Skip to content

Commit f58d73e

Browse files
authored
Merge branch 'develop' into develop
2 parents b83b4bb + 8b95cd7 commit f58d73e

29 files changed

Lines changed: 641 additions & 625 deletions

Common/include/CConfig.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8658,7 +8658,6 @@ class CConfig {
86588658
unsigned short GetKind_Average(void) const { return Kind_Average; }
86598659

86608660
/*!
8661-
*
86628661
* \brief Get the direct differentation method.
86638662
* \return direct differentiation method.
86648663
*/

SU2_CFD/include/drivers/CDriverBase.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,25 @@ class CDriverBase {
473473
"MarkerSolutionTimeN of " + solver->GetSolverName(), false);
474474
}
475475

476+
/*!
477+
* \brief Get a read/write view of the solution at time N-1 on all mesh nodes of a solver.
478+
*/
479+
inline CPyWrapperMatrixView SolutionTimeN1(unsigned short iSolver) {
480+
auto* solver = GetSolverAndCheckMarker(iSolver);
481+
return CPyWrapperMatrixView(
482+
solver->GetNodes()->GetSolution_time_n1(), "SolutionTimeN1 of " + solver->GetSolverName(), false);
483+
}
484+
485+
/*!
486+
* \brief Get a read/write view of the solution at time N-1 on the mesh nodes of a marker.
487+
*/
488+
inline CPyWrapperMarkerMatrixView MarkerSolutionTimeN1(unsigned short iSolver, unsigned short iMarker) {
489+
auto* solver = GetSolverAndCheckMarker(iSolver, iMarker);
490+
return CPyWrapperMarkerMatrixView(
491+
solver->GetNodes()->GetSolution_time_n1(), main_geometry->vertex[iMarker], main_geometry->GetnVertex(iMarker),
492+
"MarkerSolutionTimeN1 of " + solver->GetSolverName(), false);
493+
}
494+
476495
/*!
477496
* \brief Get the flow solver primitive variable names with their associated indices.
478497
* These correspond to the column indices in the matrix returned by Primitives.

SU2_CFD/include/fluid/CCoolProp.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class CCoolProp final : public CFluidModel {
4848
su2double Temperature_Critical{0.0}; /*!< \brief critical temperature */
4949
su2double acentric_factor{0.0}; /*!< \brief acentric factor */
5050
const su2double dp{0.01}; /*!< threshold for pressure */
51+
const su2double dt{0.01}; /*!< threshold for temperature */
5152
#ifdef USE_COOLPROP
5253
std::unique_ptr<CoolProp::AbstractState> fluid_entity; /*!< \brief fluid entity */
5354
#endif
@@ -62,6 +63,18 @@ class CCoolProp final : public CFluidModel {
6263
Pressure = fmin(Pressure, (1 - dp) * Pressure_Critical);
6364
}
6465

66+
/*!
67+
* \brief Avoid critical temperature
68+
* \param[in,out] Temperature: Modified so that it is not too close to critical temperature to avoid issues in
69+
* CoolProp.
70+
*/
71+
void CheckTemperature(su2double& Temperature) const {
72+
if (Temperature > Temperature_Critical)
73+
Temperature = fmax(Temperature, (1 + dt) * Temperature_Critical);
74+
else
75+
Temperature = fmin(Temperature, (1 + dt) * Temperature_Critical);
76+
}
77+
6578
public:
6679
/*!
6780
* \brief Constructor of the class.
@@ -155,4 +168,4 @@ class CCoolProp final : public CFluidModel {
155168
* \return Value of the constant: Gamma
156169
*/
157170
su2double GetGamma(void) const { return Gamma; }
158-
};
171+
};

