Skip to content

Commit

Permalink
Merge branch 'develop' into feature_pysu2_DEF
Browse files Browse the repository at this point in the history
  • Loading branch information
aa-g authored Jun 22, 2021
2 parents bb2c030 + 350fee9 commit 29e4521
Show file tree
Hide file tree
Showing 165 changed files with 4,410 additions and 3,246 deletions.
55 changes: 35 additions & 20 deletions Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ class CConfig {

unsigned short nConfig_Files; /*!< \brief Number of config files for multiphysics problems. */
string *Config_Filenames; /*!< \brief List of names for configuration files. */
unsigned short *Kind_WallFunctions; /*!< \brief The kind of wall function to use for the corresponding markers. */
WALL_FUNCTIONS *Kind_WallFunctions; /*!< \brief The kind of wall function to use for the corresponding markers. */
unsigned short **IntInfo_WallFunctions; /*!< \brief Additional integer information for the wall function markers. */
su2double **DoubleInfo_WallFunctions; /*!< \brief Additional double information for the wall function markers. */
unsigned short *Marker_All_Monitoring, /*!< \brief Global index for monitoring using the grid information. */
Expand Down Expand Up @@ -816,21 +816,23 @@ class CConfig {
Turb2LamViscRatio_FreeStream, /*!< \brief Ratio of turbulent to laminar viscosity. */
NuFactor_FreeStream, /*!< \brief Ratio of turbulent to laminar viscosity. */
NuFactor_Engine, /*!< \brief Ratio of turbulent to laminar viscosity at the engine. */
SecondaryFlow_ActDisk, /*!< \brief Ratio of turbulent to laminar viscosity at the actuator disk. */
Initial_BCThrust, /*!< \brief Ratio of turbulent to laminar viscosity at the actuator disk. */
Pressure_FreeStream, /*!< \brief Total pressure of the fluid. */
Pressure_Thermodynamic, /*!< \brief Thermodynamic pressure of the fluid. */
Temperature_FreeStream, /*!< \brief Total temperature of the fluid. */
Temperature_ve_FreeStream; /*!< \brief Total vibrational-electronic temperature of the fluid. */
su2double Prandtl_Lam, /*!< \brief Laminar Prandtl number for the gas. */
Prandtl_Turb, /*!< \brief Turbulent Prandtl number for the gas. */
Length_Ref, /*!< \brief Reference length for non-dimensionalization. */
Pressure_Ref, /*!< \brief Reference pressure for non-dimensionalization. */
Temperature_Ref, /*!< \brief Reference temperature for non-dimensionalization.*/
Temperature_ve_Ref, /*!< \brief Reference vibrational-electronic temperature for non-dimensionalization.*/
Density_Ref, /*!< \brief Reference density for non-dimensionalization.*/
Velocity_Ref, /*!< \brief Reference velocity for non-dimensionalization.*/
Time_Ref, /*!< \brief Reference time for non-dimensionalization. */
SecondaryFlow_ActDisk, /*!< \brief Ratio of turbulent to laminar viscosity at the actuator disk. */
Initial_BCThrust, /*!< \brief Ratio of turbulent to laminar viscosity at the actuator disk. */
Pressure_FreeStream, /*!< \brief Total pressure of the fluid. */
Pressure_Thermodynamic, /*!< \brief Thermodynamic pressure of the fluid. */
Temperature_FreeStream, /*!< \brief Total temperature of the fluid. */
Temperature_ve_FreeStream; /*!< \brief Total vibrational-electronic temperature of the fluid. */
su2double Prandtl_Lam, /*!< \brief Laminar Prandtl number for the gas. */
Prandtl_Turb, /*!< \brief Turbulent Prandtl number for the gas. */
wallModelKappa, /*!< \brief von Karman constant kappa for turbulence wall modeling */
wallModelB, /*!< \brief constant B for turbulence wall modeling */
Length_Ref, /*!< \brief Reference length for non-dimensionalization. */
Pressure_Ref, /*!< \brief Reference pressure for non-dimensionalization. */
Temperature_Ref, /*!< \brief Reference temperature for non-dimensionalization.*/
Temperature_ve_Ref, /*!< \brief Reference vibrational-electronic temperature for non-dimensionalization.*/
Density_Ref, /*!< \brief Reference density for non-dimensionalization.*/
Velocity_Ref, /*!< \brief Reference velocity for non-dimensionalization.*/
Time_Ref, /*!< \brief Reference time for non-dimensionalization. */
Viscosity_Ref, /*!< \brief Reference viscosity for non-dimensionalization. */
Conductivity_Ref, /*!< \brief Reference conductivity for non-dimensionalization. */
Energy_Ref, /*!< \brief Reference viscosity for non-dimensionalization. */
Expand Down Expand Up @@ -1255,7 +1257,7 @@ class CConfig {
su2double** & ActDisk_PressJump, su2double** & ActDisk_TempJump, su2double** & ActDisk_Omega);

void addWallFunctionOption(const string &name, unsigned short &list_size,
string* &string_field, unsigned short* &val_Kind_WF,
string* &string_field, WALL_FUNCTIONS* &val_Kind_WF,
unsigned short** &val_IntInfo_WF, su2double** &val_DoubleInfo_WF);

void addPythonOption(const string name);
Expand Down Expand Up @@ -1664,6 +1666,18 @@ class CConfig {
*/
su2double GetPrandtl_Turb(void) const { return Prandtl_Turb; }

/*!
* \brief Get the value of the von Karman constant kappa for turbulence wall modeling.
* \return von Karman constant.
*/
su2double GetwallModelKappa(void) const { return wallModelKappa; }

/*!
* \brief Get the value of the von Karman constant kappa for turbulence wall modeling.
* \return von Karman constant.
*/
su2double GetwallModelB(void) const { return wallModelB; }

/*!
* \brief Get the value of the thermal conductivity for solids.
* \return Thermal conductivity (solid).
Expand Down Expand Up @@ -5235,7 +5249,7 @@ class CConfig {
* \param[in] ext - the extension to be added.
* \return The new filename
*/
string GetFilename(string filename, string ext, unsigned long Iter) const;
string GetFilename(string filename, string ext, int Iter) const;

/*!
* \brief Append the zone index to the restart or the solution files.
Expand Down Expand Up @@ -5444,7 +5458,8 @@ class CConfig {
* \param[in] val_val - Value of the design variable that we want to read.
* \return Design variable step.
*/
su2double GetDV_Value(unsigned short val_dv, unsigned short val_val = 0) const { return DV_Value[val_dv][val_val]; }
su2double& GetDV_Value(unsigned short val_dv, unsigned short val_val = 0) { return DV_Value[val_dv][val_val]; }
const su2double& GetDV_Value(unsigned short val_dv, unsigned short val_val = 0) const { return DV_Value[val_dv][val_val]; }

/*!
* \brief Set the value of the design variable step, we use this value in design problems.
Expand Down Expand Up @@ -6617,7 +6632,7 @@ class CConfig {
* \param[in] val_marker - String of the viscous wall marker.
* \return The type of wall function treatment.
*/
unsigned short GetWallFunction_Treatment(string val_marker) const;
WALL_FUNCTIONS GetWallFunction_Treatment(string val_marker) const;

/*!
* \brief Get the additional integer info for the wall function treatment
Expand Down
32 changes: 3 additions & 29 deletions Common/include/basic_types/ad_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,6 @@ namespace AD{

extern ExtFuncHelper* FuncHelper;

/*--- Stores the indices of the input variables (they might be overwritten) ---*/

extern std::vector<su2double::GradientData> inputValues;

/*--- Current position inside the adjoint vector ---*/

extern int adjointVectorPosition;

extern bool Status;

extern bool PreaccActive;
Expand All @@ -297,28 +289,17 @@ namespace AD{

extern std::vector<TapePosition> TapePositions;

extern std::vector<su2double::GradientData> localInputValues;

extern std::vector<su2double*> localOutputValues;

extern codi::PreaccumulationHelper<su2double> PreaccHelper;

/*--- Reference to the tape. ---*/

FORCEINLINE su2double::TapeType& getGlobalTape() {
return su2double::getGlobalTape();
}
FORCEINLINE su2double::TapeType& getGlobalTape() {return su2double::getGlobalTape();}

FORCEINLINE void RegisterInput(su2double &data, bool push_index = true) {
AD::getGlobalTape().registerInput(data);
if (push_index) {
inputValues.push_back(data.getGradientData());
}
}
FORCEINLINE void RegisterInput(su2double &data) {AD::getGlobalTape().registerInput(data);}

FORCEINLINE void RegisterOutput(su2double& data) {AD::getGlobalTape().registerOutput(data);}

FORCEINLINE void ResetInput(su2double &data) {data.getGradientData() = su2double::GradientData();}
FORCEINLINE void ResetInput(su2double &data) {data = data.getValue();}

FORCEINLINE void StartRecording() {AD::getGlobalTape().setActive();}

Expand All @@ -335,7 +316,6 @@ namespace AD{
opdi::logic->prepareEvaluate();
#endif
AD::getGlobalTape().evaluate();
adjointVectorPosition = 0;
}

FORCEINLINE void ComputeAdjoint(unsigned short enter, unsigned short leave) {
Expand All @@ -346,19 +326,13 @@ namespace AD{
#else
AD::getGlobalTape().evaluate(TapePositions[enter], TapePositions[leave]);
#endif
if (leave == 0)
adjointVectorPosition = 0;
}

FORCEINLINE void Reset() {
AD::getGlobalTape().reset();
#if defined(HAVE_OPDI)
opdi::logic->reset();
#endif
if (inputValues.size() != 0) {
adjointVectorPosition = 0;
inputValues.clear();
}
if (TapePositions.size() != 0) {
#if defined(HAVE_OPDI)
for (TapePosition& pos : TapePositions) {
Expand Down
10 changes: 0 additions & 10 deletions Common/include/basic_types/datatype_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,9 @@ namespace SU2_TYPE {

FORCEINLINE void SetDerivative(su2double& data, const passivedouble &val) {data.setGradient(val);}

#ifdef CODI_REVERSE_TYPE
FORCEINLINE passivedouble GetSecondary(const su2double& data) {
return AD::getGlobalTape().getGradient(AD::inputValues[AD::adjointVectorPosition++]);
}

FORCEINLINE passivedouble GetDerivative(const su2double& data) {
return AD::getGlobalTape().getGradient(AD::inputValues[AD::adjointVectorPosition++]);
}
#else // forward
FORCEINLINE passivedouble GetSecondary(const su2double& data) {return data.getGradient();}

FORCEINLINE passivedouble GetDerivative(const su2double& data) {return data.getGradient();}
#endif

#else // passive type, no AD

Expand Down
13 changes: 12 additions & 1 deletion Common/include/code_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
template<bool condition>
using su2enable_if = typename std::enable_if<condition,bool>::type;

/*--- Compile-time type selection. ---*/
template<bool B, class T, class F> struct su2conditional { using type = T; };
template<class T, class F> struct su2conditional<false, T, F> { using type = F; };

template<bool B, class T, class F>
using su2conditional_t = typename su2conditional<B,T,F>::type;

/*--- Detect compilation with OpenMP. ---*/
#if defined(_OPENMP)
#define HAVE_OMP
Expand Down Expand Up @@ -103,7 +110,7 @@ using su2double = codi::RealForward;
using su2double = double;
#endif

/*--- This type can be used for (rare) compatiblity cases or for
/*--- This type can be used for (rare) compatibility cases or for
* computations that are intended to be (always) passive. ---*/
using passivedouble = double;

Expand All @@ -116,9 +123,13 @@ using su2mixedfloat = passivedouble;

/*--- Detect if OpDiLib has to be used. ---*/
#if defined(HAVE_OMP) && defined(CODI_REVERSE_TYPE)
#ifndef __INTEL_COMPILER
#define HAVE_OPDI
#else
#warning Hybrid parallel reverse mode AD cannot be used with Intel compilers.
#endif

#if (_OPENMP >= 201811 && !defined(FORCE_OPDI_MACRO_BACKEND)) || defined(FORCE_OPDI_OMPT_BACKEND)
#define HAVE_OMPT
#endif
#endif
11 changes: 7 additions & 4 deletions Common/include/fem/fem_geometry_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1227,11 +1227,14 @@ class CMeshFEM_DG: public CMeshFEM {
void SetWallDistance(su2double val) override;

/*!
* \brief Set the wall distance based on an previously constructed ADT
* \param[in] config - Definition of the particular problem.
* \param[in] WallADT - The ADT to compute the wall distance
* \brief Reduce the wall distance based on an previously constructed ADT.
* \details The ADT might belong to another zone, giving rise to lower wall distances
* than those already stored.
* \param[in] WallADT - The ADT to reduce the wall distance
* \param[in] config - Config of this geometry (not the ADT zone's geometry)
* \param[in] iZone - ignored
*/
void SetWallDistance(const CConfig *config, CADTElemClass* WallADT) override;
void SetWallDistance(CADTElemClass* WallADT, const CConfig* config, unsigned short iZone) override;
};

/*!
Expand Down
22 changes: 12 additions & 10 deletions Common/include/geometry/CGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1234,14 +1234,14 @@ class CGeometry {
* \brief Ray Intersects Triangle (Moller and Trumbore algorithm)
*/
bool RayIntersectsTriangle(const su2double orig[3], const su2double dir[3],
const su2double vert0[3], const su2double vert1[3], const su2double vert2[3],
su2double *intersect);
const su2double vert0[3], const su2double vert1[3], const su2double vert2[3],
su2double *intersect);

/*!
* \brief Segment Intersects Triangle
*/
bool SegmentIntersectsTriangle(su2double point0[3], const su2double point1[3],
su2double vert0[3], su2double vert1[3], su2double vert2[3]);
su2double vert0[3], su2double vert1[3], su2double vert2[3]);

/*!
* \brief Segment Intersects Line (for 2D FFD Intersection)
Expand All @@ -1250,16 +1250,15 @@ class CGeometry {

/*!
* \brief Register the coordinates of the mesh nodes.
* \param[in] config
*/
void RegisterCoordinates(const CConfig *config) const;
void RegisterCoordinates() const;

/*!
* \brief Update the multi-grid structure and the wall-distance.
* \param geometry_container - Geometrical definition.
* \param config - Config
*/
void UpdateGeometry(CGeometry **geometry_container, CConfig *config);
static void UpdateGeometry(CGeometry **geometry_container, CConfig *config);

/*!
* \brief Update the multi-grid structure for the customized boundary conditions
Expand Down Expand Up @@ -1683,11 +1682,14 @@ class CGeometry {
virtual std::unique_ptr<CADTElemClass> ComputeViscousWallADT(const CConfig *config) const { return nullptr; }

/*!
* \brief Set the wall distance based on an previously constructed ADT
* \param[in] config - Definition of the particular problem.
* \param[in] WallADT - The ADT to compute the wall distance
* \brief Reduce the wall distance based on an previously constructed ADT.
* \details The ADT might belong to another zone, giving rise to lower wall distances
* than those already stored.
* \param[in] WallADT - The ADT to reduce the wall distance
* \param[in] config - Config of this geometry (not the ADT zone's geometry)
* \param[in] iZone - Zone whose markers made the ADT
*/
virtual void SetWallDistance(const CConfig *config, CADTElemClass* WallADT) {}
virtual void SetWallDistance(CADTElemClass* WallADT, const CConfig* config, unsigned short iZone = numeric_limits<unsigned short>::max()) {}

/*!
* \brief Set wall distances a specific value
Expand Down
18 changes: 7 additions & 11 deletions Common/include/geometry/CPhysicalGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ class CPhysicalGeometry final : public CGeometry {
unsigned long *Elem_ID_BoundTria_Linear{nullptr};
unsigned long *Elem_ID_BoundQuad_Linear{nullptr};

vector<int> GlobalMarkerStorageDispl;
vector<su2double> GlobalRoughness_Height;

su2double Streamwise_Periodic_RefNode[MAXNDIM] = {0}; /*!< \brief Coordinates of the reference node [m] on the receiving periodic marker, for recovered pressure/temperature computation only.*/

public:
Expand Down Expand Up @@ -767,10 +764,14 @@ class CPhysicalGeometry final : public CGeometry {
std::unique_ptr<CADTElemClass> ComputeViscousWallADT(const CConfig *config) const override;

/*!
* \brief Set the wall distance based on an previously constructed ADT
* \param[in] WallADT - The ADT to compute the wall distance
* \brief Reduce the wall distance based on an previously constructed ADT.
* \details The ADT might belong to another zone, giving rise to lower wall distances
* than those already stored.
* \param[in] WallADT - The ADT to reduce the wall distance
* \param[in] config - ignored
* \param[in] iZone - zone whose markers made the ADT
*/
void SetWallDistance(const CConfig *config, CADTElemClass* WallADT) override;
void SetWallDistance(CADTElemClass* WallADT, const CConfig* config, unsigned short iZone) override;

/*!
* \brief Set wall distances a specific value
Expand All @@ -781,11 +782,6 @@ class CPhysicalGeometry final : public CGeometry {
}
}

/*!
* \brief Set roughness values for markers in a global array.
*/
void SetGlobalMarkerRoughness(const CConfig* config);

/*!
* \brief For streamwise periodicity, find & store a unique reference node on the designated periodic inlet.
* \param[in] config - Definition of the particular problem.
Expand Down
Loading

0 comments on commit 29e4521

Please sign in to comment.