-
Notifications
You must be signed in to change notification settings - Fork 847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Heat solver fixes for primal and adjoint CHT simulations #1107
Changes from 4 commits
e800a3c
afad01e
df1928a
ff99862
b82cf89
8f040d4
109f37b
2ebf8f0
54ee7cc
a004f5d
0d48aca
07cc322
85419fe
a16301b
20e012f
b6e0398
6ed646f
63f7af0
3437f2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -770,65 +770,20 @@ void CHeatSolver::Set_Heatflux_Areas(CGeometry *geometry, CConfig *config) { | |
void CHeatSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, | ||
unsigned short val_marker) { | ||
|
||
unsigned long iPoint, iVertex, Point_Normal; | ||
unsigned short iDim; | ||
su2double *Normal, *Coord_i, *Coord_j, Area, dist_ij, laminar_viscosity, thermal_diffusivity, Twall, dTdn, Prandtl_Lam; | ||
//su2double Prandtl_Turb; | ||
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) | ||
|| (config->GetKind_Solver() == DISC_ADJ_INC_RANS)); | ||
const bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); | ||
const auto Marker_Tag = config->GetMarker_All_TagBound(val_marker); | ||
const su2double Twall = config->GetIsothermal_Temperature(Marker_Tag)/config->GetTemperature_Ref(); | ||
|
||
Prandtl_Lam = config->GetPrandtl_Lam(); | ||
// Prandtl_Turb = config->GetPrandtl_Turb(); | ||
laminar_viscosity = config->GetMu_ConstantND(); | ||
//Prandtl_Turb = config->GetPrandtl_Turb(); | ||
//laminar_viscosity = config->GetViscosity_FreeStreamND(); // TDE check for consistency for CHT | ||
for (auto iVertex = 0u; iVertex < geometry->nVertex[val_marker]; iVertex++) { | ||
const auto iPoint = geometry->vertex[val_marker][iVertex]->GetNode(); | ||
|
||
string Marker_Tag = config->GetMarker_All_TagBound(val_marker); | ||
|
||
Twall = config->GetIsothermal_Temperature(Marker_Tag)/config->GetTemperature_Ref(); | ||
if (!geometry->nodes->GetDomain(iPoint)) continue; | ||
|
||
for (iVertex = 0; iVertex < geometry->nVertex[val_marker]; iVertex++) { | ||
nodes->SetSolution_Old(iPoint,&Twall); | ||
LinSysRes(iPoint, 0) = 0.0; | ||
nodes->SetRes_TruncErrorZero(iPoint); | ||
|
||
iPoint = geometry->vertex[val_marker][iVertex]->GetNode(); | ||
|
||
if (geometry->nodes->GetDomain(iPoint)) { | ||
|
||
Point_Normal = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor(); | ||
|
||
Normal = geometry->vertex[val_marker][iVertex]->GetNormal(); | ||
Area = 0.0; | ||
for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; | ||
Area = sqrt (Area); | ||
|
||
Coord_i = geometry->nodes->GetCoord(iPoint); | ||
Coord_j = geometry->nodes->GetCoord(Point_Normal); | ||
dist_ij = 0; | ||
for (iDim = 0; iDim < nDim; iDim++) | ||
dist_ij += (Coord_j[iDim]-Coord_i[iDim])*(Coord_j[iDim]-Coord_i[iDim]); | ||
dist_ij = sqrt(dist_ij); | ||
|
||
dTdn = -(nodes->GetSolution(Point_Normal,0) - Twall)/dist_ij; | ||
|
||
if(flow) { | ||
thermal_diffusivity = laminar_viscosity/Prandtl_Lam; | ||
} | ||
else | ||
thermal_diffusivity = config->GetThermalDiffusivity_Solid(); | ||
|
||
Res_Visc[0] = thermal_diffusivity*dTdn*Area; | ||
|
||
if(implicit) { | ||
|
||
Jacobian_i[0][0] = -thermal_diffusivity/dist_ij * Area; | ||
} | ||
|
||
LinSysRes.SubtractBlock(iPoint, Res_Visc); | ||
Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); | ||
} | ||
if (implicit) Jacobian.DeleteValsRowi(iPoint); | ||
} | ||
} | ||
|
||
|
@@ -1143,6 +1098,12 @@ void CHeatSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **solv | |
|
||
HeatFluxDensity = thermal_diffusivity*(Tinterface - Tnormal_Conjugate); | ||
HeatFlux = HeatFluxDensity * Area; | ||
|
||
if (implicit) { | ||
|
||
Jacobian_i[0][0] = -thermal_diffusivity*Area; | ||
Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); | ||
} | ||
Comment on lines
+1142
to
+1146
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The sign, I also moved this so that it only applies to one of the coupling modes, to be consistent with the implementation of the heat flux wall. |
||
} | ||
else { | ||
|
||
|
@@ -1152,12 +1113,6 @@ void CHeatSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **solv | |
|
||
Res_Visc[0] = -HeatFlux; | ||
LinSysRes.SubtractBlock(iPoint, Res_Visc); | ||
|
||
if (implicit) { | ||
|
||
Jacobian_i[0][0] = thermal_diffusivity*Area; | ||
Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i); | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -1642,7 +1597,9 @@ void CHeatSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ | |
|
||
/*--- Solve or smooth the linear system ---*/ | ||
|
||
System.Solve(Jacobian, LinSysRes, LinSysSol, geometry, config); | ||
auto iter = System.Solve(Jacobian, LinSysRes, LinSysSol, geometry, config); | ||
SetIterLinSolver(iter); | ||
SetResLinSolver(System.GetResidual()); | ||
Comment on lines
+1640
to
+1642
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes, it also fixes the output of the linear solver stuff. |
||
|
||
for (iPoint = 0; iPoint < nPointDomain; iPoint++) { | ||
for (iVar = 0; iVar < nVar; iVar++) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
took me a second to figure out what happens here with the override function in the child and the default argument in the parent class. Kind of odd that the override function understands that it has to use the default argument of the parent implementation... I hope I understood that correctly (I used Compiler Explorer to make a sample)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can think of it as the default value being part of the function signature, the signature is defined by the original virtual function which is all a caller needs to know (you include CIteration.hpp to use all the other iterations), the default value is passed when calling, not used when "receiving" the call.