@@ -1141,41 +1141,54 @@ void CFVMFlowSolverBase<V, FlowRegime>::BC_Sym_Plane(CGeometry* geometry, CSolve
11411141 for (auto iDim = 0u ; iDim < nDim; iDim++) UnitNormal[iDim] = Normal[iDim] / Area;
11421142 }
11431143
1144- su2double* V_reflected = GetCharacPrimVar (val_marker, iVertex);
1144+ /* --- Energy terms due to grid movement (aka work of pressure forces). ---*/
1145+ if (dynamic_grid) {
1146+ su2double* V_reflected = GetCharacPrimVar (val_marker, iVertex);
11451147
1146- /* --- Grid movement ---*/
1147- if (dynamic_grid)
1148- conv_numerics->SetGridVel (geometry->nodes ->GetGridVel (iPoint), geometry->nodes ->GetGridVel (iPoint));
1148+ conv_numerics->SetGridVel (geometry->nodes ->GetGridVel (iPoint),
1149+ geometry->nodes ->GetGridVel (iPoint));
11491150
1150- /* --- Normal vector for this vertex (negate for outward convention). ---*/
1151- for (auto iDim = 0u ; iDim < nDim; iDim++) Normal[iDim] = -Normal[iDim];
1152- conv_numerics->SetNormal (Normal);
1151+ /* --- Normal vector for this vertex (negate for outward convention). ---*/
1152+ for (auto iDim = 0u ; iDim < nDim; iDim++) Normal[iDim] = -Normal[iDim];
1153+ conv_numerics->SetNormal (Normal);
11531154
1154- for (auto iVar = 0u ; iVar < nPrimVar; iVar++)
1155- V_reflected[iVar] = nodes->GetPrimitive (iPoint, iVar);
1155+ for (auto iVar = 0u ; iVar < nPrimVar; iVar++)
1156+ V_reflected[iVar] = nodes->GetPrimitive (iPoint, iVar);
11561157
1157- su2double ProjVelocity_i = nodes->GetProjVel (iPoint, UnitNormal);
1158- /* --- Adjustment to v.n due to grid movement. ---*/
1159- if (dynamic_grid)
1158+ su2double ProjVelocity_i = nodes->GetProjVel (iPoint, UnitNormal);
1159+ /* --- Adjustment to v.n due to grid movement. ---*/
11601160 ProjVelocity_i -= GeometryToolbox::DotProduct (nDim, geometry->nodes ->GetGridVel (iPoint), UnitNormal);
11611161
1162- for (auto iDim = 0u ; iDim < nDim; iDim++)
1163- V_reflected[iDim + iVel] = nodes->GetVelocity (iPoint, iDim) - ProjVelocity_i * UnitNormal[iDim];
1162+ for (auto iDim = 0u ; iDim < nDim; iDim++)
1163+ V_reflected[iDim + iVel] = nodes->GetVelocity (iPoint, iDim) - ProjVelocity_i * UnitNormal[iDim];
11641164
1165- /* --- Get current solution at this boundary node ---*/
1166- const su2double* V_domain = nodes->GetPrimitive (iPoint);
1165+ /* --- Get current solution at this boundary node. ---*/
1166+ const su2double* V_domain = nodes->GetPrimitive (iPoint);
11671167
1168- /* --- Set Primitive and Secondary for numerics class. ---*/
1169- conv_numerics->SetPrimitive (V_domain, V_reflected);
1170- conv_numerics->SetSecondary (nodes->GetSecondary (iPoint), nodes->GetSecondary (iPoint));
1168+ /* --- Set Primitive and Secondary for numerics class. ---*/
1169+ conv_numerics->SetPrimitive (V_domain, V_reflected);
1170+ conv_numerics->SetSecondary (nodes->GetSecondary (iPoint), nodes->GetSecondary (iPoint));
11711171
1172- /* --- Compute the residual using an upwind scheme. ---*/
1173- auto residual = conv_numerics->ComputeResidual (config);
1172+ /* --- Compute the residual using an upwind scheme. ---*/
1173+ auto residual = conv_numerics->ComputeResidual (config);
11741174
1175- /* --- We include an update of the continuity and energy here, this is important for stability since
1176- * these fluxes include numerical diffusion. ---*/
1177- for (auto iVar = 0u ; iVar < nVar; iVar++) {
1178- if (iVar < iVel || iVar >= iVel + nDim) LinSysRes (iPoint, iVar) += residual.residual [iVar];
1175+ /* --- Use just the energy fluxes to update the residual, adding the others would
1176+ * increase numerical diffusion which we wish to avoid if possible. ---*/
1177+ for (auto iVar = iVel + nDim; iVar < nVar; iVar++) {
1178+ LinSysRes (iPoint, iVar) += residual.residual [iVar];
1179+ }
1180+ if (implicit) {
1181+ auto * block = Jacobian.GetBlock (iPoint, iPoint);
1182+ /* --- But in the Jacobian we also include the mass flux, this allows some cases with
1183+ * motion to use larger CFL, for example pywrapper_translating_naca0012. ---*/
1184+ for (auto iVar = 0u ; iVar < nVar; iVar++) {
1185+ if (iVar < iVel || iVar >= iVel + nDim) {
1186+ for (auto jVar = 0u ; jVar < nVar; jVar++) {
1187+ block[iVar * nVar + jVar] += SU2_TYPE::GetValue (residual.jacobian_i [iVar][jVar]);
1188+ }
1189+ }
1190+ }
1191+ }
11791192 }
11801193
11811194 /* --- Explicitly set the velocity components normal to the symmetry plane to zero.
@@ -1184,7 +1197,7 @@ void CFVMFlowSolverBase<V, FlowRegime>::BC_Sym_Plane(CGeometry* geometry, CSolve
11841197
11851198 su2double* solutionOld = nodes->GetSolution_Old (iPoint);
11861199
1187- su2double gridVel[MAXNVAR ] = {};
1200+ su2double gridVel[MAXNDIM ] = {};
11881201 if (dynamic_grid) {
11891202 for (auto iDim = 0u ; iDim < nDim; iDim++) {
11901203 gridVel[iDim] = geometry->nodes ->GetGridVel (iPoint)[iDim];
@@ -1215,7 +1228,30 @@ void CFVMFlowSolverBase<V, FlowRegime>::BC_Sym_Plane(CGeometry* geometry, CSolve
12151228
12161229 /* --- Jacobian contribution for implicit integration. ---*/
12171230 if (implicit) {
1218- Jacobian.AddBlock2Diag (iPoint, residual.jacobian_i );
1231+ /* --- Modify the Jacobians according to the modification of the residual
1232+ * J_new = (I - n * n^T) * J where n = {0, nx, ny, nz, 0, ...} ---*/
1233+ su2double mat[MAXNVAR * MAXNVAR] = {};
1234+
1235+ for (auto iVar = 0u ; iVar < nVar; iVar++)
1236+ mat[iVar * nVar + iVar] = 1 ;
1237+ for (auto iDim = 0u ; iDim < nDim; iDim++)
1238+ for (auto jDim = 0u ; jDim < nDim; jDim++)
1239+ mat[(iDim + iVel) * nVar + jDim + iVel] -= UnitNormal[iDim] * UnitNormal[jDim];
1240+
1241+ auto ModifyJacobian = [&](const unsigned long jPoint) {
1242+ su2double jac[MAXNVAR * MAXNVAR], newJac[MAXNVAR * MAXNVAR];
1243+ auto * block = Jacobian.GetBlock (iPoint, jPoint);
1244+ for (auto iVar = 0u ; iVar < nVar * nVar; iVar++) jac[iVar] = block[iVar];
1245+
1246+ CBlasStructure ().gemm (nVar, nVar, nVar, mat, jac, newJac, config);
1247+
1248+ for (auto iVar = 0u ; iVar < nVar * nVar; iVar++)
1249+ block[iVar] = SU2_TYPE::GetValue (newJac[iVar]);
1250+ };
1251+ ModifyJacobian (iPoint);
1252+ for (size_t iNeigh = 0 ; iNeigh < geometry->nodes ->GetnPoint (iPoint); ++iNeigh) {
1253+ ModifyJacobian (geometry->nodes ->GetPoint (iPoint, iNeigh));
1254+ }
12191255 }
12201256
12211257 /* --- Correction for multigrid. ---*/
0 commit comments