@@ -4499,7 +4499,7 @@ void CEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container,
44994499
45004500 /* --- Turbulent kinetic energy ---*/
45014501
4502- if (config->GetKind_Turb_Model () == TURB_MODEL::SST)
4502+ if (config->GetKind_Turb_Model () == TURB_MODEL::SST)
45034503 visc_numerics->SetTurbKineticEnergy (solver_container[TURB_SOL]->GetNodes ()->GetSolution (iPoint,0 ),
45044504 solver_container[TURB_SOL]->GetNodes ()->GetSolution (iPoint,0 ));
45054505
@@ -6455,19 +6455,17 @@ void CEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container,
64556455 CConfig *config, unsigned short val_marker) {
64566456 unsigned short iDim;
64576457 unsigned long iVertex, iPoint;
6458- su2double P_Total, T_Total, Velocity[3 ], Velocity2, H_Total, Temperature, Riemann,
6458+ su2double P_Total, T_Total, Velocity[MAXNDIM ], Velocity2, H_Total, Temperature, Riemann,
64596459 Pressure, Density, Energy, *Flow_Dir, Mach2, SoundSpeed2, SoundSpeed_Total2, Vel_Mag,
6460- alpha, aa, bb, cc, dd, Area, UnitNormal[3 ] ;
6460+ alpha, aa, bb, cc, dd, Area, UnitNormal[MAXNDIM], Normal[MAXNDIM] = { 0.0 } ;
64616461 su2double *V_inlet, *V_domain;
64626462
6463- bool implicit = (config->GetKind_TimeIntScheme () == EULER_IMPLICIT);
6464- su2double Two_Gamma_M1 = 2.0 /Gamma_Minus_One;
6465- su2double Gas_Constant = config->GetGas_ConstantND ();
6466- INLET_TYPE Kind_Inlet= config->GetKind_Inlet ();
6467- string Marker_Tag = config->GetMarker_All_TagBound (val_marker);
6468- bool tkeNeeded = (config->GetKind_Turb_Model () == TURB_MODEL::SST);
6469-
6470- su2double *Normal = new su2double[nDim];
6463+ const bool implicit = (config->GetKind_TimeIntScheme () == EULER_IMPLICIT);
6464+ const su2double Two_Gamma_M1 = 2.0 / Gamma_Minus_One;
6465+ const su2double Gas_Constant = config->GetGas_ConstantND ();
6466+ const auto Kind_Inlet = config->GetKind_Inlet ();
6467+ const auto Marker_Tag = config->GetMarker_All_TagBound (val_marker);
6468+ const bool tkeNeeded = (config->GetKind_Turb_Model () == TURB_MODEL::SST);
64716469
64726470 /* --- Loop over all the vertices on this boundary marker ---*/
64736471
@@ -6744,10 +6742,6 @@ void CEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container,
67446742 }
67456743 END_SU2_OMP_FOR
67466744
6747- /* --- Free locally allocated memory ---*/
6748-
6749- delete [] Normal;
6750-
67516745}
67526746
67536747void CEulerSolver::BC_Outlet (CGeometry *geometry, CSolver **solver_container,
@@ -6927,147 +6921,89 @@ void CEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container,
69276921void CEulerSolver::BC_Supersonic_Inlet (CGeometry *geometry, CSolver **solver_container,
69286922 CNumerics *conv_numerics, CNumerics *visc_numerics,
69296923 CConfig *config, unsigned short val_marker) {
6930- unsigned short iDim;
6931- unsigned long iVertex, iPoint;
6932- su2double *V_inlet, *V_domain;
6933-
6934- su2double Density, Energy, Velocity2;
6935- su2double Gas_Constant = config->GetGas_ConstantND ();
6936-
6937- bool implicit = (config->GetKind_TimeIntScheme () == EULER_IMPLICIT);
6938- string Marker_Tag = config->GetMarker_All_TagBound (val_marker);
6939- bool tkeNeeded = (config->GetKind_Turb_Model () == TURB_MODEL::SST);
6940- su2double *Normal = new su2double[nDim];
6941- su2double *Velocity = new su2double[nDim];
6924+ const su2double Gas_Constant = config->GetGas_ConstantND ();
6925+ const bool implicit = (config->GetKind_TimeIntScheme () == EULER_IMPLICIT);
6926+ const auto Marker_Tag = config->GetMarker_All_TagBound (val_marker);
6927+ const bool tkeNeeded = (config->GetKind_Turb_Model () == TURB_MODEL::SST);
69426928
69436929 /* --- Supersonic inlet flow: there are no outgoing characteristics,
69446930 so all flow variables can be imposed at the inlet.
69456931 First, retrieve the specified values for the primitive variables. ---*/
69466932
6947- auto Temperature = config->GetInlet_Temperature (Marker_Tag);
6948- auto Pressure = config->GetInlet_Pressure (Marker_Tag);
6949- auto Vel = config->GetInlet_Velocity (Marker_Tag);
6950-
6951- /* --- Non-dim. the inputs if necessary. ---*/
6933+ const su2double Temperature = config->GetInlet_Temperature (Marker_Tag) / config->GetTemperature_Ref ();
6934+ const su2double Pressure = config->GetInlet_Pressure (Marker_Tag) / config->GetPressure_Ref ();
6935+ const auto * Vel = config->GetInlet_Velocity (Marker_Tag);
69526936
6953- Temperature /= config->GetTemperature_Ref ();
6954- Pressure /= config->GetPressure_Ref ();
6955- for (iDim = 0 ; iDim < nDim; iDim++)
6937+ su2double Velocity[MAXNDIM] = {0.0 };
6938+ for (unsigned short iDim = 0 ; iDim < nDim; iDim++)
69566939 Velocity[iDim] = Vel[iDim] / config->GetVelocity_Ref ();
69576940
69586941 /* --- Density at the inlet from the gas law ---*/
69596942
6960- Density = Pressure/ (Gas_Constant* Temperature);
6943+ const su2double Density = Pressure / (Gas_Constant * Temperature);
69616944
69626945 /* --- Compute the energy from the specified state ---*/
69636946
6964- Velocity2 = 0.0 ;
6965- for (iDim = 0 ; iDim < nDim; iDim++)
6966- Velocity2 += Velocity[iDim]*Velocity[iDim];
6967- Energy = Pressure/(Density*Gamma_Minus_One)+0.5 *Velocity2;
6947+ const su2double Velocity2 = GeometryToolbox::SquaredNorm (int (MAXNDIM), Velocity);
6948+ su2double Energy = Pressure / (Density * Gamma_Minus_One) + 0.5 * Velocity2;
69686949 if (tkeNeeded) Energy += GetTke_Inf ();
69696950
69706951 /* --- Loop over all the vertices on this boundary marker ---*/
69716952
69726953 SU2_OMP_FOR_DYN (OMP_MIN_SIZE)
6973- for (iVertex = 0 ; iVertex < geometry->nVertex [val_marker]; iVertex++) {
6954+ for (auto iVertex = 0ul ; iVertex < geometry->nVertex [val_marker]; iVertex++) {
6955+ const auto iPoint = geometry->vertex [val_marker][iVertex]->GetNode ();
69746956
6975- /* --- Allocate the value at the outlet --- */
6957+ if (!geometry-> nodes -> GetDomain (iPoint)) continue ;
69766958
6977- V_inlet = GetCharacPrimVar (val_marker, iVertex);
6959+ /* --- Allocate the value at the inlet ---*/
6960+
6961+ auto * V_inlet = GetCharacPrimVar (val_marker, iVertex);
69786962
69796963 /* --- Primitive variables, using the derived quantities ---*/
69806964
6981- V_inlet[0 ] = Temperature;
6982- for (iDim = 0 ; iDim < nDim; iDim++)
6983- V_inlet[iDim+ 1 ] = Velocity[iDim] ;
6984- V_inlet[nDim+ 1 ] = Pressure;
6985- V_inlet[nDim+ 2 ] = Density;
6986- V_inlet[nDim+ 3 ] = Energy + Pressure/Density ;
6965+ V_inlet[prim_idx. Temperature () ] = Temperature;
6966+ V_inlet[prim_idx. Pressure ()] = Pressure;
6967+ V_inlet[prim_idx. Density () ] = Density ;
6968+ V_inlet[prim_idx. Enthalpy () ] = Energy + Pressure / Density ;
6969+ for ( unsigned short iDim = 0 ; iDim < nDim; iDim++)
6970+ V_inlet[iDim+prim_idx. Velocity () ] = Velocity[iDim] ;
69876971
6988- iPoint = geometry-> vertex [val_marker][iVertex]-> GetNode ();
6972+ /* --- Current solution at this boundary node --- */
69896973
6990- /* --- Check if the node belongs to the domain (i.e, not a halo node) --- */
6974+ auto * V_domain = nodes-> GetPrimitive (iPoint);
69916975
6992- if (geometry-> nodes -> GetDomain (iPoint)) {
6976+ /* --- Normal vector for this vertex (negate for outward convention) --- */
69936977
6994- /* --- Current solution at this boundary node ---*/
6978+ su2double Normal[MAXNDIM] = {0.0 };
6979+ geometry->vertex [val_marker][iVertex]->GetNormal (Normal);
6980+ for (unsigned short iDim = 0 ; iDim < nDim; iDim++) Normal[iDim] = -Normal[iDim];
69956981
6996- V_domain = nodes-> GetPrimitive (iPoint);
6982+ /* --- Set various quantities in the solver class --- */
69976983
6998- /* --- Normal vector for this vertex (negate for outward convention) ---*/
6984+ conv_numerics->SetNormal (Normal);
6985+ conv_numerics->SetPrimitive (V_domain, V_inlet);
69996986
7000- geometry->vertex [val_marker][iVertex]->GetNormal (Normal);
7001- for (iDim = 0 ; iDim < nDim; iDim++) Normal[iDim] = -Normal[iDim];
7002-
7003- /* --- Set various quantities in the solver class ---*/
6987+ if (dynamic_grid)
6988+ conv_numerics->SetGridVel (geometry->nodes ->GetGridVel (iPoint),
6989+ geometry->nodes ->GetGridVel (iPoint));
70046990
7005- conv_numerics->SetNormal (Normal);
7006- conv_numerics->SetPrimitive (V_domain, V_inlet);
6991+ /* --- Compute the residual using an upwind scheme ---*/
70076992
7008- if (dynamic_grid)
7009- conv_numerics->SetGridVel (geometry->nodes ->GetGridVel (iPoint),
7010- geometry->nodes ->GetGridVel (iPoint));
6993+ auto residual = conv_numerics->ComputeResidual (config);
70116994
7012- /* --- Compute the residual using an upwind scheme --- */
6995+ LinSysRes. AddBlock (iPoint, residual);
70136996
7014- auto residual = conv_numerics-> ComputeResidual (config);
6997+ /* --- Jacobian contribution for implicit integration --- */
70156998
7016- LinSysRes.AddBlock (iPoint, residual);
7017-
7018- /* --- Jacobian contribution for implicit integration ---*/
7019-
7020- if (implicit)
7021- Jacobian.AddBlock2Diag (iPoint, residual.jacobian_i );
6999+ if (implicit)
7000+ Jacobian.AddBlock2Diag (iPoint, residual.jacobian_i );
70227001
7023- // /*--- Viscous contribution, commented out because serious convergence problems ---*/
7024- //
7025- // if (viscous) {
7026- //
7027- // /*--- Set laminar and eddy viscosity at the infinity ---*/
7028- //
7029- // V_inlet[nDim+5] = nodes->GetLaminarViscosity(iPoint);
7030- // V_inlet[nDim+6] = nodes->GetEddyViscosity(iPoint);
7031- //
7032- // /*--- Set the normal vector and the coordinates ---*/
7033- //
7034- // visc_numerics->SetNormal(Normal);
7035- // su2double Coord_Reflected[MAXNDIM];
7036- // GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
7037- // geometry->nodes->GetCoord(iPoint), Coord_Reflected);
7038- // visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
7039- //
7040- // /*--- Primitive variables, and gradient ---*/
7041- //
7042- // visc_numerics->SetPrimitive(V_domain, V_inlet);
7043- // visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nodes->GetGradient_Primitive(iPoint));
7044- //
7045- // /*--- Turbulent kinetic energy ---*/
7046- //
7047- // if (config->GetKind_Turb_Model() == TURB_MODEL::SST)
7048- // visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0),
7049- // solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0));
7050- //
7051- // /*--- Compute and update residual ---*/
7052- //
7053- // auto residual = visc_numerics->ComputeResidual(config);
7054- // LinSysRes.SubtractBlock(iPoint, residual);
7055- //
7056- // /*--- Jacobian contribution for implicit integration ---*/
7057- //
7058- // if (implicit)
7059- // Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i);
7060- // }
7002+ /* --- Viscous contribution, omited to improve convergence. ---*/
70617003
7062- }
70637004 }
70647005 END_SU2_OMP_FOR
70657006
7066- /* --- Free locally allocated memory ---*/
7067-
7068- delete [] Normal;
7069- delete [] Velocity;
7070-
70717007}
70727008
70737009void CEulerSolver::BC_Supersonic_Outlet (CGeometry *geometry, CSolver **solver_container,
0 commit comments