Skip to content

Commit

Permalink
Merge branch 'develop' into fix_cornernode_comp
Browse files Browse the repository at this point in the history
  • Loading branch information
bigfooted authored Sep 15, 2024
2 parents 4b13197 + c918e04 commit f81246c
Show file tree
Hide file tree
Showing 16 changed files with 117 additions and 18 deletions.
17 changes: 17 additions & 0 deletions Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class CConfig {
su2double Buffet_lambda; /*!< \brief Offset parameter for buffet sensor.*/
su2double Damp_Engine_Inflow; /*!< \brief Damping factor for the engine inlet. */
su2double Damp_Engine_Exhaust; /*!< \brief Damping factor for the engine exhaust. */
unsigned long Bc_Eval_Freq; /*!< \brief Evaluation frequency for Engine and Actuator disk markers. */
su2double Damp_Res_Restric, /*!< \brief Damping factor for the residual restriction. */
Damp_Correc_Prolong; /*!< \brief Damping factor for the correction prolongation. */
su2double Position_Plane; /*!< \brief Position of the Near-Field (y coordinate 2D, and z coordinate 3D). */
Expand Down Expand Up @@ -192,6 +193,7 @@ class CConfig {
nMarker_Fluid_Load, /*!< \brief Number of markers in which the flow load is computed/employed. */
nMarker_Fluid_InterfaceBound, /*!< \brief Number of fluid interface markers. */
nMarker_CHTInterface, /*!< \brief Number of conjugate heat transfer interface markers. */
nMarker_ContactResistance, /*!< \brief Number of CHT interfaces with contact resistance. */
nMarker_Inlet, /*!< \brief Number of inlet flow markers. */
nMarker_Inlet_Species, /*!< \brief Number of inlet species markers. */
nSpecies_per_Inlet, /*!< \brief Number of species defined per inlet markers. */
Expand Down Expand Up @@ -396,6 +398,7 @@ class CConfig {
su2double **Periodic_RotCenter; /*!< \brief Rotational center for each periodic boundary. */
su2double **Periodic_RotAngles; /*!< \brief Rotation angles for each periodic boundary. */
su2double **Periodic_Translation; /*!< \brief Translation vector for each periodic boundary. */
su2double *CHT_ContactResistance; /*!< \brief Contact resistance values for each solid-solid CHT interface. */
string *Marker_CfgFile_TagBound; /*!< \brief Global index for markers using config file. */
unsigned short *Marker_All_KindBC, /*!< \brief Global index for boundaries using grid information. */
*Marker_CfgFile_KindBC; /*!< \brief Global index for boundaries using config file. */
Expand Down Expand Up @@ -589,6 +592,7 @@ class CConfig {
bool EulerPersson; /*!< \brief Boolean to determine whether this is an Euler simulation with Persson shock capturing. */
bool FSI_Problem = false,/*!< \brief Boolean to determine whether the simulation is FSI or not. */
Multizone_Problem; /*!< \brief Boolean to determine whether we are solving a multizone problem. */
//bool ContactResistance = false; /*!< \brief Apply contact resistance for conjugate heat transfer. */
unsigned short nID_DV; /*!< \brief ID for the region of FEM when computed using direct differentiation. */

bool AD_Mode; /*!< \brief Algorithmic Differentiation support. */
Expand Down Expand Up @@ -3662,6 +3666,13 @@ class CConfig {
*/
unsigned short GetMarker_n_ZoneInterface(void) const { return nMarker_ZoneInterface; }

/*!
* \brief Get the contact resistance value of a specified interface.
* \param[in] val_interface interface index.
* \return Contact resistance value (zero by default).
*/
su2double GetContactResistance(unsigned short val_interface) const { return (nMarker_ContactResistance > 0) ? CHT_ContactResistance[val_interface] : 0.0; }

/*!
* \brief Get the DV information for a marker <i>val_marker</i>.
* \param[in] val_marker - 0 or 1 depending if the the marker is going to be affected by design variables.
Expand Down Expand Up @@ -6505,6 +6516,12 @@ class CConfig {
*/
su2double GetMinLogResidual(void) const { return MinLogResidual; }

/*!
* \brief Evaluation frequency for Engine and Actuator disk markers.
* \return Value Evaluation frequency .
*/
unsigned long GetBc_Eval_Freq(void) const { return Bc_Eval_Freq; }

/*!
* \brief Value of the damping factor for the engine inlet bc.
* \return Value of the damping factor.
Expand Down
1 change: 1 addition & 0 deletions Common/include/option_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ enum ENUM_TRANSFER {
CONJUGATE_HEAT_WEAKLY_FS = 17, /*!< \brief Conjugate heat transfer (between incompressible fluids and solids). */
CONJUGATE_HEAT_SF = 18, /*!< \brief Conjugate heat transfer (between solids and compressible fluids). */
CONJUGATE_HEAT_WEAKLY_SF = 19, /*!< \brief Conjugate heat transfer (between solids and incompressible fluids). */
CONJUGATE_HEAT_SS = 20, /*!< \brief Conjugate heat transfer (between two solids). */
};

/*!
Expand Down
23 changes: 23 additions & 0 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,8 @@ void CConfig::SetConfig_Options() {
addStringListOption("MARKER_ZONE_INTERFACE", nMarker_ZoneInterface, Marker_ZoneInterface);
/*!\brief MARKER_CHT_INTERFACE \n DESCRIPTION: CHT interface boundary marker(s) \ingroup Config*/
addStringListOption("MARKER_CHT_INTERFACE", nMarker_CHTInterface, Marker_CHTInterface);
/*!\brief CHT_INTERFACE_CONTACT_RESISTANCE: Thermal contact resistance values for each CHT inerface. \ingroup Config*/
addDoubleListOption("CHT_INTERFACE_CONTACT_RESISTANCE", nMarker_ContactResistance, CHT_ContactResistance);
/* DESCRIPTION: Internal boundary marker(s) */
addStringListOption("MARKER_INTERNAL", nMarker_Internal, Marker_Internal);
/* DESCRIPTION: Custom boundary marker(s) */
Expand Down Expand Up @@ -1734,6 +1736,8 @@ void CConfig::SetConfig_Options() {
/*!\brief RAMP_AND_RELEASE\n DESCRIPTION: release the load after applying the ramp*/
addBoolOption("RAMP_AND_RELEASE_LOAD", RampAndRelease, false);

/* DESCRIPTION: Evaluation frequency for Engine and Actuator disk markers. */
addUnsignedLongOption("BC_EVAL_FREQ", Bc_Eval_Freq, 40);
/* DESCRIPTION: Damping factor for engine inlet condition */
addDoubleOption("DAMP_ENGINE_INFLOW", Damp_Engine_Inflow, 0.95);
/* DESCRIPTION: Damping factor for engine exhaust condition */
Expand Down Expand Up @@ -3560,6 +3564,25 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
SU2_MPI::Error(string("You probably want to set INC_ENERGY_EQUATION= YES for the fluid solver. \n"), CURRENT_FUNCTION);
}

/*--- Check correctness and consistency of contact resistance options. ---*/
if (nMarker_ContactResistance > 0) {

/*--- Set constant contact resistance across CHT interfaces if a single value is provided. ---*/
if (nMarker_ContactResistance == 1) {
auto val_CHTInterface = CHT_ContactResistance[0];
delete [] CHT_ContactResistance;
CHT_ContactResistance = new su2double[nMarker_CHTInterface];
for (auto iCHTMarker=0u; iCHTMarker < nMarker_CHTInterface; iCHTMarker++)
CHT_ContactResistance[iCHTMarker] = val_CHTInterface;
}else if((nMarker_CHTInterface/2) != nMarker_ContactResistance){
SU2_MPI::Error("Number of CHT interfaces does not match number of contact resistances.", CURRENT_FUNCTION);
}
for (auto iCHTMarker=0u; iCHTMarker < nMarker_ContactResistance; iCHTMarker++){
if (CHT_ContactResistance[iCHTMarker] < 0)
SU2_MPI::Error("Contact resistance value should be positive.", CURRENT_FUNCTION);
}
}

/*--- By default, in 2D we should use TWOD_AIRFOIL (independenly from the input file) ---*/

if (val_nDim == 2) Geo_Description = TWOD_AIRFOIL;
Expand Down
5 changes: 5 additions & 0 deletions SU2_CFD/include/interfaces/CInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,9 @@ class CInterface {
*/
void GatherAverageValues(CSolver *donor_solution, CSolver *target_solution, unsigned short donorZone);

/*!
* \brief Set the contact resistance value for the solid-to-solid heat transfer interface.
* \param[in] val_contact_resistance - Contact resistance value in m^2/W
*/
inline virtual void SetContactResistance(su2double val_contact_resistance) {};
};
7 changes: 7 additions & 0 deletions SU2_CFD/include/interfaces/cht/CConjugateHeatInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* \ingroup Interfaces
*/
class CConjugateHeatInterface : public CInterface {
su2double ContactResistance = 0; /*!<\brief Contact resistance value of the current inerface. */
public:
/*!
* \brief Constructor of the class.
Expand Down Expand Up @@ -70,4 +71,10 @@ class CConjugateHeatInterface : public CInterface {
*/
void SetTarget_Variable(CSolver *target_solution, CGeometry *target_geometry, const CConfig *target_config,
unsigned long Marker_Target, unsigned long Vertex_Target, unsigned long Point_Target) override;

/*!
* \brief Set the contact resistance value for the solid-to-solid heat transfer interface.
* \param[in] val_contact_resistance - Contact resistance value in m^2/W
*/
void SetContactResistance(su2double val_contact_resistance) override { ContactResistance = val_contact_resistance; }
};
24 changes: 13 additions & 11 deletions SU2_CFD/src/drivers/CDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2494,19 +2494,21 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet
}
}
else if (heat_donor || heat_target) {
if (heat_donor && heat_target)
SU2_MPI::Error("Conjugate heat transfer between solids is not implemented.", CURRENT_FUNCTION);
if (heat_donor && heat_target){
interface_type = CONJUGATE_HEAT_SS;

const auto fluidZone = heat_target? donor : target;

if (config[fluidZone]->GetEnergy_Equation() || (config[fluidZone]->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE)
|| (config[fluidZone]->GetKind_FluidModel() == ENUM_FLUIDMODEL::FLUID_FLAMELET))
interface_type = heat_target? CONJUGATE_HEAT_FS : CONJUGATE_HEAT_SF;
else if (config[fluidZone]->GetWeakly_Coupled_Heat())
interface_type = heat_target? CONJUGATE_HEAT_WEAKLY_FS : CONJUGATE_HEAT_WEAKLY_SF;
else
interface_type = NO_TRANSFER;
} else {

const auto fluidZone = heat_target? donor : target;
if (config[fluidZone]->GetEnergy_Equation() || (config[fluidZone]->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE)
|| (config[fluidZone]->GetKind_FluidModel() == ENUM_FLUIDMODEL::FLUID_FLAMELET))
interface_type = heat_target? CONJUGATE_HEAT_FS : CONJUGATE_HEAT_SF;
else if (config[fluidZone]->GetWeakly_Coupled_Heat())
interface_type = heat_target? CONJUGATE_HEAT_WEAKLY_FS : CONJUGATE_HEAT_WEAKLY_SF;
else
interface_type = NO_TRANSFER;
}

if (interface_type != NO_TRANSFER) {
auto nVar = 4;
interface[donor][target] = new CConjugateHeatInterface(nVar, 0);
Expand Down
3 changes: 3 additions & 0 deletions SU2_CFD/src/drivers/CMultizoneDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,9 @@ bool CMultizoneDriver::TransferData(unsigned short donorZone, unsigned short tar
BroadcastData(SPECIES_SOL, SPECIES_SOL);
}
break;
case CONJUGATE_HEAT_SS:
BroadcastData(HEAT_SOL, HEAT_SOL);
break;
case CONJUGATE_HEAT_FS:
BroadcastData(FLOW_SOL, HEAT_SOL);
break;
Expand Down
4 changes: 2 additions & 2 deletions SU2_CFD/src/drivers/CSinglezoneDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ void CSinglezoneDriver::StartSolver() {
TimeIter = config_container[ZONE_0]->GetRestart_Iter();

/*--- Run the problem until the number of time iterations required is reached. ---*/
while ( TimeIter < config_container[ZONE_0]->GetnTime_Iter() ) {

/*--- or until a SIGTERM signal stops the loop. We catch SIGTERM and exit gracefully ---*/
while ( TimeIter < config_container[ZONE_0]->GetnTime_Iter()) {
/*--- Perform some preprocessing before starting the time-step simulation. ---*/

Preprocess(TimeIter);
Expand Down
5 changes: 5 additions & 0 deletions SU2_CFD/src/interfaces/CInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ void CInterface::BroadcastData(const CInterpolator& interpolator,
su2activematrix sendDonorVar(nLocalVertexDonor, nVar);

if (markDonor >= 0) {

/*--- Apply contact resistance if specified. ---*/

SetContactResistance(donor_config->GetContactResistance(iMarkerInt));

for (auto iVertex = 0ul, iSend = 0ul; iVertex < donor_geometry->GetnVertex(markDonor); iVertex++) {
const auto iPoint = donor_geometry->vertex[markDonor][iVertex]->GetNode();

Expand Down
4 changes: 3 additions & 1 deletion SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet
if ((donor_config->GetKind_CHT_Coupling() == CHT_COUPLING::DIRECT_TEMPERATURE_ROBIN_HEATFLUX) ||
(donor_config->GetKind_CHT_Coupling() == CHT_COUPLING::AVERAGED_TEMPERATURE_ROBIN_HEATFLUX)) {

/*--- Apply contact resistance to solid-to-solid heat transfer boundary ---*/
const su2double rho_cp_solid = donor_config->GetSpecific_Heat_Cp()*donor_config->GetMaterialDensity(0);
conductivity_over_dist = thermal_diffusivity*rho_cp_solid/dist;
thermal_conductivity = thermal_diffusivity * rho_cp_solid;
conductivity_over_dist = thermal_conductivity/(dist + thermal_conductivity * ContactResistance);
}
}

Expand Down
24 changes: 22 additions & 2 deletions SU2_CFD/src/output/COutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
*/

#include <iostream>
#include <csignal>

#include "../../../Common/include/geometry/CGeometry.hpp"
#include "../../include/solvers/CSolver.hpp"

Expand All @@ -47,6 +50,15 @@
#include "../../include/output/filewriter/CSU2BinaryFileWriter.hpp"
#include "../../include/output/filewriter/CSU2MeshFileWriter.hpp"

namespace {
volatile sig_atomic_t STOP;

void signalHandler(int signum) {
std::cout << "Interrupt signal (" << signum << ") received, saving files and exiting.\n";
STOP = 1;
}
}

COutput::COutput(const CConfig *config, unsigned short ndim, bool fem_output):
rank(SU2_MPI::GetRank()),
size(SU2_MPI::GetSize()),
Expand Down Expand Up @@ -169,7 +181,11 @@ COutput::COutput(const CConfig *config, unsigned short ndim, bool fem_output):
volumeDataSorter = nullptr;
surfaceDataSorter = nullptr;

headerNeeded = false;
headerNeeded = false;

/*--- Setup a signal handler for SIGTERM. ---*/

signal(SIGTERM, signalHandler);
}

COutput::~COutput() {
Expand Down Expand Up @@ -233,7 +249,7 @@ void COutput::SetHistoryOutput(CGeometry ****geometry, CSolver *****solver, CCon

if (config[ZONE_0]->GetMultizone_Problem())
Iter = OuterIter;

/*--- Turbomachinery Performance Screen summary output---*/
if (Iter%100 == 0 && rank == MASTER_NODE) {
SetTurboPerformance_Output(TurboPerf, config[val_iZone], TimeIter, OuterIter, InnerIter);
Expand Down Expand Up @@ -946,9 +962,13 @@ bool COutput::ConvergenceMonitoring(CConfig *config, unsigned long Iteration) {

if (convFields.empty() || Iteration < config->GetStartConv_Iter()) convergence = false;

/*--- If a SIGTERM signal is sent to one of the processes, we set convergence to true. ---*/
if (STOP) convergence = true;

/*--- Apply the same convergence criteria to all processors. ---*/

unsigned short local = convergence, global = 0;

SU2_MPI::Allreduce(&local, &global, 1, MPI_UNSIGNED_SHORT, MPI_MAX, SU2_MPI::GetComm());
convergence = global > 0;

Expand Down
2 changes: 1 addition & 1 deletion SU2_CFD/src/python_wrapper_structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void CSinglezoneDriver::SetInitialMesh() {
DynamicMeshUpdate(0);

SU2_OMP_PARALLEL {
for (iMesh = 0u; iMesh <= main_config->GetnMGLevels(); iMesh++) {
for (auto iMesh = 0u; iMesh <= main_config->GetnMGLevels(); iMesh++) {
SU2_OMP_FOR_STAT(roundUpDiv(geometry_container[selected_zone][INST_0][iMesh]->GetnPoint(), omp_get_max_threads()))
for (auto iPoint = 0ul; iPoint < geometry_container[selected_zone][INST_0][iMesh]->GetnPoint(); iPoint++) {
/*--- Overwrite fictitious velocities. ---*/
Expand Down
3 changes: 2 additions & 1 deletion SU2_CFD/src/solvers/CEulerSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2541,7 +2541,7 @@ void CEulerSolver::GetPower_Properties(CGeometry *geometry, CConfig *config, uns
su2double Alpha = config->GetAoA()*PI_NUMBER/180.0;
su2double Beta = config->GetAoS()*PI_NUMBER/180.0;
bool write_heads = ((((config->GetInnerIter() % (config->GetScreen_Wrt_Freq(2)*40)) == 0) && (config->GetInnerIter()!= 0)) || (config->GetInnerIter() == 1));
bool Evaluate_BC = ((((config->GetInnerIter() % (config->GetScreen_Wrt_Freq(2)*40)) == 0)) || (config->GetInnerIter() == 1) || (config->GetDiscrete_Adjoint()));
bool Evaluate_BC = ((((config->GetInnerIter() % (config->GetBc_Eval_Freq())) == 0)) || (config->GetInnerIter() == 1) || (config->GetDiscrete_Adjoint()));

if ((config->GetnMarker_EngineInflow() != 0) || (config->GetnMarker_EngineExhaust() != 0)) Engine = true;
if ((config->GetnMarker_ActDiskInlet() != 0) || (config->GetnMarker_ActDiskOutlet() != 0)) Engine = false;
Expand Down Expand Up @@ -2930,6 +2930,7 @@ void CEulerSolver::GetPower_Properties(CGeometry *geometry, CConfig *config, uns
config->SetInflow_RamDrag(iMarker_Inlet, Inlet_RamDrag_Total[iMarker_Inlet]);
config->SetInflow_Force(iMarker_Inlet, Inlet_Force_Total[iMarker_Inlet]);
config->SetInflow_Power(iMarker_Inlet, Inlet_Power_Total[iMarker_Inlet]);
config->SetInflow_Mach(iMarker_Inlet, Inlet_Mach_Total[iMarker_Inlet]);
}
else {
config->SetActDiskInlet_MassFlow(iMarker_Inlet, Inlet_MassFlow_Total[iMarker_Inlet]);
Expand Down
1 change: 1 addition & 0 deletions TestCases/parallel_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,7 @@ def main():
sp_pinArray_3d_cht_mf_hf_tp.multizone = True
test_list.append(sp_pinArray_3d_cht_mf_hf_tp)


##########################
### Python wrapper ###
##########################
Expand Down
9 changes: 9 additions & 0 deletions TestCases/tutorials.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ def main():
cht_incompressible.multizone = True
test_list.append(cht_incompressible)

# Solid-to-solid and solid-to-fluid CHT with contact resistance
cht_CR = TestCase('cht_solid_solid')
cht_CR.cfg_dir = "../Tutorials/multiphysics/contact_resistance_cht"
cht_CR.cfg_file = "master.cfg"
cht_CR.test_iter = 80
cht_CR.test_vals = [ -8.857438, -9.377593, -10.097769, -2.122358]
cht_CR.multizone = True
test_list.append(cht_CR)

### Incompressible Flow

# 2D pin case massflow periodic with heatflux BC and prescribed extracted outlet heat
Expand Down
3 changes: 3 additions & 0 deletions config_template.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,9 @@ FAN_POLY_EFF= 1.0
% Only half engine is in the computational grid (NO, YES)
ENGINE_HALF_MODEL= NO
%
% Evaluation Frequency for Engine and Actuator Disk Markers
BC_EVAL_FREQ = 40
%
% Damping factor for the engine inflow.
DAMP_ENGINE_INFLOW= 0.95
%
Expand Down

0 comments on commit f81246c

Please sign in to comment.