Skip to content

Commit

Permalink
Merge branch 'develop' into feature_signal_handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bigfooted authored Jul 10, 2024
2 parents ef316f2 + bbdc457 commit 5da85c6
Show file tree
Hide file tree
Showing 25 changed files with 417 additions and 168 deletions.
8 changes: 4 additions & 4 deletions Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6841,7 +6841,7 @@ class CConfig {
* \param[in] val_index - Index corresponding to the inlet boundary.
* \return The total temperature.
*/
su2double GetInlet_Ttotal(const string& val_index) const;
su2double GetInletTtotal(const string& val_index) const;

/*!
* \brief Get the temperature at a supersonic inlet boundary.
Expand Down Expand Up @@ -6883,14 +6883,14 @@ class CConfig {
* \param[in] val_index - Index corresponding to the inlet boundary.
* \return The total pressure.
*/
su2double GetInlet_Ptotal(const string& val_index) const;
su2double GetInletPtotal(const string& val_index) const;

/*!
* \brief Set the total pressure at an inlet boundary.
* \param[in] val_pressure - Pressure value at the inlet boundary.
* \param[in] val_index - Index corresponding to the inlet boundary.
*/
void SetInlet_Ptotal(su2double val_pressure, const string& val_marker);
void SetInletPtotal(su2double val_pressure, const string& val_marker);

/*!
* \brief Get the species values at an inlet boundary
Expand Down Expand Up @@ -6930,7 +6930,7 @@ class CConfig {
* \param[in] val_index - Index corresponding to the inlet boundary.
* \return The flow direction vector.
*/
const su2double* GetInlet_FlowDir(const string& val_index) const;
const su2double* GetInletFlowDir(const string& val_index) const;

/*!
* \brief Get the back pressure (static) at an outlet boundary.
Expand Down
44 changes: 44 additions & 0 deletions Common/include/geometry/CGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1639,6 +1639,50 @@ class CGeometry {
CustomBoundaryHeatFlux[val_marker][val_vertex] = val_customBoundaryHeatFlux;
}

/*!
* \brief Set a representative wall value of the agglomerated control volumes on a particular boundary marker.
* \param[in] fine_grid - Geometrical definition of the problem.
* \param[in] val_marker - Index of the boundary marker.
* \param[in] wall_quantity - Object with methods Get(iVertex_fine) and Set(iVertex_coarse, val).
*/
template <class T>
void SetMultiGridMarkerQuantity(const CGeometry* fine_grid, unsigned short val_marker, T& wall_quantity) {
for (auto iVertex = 0ul; iVertex < nVertex[val_marker]; iVertex++) {
const auto Point_Coarse = vertex[val_marker][iVertex]->GetNode();

if (!nodes->GetDomain(Point_Coarse)) continue;

su2double Area_Parent = 0.0;

/*--- Compute area parent by taking into account only volumes that are on the marker. ---*/
for (auto iChildren = 0u; iChildren < nodes->GetnChildren_CV(Point_Coarse); iChildren++) {
const auto Point_Fine = nodes->GetChildren_CV(Point_Coarse, iChildren);
const auto isVertex =
fine_grid->nodes->GetDomain(Point_Fine) && (fine_grid->nodes->GetVertex(Point_Fine, val_marker) != -1);
if (isVertex) {
Area_Parent += fine_grid->nodes->GetVolume(Point_Fine);
}
}

su2double Quantity_Coarse = 0.0;

/*--- Loop again to average coarser value. ---*/
for (auto iChildren = 0u; iChildren < nodes->GetnChildren_CV(Point_Coarse); iChildren++) {
const auto Point_Fine = nodes->GetChildren_CV(Point_Coarse, iChildren);
const auto isVertex =
fine_grid->nodes->GetDomain(Point_Fine) && (fine_grid->nodes->GetVertex(Point_Fine, val_marker) != -1);
if (isVertex) {
const auto Vertex_Fine = fine_grid->nodes->GetVertex(Point_Fine, val_marker);
const auto Area_Children = fine_grid->nodes->GetVolume(Point_Fine);
Quantity_Coarse += wall_quantity.Get(Vertex_Fine) * Area_Children / Area_Parent;
}
}

/*--- Set the value at the coarse level. ---*/
wall_quantity.Set(iVertex, Quantity_Coarse);
}
}

/*!
* \brief Filter values given at the element CG by performing a weighted average over a radial neighbourhood.
* \param[in] filter_radius - Parameter defining the size of the neighbourhood.
Expand Down
44 changes: 0 additions & 44 deletions Common/include/geometry/CMultiGridGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,50 +66,6 @@ class CMultiGridGeometry final : public CGeometry {
void SetSuitableNeighbors(vector<unsigned long>& Suitable_Indirect_Neighbors, unsigned long iPoint,
unsigned long Index_CoarseCV, const CGeometry* fine_grid) const;

/*!
* \brief Set a representative wall value of the agglomerated control volumes on a particular boundary marker.
* \param[in] fine_grid - Geometrical definition of the problem.
* \param[in] val_marker - Index of the boundary marker.
* \param[in] wall_quantity - Object with methods Get(iVertex_fine) and Set(iVertex_coarse, val).
*/
template <class T>
void SetMultiGridWallQuantity(const CGeometry* fine_grid, unsigned short val_marker, T& wall_quantity) {
for (auto iVertex = 0ul; iVertex < nVertex[val_marker]; iVertex++) {
const auto Point_Coarse = vertex[val_marker][iVertex]->GetNode();

if (!nodes->GetDomain(Point_Coarse)) continue;

su2double Area_Parent = 0.0;

/*--- Compute area parent by taking into account only volumes that are on the marker. ---*/
for (auto iChildren = 0u; iChildren < nodes->GetnChildren_CV(Point_Coarse); iChildren++) {
const auto Point_Fine = nodes->GetChildren_CV(Point_Coarse, iChildren);
const auto isVertex =
fine_grid->nodes->GetDomain(Point_Fine) && (fine_grid->nodes->GetVertex(Point_Fine, val_marker) != -1);
if (isVertex) {
Area_Parent += fine_grid->nodes->GetVolume(Point_Fine);
}
}

su2double Quantity_Coarse = 0.0;

/*--- Loop again to average coarser value. ---*/
for (auto iChildren = 0u; iChildren < nodes->GetnChildren_CV(Point_Coarse); iChildren++) {
const auto Point_Fine = nodes->GetChildren_CV(Point_Coarse, iChildren);
const auto isVertex =
fine_grid->nodes->GetDomain(Point_Fine) && (fine_grid->nodes->GetVertex(Point_Fine, val_marker) != -1);
if (isVertex) {
const auto Vertex_Fine = fine_grid->nodes->GetVertex(Point_Fine, val_marker);
const auto Area_Children = fine_grid->nodes->GetVolume(Point_Fine);
Quantity_Coarse += wall_quantity.Get(Vertex_Fine) * Area_Children / Area_Parent;
}
}

/*--- Set the value at the coarse level. ---*/
wall_quantity.Set(iVertex, Quantity_Coarse);
}
}

public:
/*--- This is to suppress Woverloaded-virtual, omitting it has no negative impact. ---*/
using CGeometry::SetBoundControlVolume;
Expand Down
8 changes: 4 additions & 4 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8900,28 +8900,28 @@ INC_OUTLET_TYPE CConfig::GetKind_Inc_Outlet(const string& val_marker) const {
return Kind_Inc_Outlet[iMarker_Outlet];
}

su2double CConfig::GetInlet_Ttotal(const string& val_marker) const {
su2double CConfig::GetInletTtotal(const string& val_marker) const {
unsigned short iMarker_Inlet;
for (iMarker_Inlet = 0; iMarker_Inlet < nMarker_Inlet; iMarker_Inlet++)
if (Marker_Inlet[iMarker_Inlet] == val_marker) break;
return Inlet_Ttotal[iMarker_Inlet];
}

su2double CConfig::GetInlet_Ptotal(const string& val_marker) const {
su2double CConfig::GetInletPtotal(const string& val_marker) const {
unsigned short iMarker_Inlet;
for (iMarker_Inlet = 0; iMarker_Inlet < nMarker_Inlet; iMarker_Inlet++)
if (Marker_Inlet[iMarker_Inlet] == val_marker) break;
return Inlet_Ptotal[iMarker_Inlet];
}

void CConfig::SetInlet_Ptotal(su2double val_pressure, const string& val_marker) {
void CConfig::SetInletPtotal(su2double val_pressure, const string& val_marker) {
unsigned short iMarker_Inlet;
for (iMarker_Inlet = 0; iMarker_Inlet < nMarker_Inlet; iMarker_Inlet++)
if (Marker_Inlet[iMarker_Inlet] == val_marker)
Inlet_Ptotal[iMarker_Inlet] = val_pressure;
}

const su2double* CConfig::GetInlet_FlowDir(const string& val_marker) const {
const su2double* CConfig::GetInletFlowDir(const string& val_marker) const {
unsigned short iMarker_Inlet;
for (iMarker_Inlet = 0; iMarker_Inlet < nMarker_Inlet; iMarker_Inlet++)
if (Marker_Inlet[iMarker_Inlet] == val_marker) break;
Expand Down
32 changes: 14 additions & 18 deletions Common/src/geometry/CGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2386,24 +2386,20 @@ void CGeometry::SetCustomBoundary(CConfig* config) {
}

void CGeometry::UpdateCustomBoundaryConditions(CGeometry** geometry_container, CConfig* config) {
unsigned short iMGfine, iMGlevel, nMGlevel, iMarker;

nMGlevel = config->GetnMGLevels();
for (iMGlevel = 1; iMGlevel <= nMGlevel; iMGlevel++) {
iMGfine = iMGlevel - 1;
for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) {
if (config->GetMarker_All_PyCustom(iMarker)) {
switch (config->GetMarker_All_KindBC(iMarker)) {
case HEAT_FLUX:
geometry_container[iMGlevel]->SetMultiGridWallHeatFlux(geometry_container[iMGfine], iMarker);
break;
case ISOTHERMAL:
geometry_container[iMGlevel]->SetMultiGridWallTemperature(geometry_container[iMGfine], iMarker);
break;
// Inlet flow handled in solver class.
default:
break;
}
for (auto iMGlevel = 1u; iMGlevel <= config->GetnMGLevels(); iMGlevel++) {
const auto iMGfine = iMGlevel - 1;
for (auto iMarker = 0u; iMarker < config->GetnMarker_All(); iMarker++) {
if (!config->GetMarker_All_PyCustom(iMarker)) continue;
switch (config->GetMarker_All_KindBC(iMarker)) {
case HEAT_FLUX:
geometry_container[iMGlevel]->SetMultiGridWallHeatFlux(geometry_container[iMGfine], iMarker);
break;
case ISOTHERMAL:
geometry_container[iMGlevel]->SetMultiGridWallTemperature(geometry_container[iMGfine], iMarker);
break;
// Inlet flow handled in solver class.
default:
break;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Common/src/geometry/CMultiGridGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ void CMultiGridGeometry::SetMultiGridWallHeatFlux(const CGeometry* fine_grid, un
wall_heat_flux.marker = val_marker;
wall_heat_flux.target = CustomBoundaryHeatFlux[val_marker];

SetMultiGridWallQuantity(fine_grid, val_marker, wall_heat_flux);
SetMultiGridMarkerQuantity(fine_grid, val_marker, wall_heat_flux);
}

void CMultiGridGeometry::SetMultiGridWallTemperature(const CGeometry* fine_grid, unsigned short val_marker) {
Expand All @@ -990,7 +990,7 @@ void CMultiGridGeometry::SetMultiGridWallTemperature(const CGeometry* fine_grid,
wall_temperature.marker = val_marker;
wall_temperature.target = CustomBoundaryTemperature[val_marker];

SetMultiGridWallQuantity(fine_grid, val_marker, wall_temperature);
SetMultiGridMarkerQuantity(fine_grid, val_marker, wall_temperature);
}

void CMultiGridGeometry::SetRestricted_GridVelocity(const CGeometry* fine_grid) {
Expand Down
4 changes: 2 additions & 2 deletions SU2_CFD/include/drivers/CDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ class CDriver : public CDriverBase {
/*!
* \brief Set the direction of the inlet.
* \param[in] iMarker - Marker index.
* \param[in] alpha - Angle (Zpos).
* \param[in] alpha - Angle around z axis.
*/
void SetInletAngle(unsigned short iMarker, passivedouble alpha);

Expand Down Expand Up @@ -554,7 +554,7 @@ class CDriver : public CDriverBase {
* \param[in] vel_z - Value of velocity along z-axis.
*/
void SetMarkerTranslationRate(unsigned short iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z);

/// \}
};

Expand Down
33 changes: 33 additions & 0 deletions SU2_CFD/include/drivers/CDriverBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,39 @@ class CDriverBase {
}
}

/*!
* \brief Set the first variable in MARKER_INLET (usually temperature).
* \param[in] iMarker - Marker index.
* \param[in] iVertex - Marker vertex index.
* \param[in] value - Value of the variable.
*/
void SetMarkerCustomInletFlowVar0(unsigned short iMarker, unsigned long iVertex, passivedouble value) {
GetSolverAndCheckMarker(FLOW_SOL, iMarker)->SetInletTtotal(iMarker, iVertex, value);
}

/*!
* \brief Set the second variable in MARKER_INLET (usually total pressure).
* \param[in] iMarker - Marker index.
* \param[in] iVertex - Marker vertex index.
* \param[in] value - Value of the variable.
*/
void SetMarkerCustomInletFlowVar1(unsigned short iMarker, unsigned long iVertex, passivedouble value) {
GetSolverAndCheckMarker(FLOW_SOL, iMarker)->SetInletPtotal(iMarker, iVertex, value);
}

/*!
* \brief Set the flow direction vector (does not need to be a unit vector).
* \param[in] iMarker - Marker index.
* \param[in] iVertex - Marker vertex index.
* \param[in] values - Flow direction vector.
*/
void SetMarkerCustomInletFlowDirection(unsigned short iMarker, unsigned long iVertex, std::vector<passivedouble> values) {
auto* solver = GetSolverAndCheckMarker(FLOW_SOL, iMarker);
for (auto iDim = 0ul; iDim < GetNumberDimensions(); ++iDim) {
solver->SetInletFlowDir(iMarker, iVertex, iDim, values[iDim]);
}
}

/// \}

protected:
Expand Down
13 changes: 3 additions & 10 deletions SU2_CFD/include/solvers/CEulerSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1013,13 +1013,6 @@ class CEulerSolver : public CFVMFlowSolverBase<CEulerVariable, ENUM_REGIME::COMP
DonorGlobalIndex[val_marker][val_vertex] = val_index;
}

/*!
* \brief Update the multi-grid structure for the customized boundary conditions
* \param geometry_container - Geometrical definition.
* \param config - Definition of the particular problem.
*/
void UpdateCustomBoundaryConditions(CGeometry **geometry_container, CConfig *config) final;

/*!
* \brief Set the initial condition for the Euler Equations.
* \param[in] geometry - Geometrical definition of the problem.
Expand All @@ -1044,7 +1037,7 @@ class CEulerSolver : public CFVMFlowSolverBase<CEulerVariable, ENUM_REGIME::COMP
* \param[in] config - Definition of the particular problem.
*/
void InitTurboContainers(CGeometry *geometry, CConfig *config) final;

/*!
* \brief Get Primal variables for turbo performance computation
* iteration can be executed by multiple threads.
Expand All @@ -1062,15 +1055,15 @@ class CEulerSolver : public CFVMFlowSolverBase<CEulerVariable, ENUM_REGIME::COMP
TurboPrimitive.push_back(TurboVelocityIn[iBlade][iSpan][2]);
}
else {
TurboPrimitive.push_back(DensityOut[iBlade][iSpan]);
TurboPrimitive.push_back(DensityOut[iBlade][iSpan]);
TurboPrimitive.push_back(PressureOut[iBlade][iSpan]);
TurboPrimitive.push_back(TurboVelocityOut[iBlade][iSpan][0]);
TurboPrimitive.push_back(TurboVelocityOut[iBlade][iSpan][1]);
if (nDim==3)
TurboPrimitive.push_back(TurboVelocityOut[iBlade][iSpan][2]);
}
return TurboPrimitive;
}
}
/*!
* \brief Set the solution using the Freestream values.
* \param[in] config - Definition of the particular problem.
Expand Down
23 changes: 16 additions & 7 deletions SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2119,7 +2119,7 @@ class CFVMFlowSolverBase : public CSolver {
* \param[in] val_vertex - Vertex of the marker <i>val_marker</i> where the total temperature is evaluated.
* \return Value of the total temperature
*/
inline su2double GetInlet_Ttotal(unsigned short val_marker, unsigned long val_vertex) const final {
inline su2double GetInletTtotal(unsigned short val_marker, unsigned long val_vertex) const final {
return Inlet_Ttotal[val_marker][val_vertex];
}

Expand All @@ -2129,7 +2129,7 @@ class CFVMFlowSolverBase : public CSolver {
* \param[in] val_vertex - Vertex of the marker <i>val_marker</i> where the total pressure is evaluated.
* \return Value of the total pressure
*/
inline su2double GetInlet_Ptotal(unsigned short val_marker, unsigned long val_vertex) const final {
inline su2double GetInletPtotal(unsigned short val_marker, unsigned long val_vertex) const final {
return Inlet_Ptotal[val_marker][val_vertex];
}

Expand All @@ -2140,7 +2140,7 @@ class CFVMFlowSolverBase : public CSolver {
* \param[in] val_dim - The component of the flow direction unit vector to be evaluated
* \return Component of a unit vector representing the flow direction.
*/
inline su2double GetInlet_FlowDir(unsigned short val_marker, unsigned long val_vertex,
inline su2double GetInletFlowDir(unsigned short val_marker, unsigned long val_vertex,
unsigned short val_dim) const final {
return Inlet_FlowDir[val_marker][val_vertex][val_dim];
}
Expand All @@ -2151,7 +2151,7 @@ class CFVMFlowSolverBase : public CSolver {
* \param[in] val_vertex - Vertex of the marker <i>val_marker</i> where the total temperature is set.
* \param[in] val_ttotal - Value of the total temperature
*/
inline void SetInlet_Ttotal(unsigned short val_marker, unsigned long val_vertex, su2double val_ttotal) final {
inline void SetInletTtotal(unsigned short val_marker, unsigned long val_vertex, su2double val_ttotal) final {
/*--- Since this call can be accessed indirectly using python, do some error
* checking to prevent segmentation faults ---*/
if (val_marker >= nMarker)
Expand All @@ -2168,7 +2168,7 @@ class CFVMFlowSolverBase : public CSolver {
* \param[in] val_vertex - Vertex of the marker <i>val_marker</i> where the total pressure is set.
* \param[in] val_ptotal - Value of the total pressure
*/
inline void SetInlet_Ptotal(unsigned short val_marker, unsigned long val_vertex, su2double val_ptotal) final {
inline void SetInletPtotal(unsigned short val_marker, unsigned long val_vertex, su2double val_ptotal) final {
/*--- Since this call can be accessed indirectly using python, do some error
* checking to prevent segmentation faults ---*/
if (val_marker >= nMarker)
Expand All @@ -2186,8 +2186,8 @@ class CFVMFlowSolverBase : public CSolver {
* \param[in] val_dim - The component of the flow direction unit vector to be set
* \param[in] val_flowdir - Component of a unit vector representing the flow direction.
*/
inline void SetInlet_FlowDir(unsigned short val_marker, unsigned long val_vertex, unsigned short val_dim,
su2double val_flowdir) final {
inline void SetInletFlowDir(unsigned short val_marker, unsigned long val_vertex, unsigned short val_dim,
su2double val_flowdir) final {
/*--- Since this call can be accessed indirectly using python, do some error
* checking to prevent segmentation faults ---*/
if (val_marker >= nMarker)
Expand All @@ -2198,6 +2198,15 @@ class CFVMFlowSolverBase : public CSolver {
Inlet_FlowDir[val_marker][val_vertex][val_dim] = val_flowdir;
}

/*!
* \brief Update the multi-grid structure for the customized boundary conditions.
* \param geometry_container - Geometrical definition.
* \param solver_container - Solver definition.
* \param config - Definition of the particular problem.
*/
void UpdateCustomBoundaryConditions(CGeometry **geometry_container, CSolver ***solver_container,
CConfig *config) final;

/*!
* \brief Updates the components of the farfield velocity vector.
*/
Expand Down
Loading

0 comments on commit 5da85c6

Please sign in to comment.