SU2_CFD/include/output/CFlowOutput.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ class CFlowOutput : public CFVMOutput{
215215
* \brief Helper for custom outputs, converts variable names to indices and pointers which are then used
216216
* to evaluate the custom expressions.
217217
*/
218-
void ConvertVariableSymbolsToIndices(const CPrimitiveIndices<unsigned long>& idx, CustomOutput& output) const;
218+
void ConvertVariableSymbolsToIndices(const CPrimitiveIndices<unsigned long>& idx, bool allowSkip,
219+
CustomOutput& output) const;
219220

220221
/*!
221222
* \brief Compute value of the Q criteration for vortex idenfitication
@@ -296,7 +297,7 @@ class CFlowOutput : public CFVMOutput{
296297
* \param[in] force_writing - boolean that forces writing of volume output
297298
* \param[in] iFile - index to the file that we need to consider for volume output
298299
*/
299-
bool WriteVolumeOutput(CConfig *config, unsigned long Iter, bool force_writing, unsigned short iFile) override;
300+
bool WriteVolumeOutput(CConfig *config, unsigned long Iter, bool force_writing, unsigned short iFile) override;
300301
/*!
301302
* \brief Write the forces breakdown file
302303
* \param[in] config - Definition of the particular problem per zone.

SU2_CFD/include/output/COutput.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ class COutput {
223223
We store pointers to the required outputs to speed-up access. ---*/
224224
std::vector<const su2double*> otherOutputs;
225225

226+
/*--- For discrete adjoint we may need to skip some expressions because there is one output class
227+
for the primal solver and one for the discrete adjoint (each with different variables). ---*/
228+
bool skip = false;
229+
226230
/*--- For evaluation, "vars" is a functor (i.e. has operator()) that returns the value of a variable at a given
227231
point. For example, it can be a wrapper to the primitives pointer, in which case varIndices needs to be setup
228232
with primitive indices. ---*/
@@ -807,6 +811,14 @@ class COutput {
807811
*/
808812
void SetCustomOutputs(const CConfig *config);
809813

814+
/*!
815+
* \brief Evaluates function-type custom outputs.
816+
* Derived classes can use this to compute simple expressions of other outputs if they
817+
* do not implement surface averages. This should be called just before evaluating the
818+
* custom objective function.
819+
*/
820+
void ComputeSimpleCustomOutputs(const CConfig *config);
821+
810822
/*!
811823
* \brief Load values of the history fields common for all solvers.
812824
* \param[in] config - Definition of the particular problem.

SU2_CFD/include/variables/CVariable.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ class CVariable {
500500
* \return Pointer to the solution (at time n-1) vector.
501501
*/
502502
inline su2double *GetSolution_time_n1(unsigned long iPoint) { return Solution_time_n1[iPoint]; }
503+
inline MatrixType& GetSolution_time_n1() { return Solution_time_n1; }
503504

504505
/*!
505506
* \brief Set the value of the old residual.

SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ CDiscAdjSinglezoneDriver::~CDiscAdjSinglezoneDriver() {
129129

130130
void CDiscAdjSinglezoneDriver::Preprocess(unsigned long TimeIter) {
131131

132+
/*--- Set the current time iteration in the config and also in the driver
133+
* because the python interface doesn't offer an explicit way of doing it. ---*/
134+
135+
this->TimeIter = TimeIter;
132136
config_container[ZONE_0]->SetTimeIter(TimeIter);
133137

134138
/*--- Preprocess the adjoint iteration ---*/

SU2_CFD/src/drivers/CSinglezoneDriver.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ void CSinglezoneDriver::StartSolver() {
110110

111111
void CSinglezoneDriver::Preprocess(unsigned long TimeIter) {
112112

113-
/*--- Set the current time iteration in the config ---*/
113+
/*--- Set the current time iteration in the config and also in the driver
114+
* because the python interface doesn't offer an explicit way of doing it. ---*/
114115

116+
this->TimeIter = TimeIter;
115117
config_container[ZONE_0]->SetTimeIter(TimeIter);
116118

117119
/*--- Store the current physical time in the config container, as

SU2_CFD/src/fluid/CCoolProp.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,20 @@ void CCoolProp::SetTDState_rhoe(su2double rho, su2double e) {
5656
dTdrho_e = fluid_entity->first_partial_deriv(CoolProp::iT, CoolProp::iDmass, CoolProp::iUmass);
5757
dTde_rho = fluid_entity->first_partial_deriv(CoolProp::iT, CoolProp::iUmass, CoolProp::iDmass);
5858
if (fluid_entity->phase() == CoolProp::iphase_twophase) {
59-
// assume it is pure gas
60-
fluid_entity->specify_phase(CoolProp::iphase_gas);
59+
// impose gas phase
60+
Temperature = Temperature + 0.1;
6161
CheckPressure(Pressure);
62+
CheckTemperature(Temperature);
6263
fluid_entity->update(CoolProp::PT_INPUTS, Pressure, Temperature);
63-
if (abs(fluid_entity->rhomass() / Density - 1) < dp) {
64-
// origial phase is near saturation gas, then just compute sound speed
65-
SoundSpeed2 = pow(fluid_entity->speed_sound(), 2);
66-
} else {
67-
// original phase is not near saturation gas, then specify the phase as gas phase
68-
fluid_entity->specify_phase(CoolProp::iphase_gas);
69-
SetTDState_PT(Pressure, Temperature);
70-
}
64+
SoundSpeed2 = pow(fluid_entity->speed_sound(), 2);
7165
} else {
7266
SoundSpeed2 = pow(fluid_entity->speed_sound(), 2);
7367
}
7468
}
7569

7670
void CCoolProp::SetTDState_PT(su2double P, su2double T) {
7771
CheckPressure(P);
72+
CheckTemperature(T);
7873
fluid_entity->update(CoolProp::PT_INPUTS, P, T);
7974
su2double rho = fluid_entity->rhomass();
8075
su2double e = fluid_entity->umass();
@@ -130,4 +125,4 @@ CCoolProp::CCoolProp(const string& fluidname) {
130125
"or autodiff",
131126
CURRENT_FUNCTION);
132127
}
133-
#endif
128+
#endif

0 commit comments

Comments
 (0)