@@ -1143,41 +1143,54 @@ void CFVMFlowSolverBase<V, FlowRegime>::BC_Sym_Plane(CGeometry* geometry, CSolve
11431143 for (auto iDim = 0u ; iDim < nDim; iDim++) UnitNormal[iDim] = Normal[iDim] / Area;
11441144 }
11451145
1146- su2double* V_reflected = GetCharacPrimVar (val_marker, iVertex);
1146+ /* --- Energy terms due to grid movement (aka work of pressure forces). ---*/
1147+ if (dynamic_grid) {
1148+ su2double* V_reflected = GetCharacPrimVar (val_marker, iVertex);
11471149
1148- /* --- Grid movement ---*/
1149- if (dynamic_grid)
1150- conv_numerics->SetGridVel (geometry->nodes ->GetGridVel (iPoint), geometry->nodes ->GetGridVel (iPoint));
1150+ conv_numerics->SetGridVel (geometry->nodes ->GetGridVel (iPoint),
1151+ geometry->nodes ->GetGridVel (iPoint));
11511152
1152- /* --- Normal vector for this vertex (negate for outward convention). ---*/
1153- for (auto iDim = 0u ; iDim < nDim; iDim++) Normal[iDim] = -Normal[iDim];
1154- conv_numerics->SetNormal (Normal);
1153+ /* --- Normal vector for this vertex (negate for outward convention). ---*/
1154+ for (auto iDim = 0u ; iDim < nDim; iDim++) Normal[iDim] = -Normal[iDim];
1155+ conv_numerics->SetNormal (Normal);
11551156
1156- for (auto iVar = 0u ; iVar < nPrimVar; iVar++)
1157- V_reflected[iVar] = nodes->GetPrimitive (iPoint, iVar);
1157+ for (auto iVar = 0u ; iVar < nPrimVar; iVar++)
1158+ V_reflected[iVar] = nodes->GetPrimitive (iPoint, iVar);
11581159
1159- su2double ProjVelocity_i = nodes->GetProjVel (iPoint, UnitNormal);
1160- /* --- Adjustment to v.n due to grid movement. ---*/
1161- if (dynamic_grid)
1160+ su2double ProjVelocity_i = nodes->GetProjVel (iPoint, UnitNormal);
1161+ /* --- Adjustment to v.n due to grid movement. ---*/
11621162 ProjVelocity_i -= GeometryToolbox::DotProduct (nDim, geometry->nodes ->GetGridVel (iPoint), UnitNormal);
11631163
1164- for (auto iDim = 0u ; iDim < nDim; iDim++)
1165- V_reflected[iDim + iVel] = nodes->GetVelocity (iPoint, iDim) - ProjVelocity_i * UnitNormal[iDim];
1164+ for (auto iDim = 0u ; iDim < nDim; iDim++)
1165+ V_reflected[iDim + iVel] = nodes->GetVelocity (iPoint, iDim) - ProjVelocity_i * UnitNormal[iDim];
11661166
1167- /* --- Get current solution at this boundary node ---*/
1168- const su2double* V_domain = nodes->GetPrimitive (iPoint);
1167+ /* --- Get current solution at this boundary node. ---*/
1168+ const su2double* V_domain = nodes->GetPrimitive (iPoint);
11691169
1170- /* --- Set Primitive and Secondary for numerics class. ---*/
1171- conv_numerics->SetPrimitive (V_domain, V_reflected);
1172- conv_numerics->SetSecondary (nodes->GetSecondary (iPoint), nodes->GetSecondary (iPoint));
1170+ /* --- Set Primitive and Secondary for numerics class. ---*/
1171+ conv_numerics->SetPrimitive (V_domain, V_reflected);
1172+ conv_numerics->SetSecondary (nodes->GetSecondary (iPoint), nodes->GetSecondary (iPoint));
11731173
1174- /* --- Compute the residual using an upwind scheme. ---*/
1175- auto residual = conv_numerics->ComputeResidual (config);
1174+ /* --- Compute the residual using an upwind scheme. ---*/
1175+ auto residual = conv_numerics->ComputeResidual (config);
11761176
1177- /* --- We include an update of the continuity and energy here, this is important for stability since
1178- * these fluxes include numerical diffusion. ---*/
1179- for (auto iVar = 0u ; iVar < nVar; iVar++) {
1180- if (iVar < iVel || iVar >= iVel + nDim) LinSysRes (iPoint, iVar) += residual.residual [iVar];
1177+ /* --- Use just the energy fluxes to update the residual, adding the others would
1178+ * increase numerical diffusion which we wish to avoid if possible. ---*/
1179+ for (auto iVar = iVel + nDim; iVar < nVar; iVar++) {
1180+ LinSysRes (iPoint, iVar) += residual.residual [iVar];
1181+ }
1182+ if (implicit) {
1183+ auto * block = Jacobian.GetBlock (iPoint, iPoint);
1184+ /* --- But in the Jacobian we also include the mass flux, this allows some cases with
1185+ * motion to use larger CFL, for example pywrapper_translating_naca0012. ---*/
1186+ for (auto iVar = 0u ; iVar < nVar; iVar++) {
1187+ if (iVar < iVel || iVar >= iVel + nDim) {
1188+ for (auto jVar = 0u ; jVar < nVar; jVar++) {
1189+ block[iVar * nVar + jVar] += SU2_TYPE::GetValue (residual.jacobian_i [iVar][jVar]);
1190+ }
1191+ }
1192+ }
1193+ }
11811194 }
11821195
11831196 /* --- Explicitly set the velocity components normal to the symmetry plane to zero.
@@ -1186,7 +1199,7 @@ void CFVMFlowSolverBase<V, FlowRegime>::BC_Sym_Plane(CGeometry* geometry, CSolve
11861199
11871200 su2double* solutionOld = nodes->GetSolution_Old (iPoint);
11881201
1189- su2double gridVel[MAXNVAR ] = {};
1202+ su2double gridVel[MAXNDIM ] = {};
11901203 if (dynamic_grid) {
11911204 for (auto iDim = 0u ; iDim < nDim; iDim++) {
11921205 gridVel[iDim] = geometry->nodes ->GetGridVel (iPoint)[iDim];
@@ -1217,7 +1230,30 @@ void CFVMFlowSolverBase<V, FlowRegime>::BC_Sym_Plane(CGeometry* geometry, CSolve
12171230
12181231 /* --- Jacobian contribution for implicit integration. ---*/
12191232 if (implicit) {
1220- Jacobian.AddBlock2Diag (iPoint, residual.jacobian_i );
1233+ /* --- Modify the Jacobians according to the modification of the residual
1234+ * J_new = (I - n * n^T) * J where n = {0, nx, ny, nz, 0, ...} ---*/
1235+ su2double mat[MAXNVAR * MAXNVAR] = {};
1236+
1237+ for (auto iVar = 0u ; iVar < nVar; iVar++)
1238+ mat[iVar * nVar + iVar] = 1 ;
1239+ for (auto iDim = 0u ; iDim < nDim; iDim++)
1240+ for (auto jDim = 0u ; jDim < nDim; jDim++)
1241+ mat[(iDim + iVel) * nVar + jDim + iVel] -= UnitNormal[iDim] * UnitNormal[jDim];
1242+
1243+ auto ModifyJacobian = [&](const unsigned long jPoint) {
1244+ su2double jac[MAXNVAR * MAXNVAR], newJac[MAXNVAR * MAXNVAR];
1245+ auto * block = Jacobian.GetBlock (iPoint, jPoint);
1246+ for (auto iVar = 0u ; iVar < nVar * nVar; iVar++) jac[iVar] = block[iVar];
1247+
1248+ CBlasStructure ().gemm (nVar, nVar, nVar, mat, jac, newJac, config);
1249+
1250+ for (auto iVar = 0u ; iVar < nVar * nVar; iVar++)
1251+ block[iVar] = SU2_TYPE::GetValue (newJac[iVar]);
1252+ };
1253+ ModifyJacobian (iPoint);
1254+ for (size_t iNeigh = 0 ; iNeigh < geometry->nodes ->GetnPoint (iPoint); ++iNeigh) {
1255+ ModifyJacobian (geometry->nodes ->GetPoint (iPoint, iNeigh));
1256+ }
12211257 }
12221258
12231259 /* --- Correction for multigrid. ---*/
0 commit comments