Skip to content

Commit

Permalink
Merge pull request #2096 from su2code/custom_temperature_inc_solver
Browse files Browse the repository at this point in the history
Add python custom temperature and heat flux to incompressible solver
  • Loading branch information
pcarruscag authored Jul 30, 2023
2 parents c3444c8 + f679db1 commit efe8a67
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet
su2double conductivity_over_dist = 0.0;

const bool compressible_flow = (donor_config->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE);
const bool incompressible_flow = (donor_config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE) &&
const bool incompressible_flow = (donor_config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE) &&
(donor_config->GetEnergy_Equation() || (donor_config->GetKind_FluidModel() == ENUM_FLUIDMODEL::FLUID_FLAMELET));

if (compressible_flow) {
Expand Down
11 changes: 8 additions & 3 deletions SU2_CFD/src/solvers/CIncNSSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry,

const su2double FaceArea = GeometryToolbox::Norm(nDim, AreaNormal);

HeatFlow_Local += FaceArea * (-1.0) * Wall_HeatFlux/config->GetHeat_Flux_Ref();;
HeatFlow_Local += FaceArea * (-1.0) * Wall_HeatFlux/config->GetHeat_Flux_Ref();
} // loop Vertices
} // loop Heatflux marker
} // loop AllMarker
Expand Down Expand Up @@ -336,13 +336,13 @@ void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *con

const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
const bool energy = config->GetEnergy_Equation();
const bool py_custom = config->GetMarker_All_PyCustom(val_marker);

/*--- Variables for streamwise periodicity ---*/
const bool streamwise_periodic = (config->GetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE);
const bool streamwise_periodic_temperature = config->GetStreamwise_Periodic_Temperature();
su2double Cp, thermal_conductivity, dot_product, scalar_factor;


/*--- Identify the boundary by string name ---*/

const auto Marker_Tag = config->GetMarker_All_TagBound(val_marker);
Expand Down Expand Up @@ -426,6 +426,9 @@ void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *con
/*--- Apply a weak boundary condition for the energy equation.
Compute the residual due to the prescribed heat flux. ---*/

if (py_custom) {
Wall_HeatFlux = geometry->GetCustomBoundaryHeatFlux(val_marker, iVertex) / config->GetHeat_Flux_Ref();
}
LinSysRes(iPoint, nDim+1) -= Wall_HeatFlux*Area;

/*--- With streamwise periodic flow and heatflux walls an additional term is introduced in the boundary formulation ---*/
Expand Down Expand Up @@ -460,7 +463,9 @@ void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *con
break;

case ISOTHERMAL:

if (py_custom) {
Twall = geometry->GetCustomBoundaryTemperature(val_marker, iVertex) / config->GetTemperature_Ref();
}
const auto Point_Normal = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor();

/*--- Get coordinates of i & nearest normal and compute distance ---*/
Expand Down
2 changes: 1 addition & 1 deletion TestCases/py_wrapper/custom_heat_flux/run_ad.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def ApplyHeatFlux(time, driver, marker_ids):
for marker_id in marker_ids:
if marker_id < 0:
continue
hf = (-1, 0)[time > 0.2]
hf = (-1 * 2700 * 870, 0)[time > 0.2]
for i_vertex in range(driver.GetNumberMarkerNodes(marker_id)):
driver.SetMarkerCustomNormalHeatFlux(marker_id, i_vertex, hf)

Expand Down

0 comments on commit efe8a67

Please sign in to comment.