Skip to content

Commit 737df10

Browse files
committed
cleanup SetMultiGridWall** functions
1 parent d980f8c commit 737df10

3 files changed

Lines changed: 75 additions & 84 deletions

File tree

Common/include/geometry/CGeometry.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,14 +815,14 @@ class CGeometry {
815815
* \param[in] geometry - Geometrical definition of the problem.
816816
* \param[in] val_marker - Index of the boundary marker.
817817
*/
818-
inline virtual void SetMultiGridWallHeatFlux(CGeometry *geometry, unsigned short val_marker) {}
818+
inline virtual void SetMultiGridWallHeatFlux(const CGeometry *geometry, unsigned short val_marker) {}
819819

820820
/*!
821821
* \brief A virtual member.
822822
* \param[in] geometry - Geometrical definition of the problem.
823823
* \param[in] val_marker - Index of the boundary marker.
824824
*/
825-
inline virtual void SetMultiGridWallTemperature(CGeometry *geometry, unsigned short val_marker) {}
825+
inline virtual void SetMultiGridWallTemperature(const CGeometry *geometry, unsigned short val_marker) {}
826826

827827
/*!
828828
* \brief A virtual member.

Common/include/geometry/CMultiGridGeometry.hpp

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,51 @@
3737
*/
3838
class CMultiGridGeometry final : public CGeometry {
3939

40+
/*!
41+
* \brief Set a representative wall value of the agglomerated control volumes on a particular boundary marker.
42+
* \param[in] geometry - Geometrical definition of the problem.
43+
* \param[in] val_marker - Index of the boundary marker.
44+
* \param[in] wall_quantity - Object with methods Get(iVertex_fine) and Set(iVertex_coarse, val).
45+
*/
46+
template <class T>
47+
void SetMultiGridWallQuantity(const CGeometry *geometry, unsigned short val_marker, T& wall_quantity) {
48+
49+
for (auto iVertex = 0ul; iVertex < nVertex[val_marker]; iVertex++) {
50+
const auto Point_Coarse = vertex[val_marker][iVertex]->GetNode();
51+
52+
if (!nodes->GetDomain(Point_Coarse)) continue;
53+
54+
su2double Area_Parent = 0.0;
55+
56+
/*--- Compute area parent by taking into account only volumes that are on the marker. ---*/
57+
for (auto iChildren = 0u; iChildren < nodes->GetnChildren_CV(Point_Coarse); iChildren++) {
58+
const auto Point_Fine = nodes->GetChildren_CV(Point_Coarse, iChildren);
59+
const auto isVertex = geometry->nodes->GetDomain(Point_Fine) &&
60+
(geometry->nodes->GetVertex(Point_Fine, val_marker) != -1);
61+
if (isVertex) {
62+
Area_Parent += geometry->nodes->GetVolume(Point_Fine);
63+
}
64+
}
65+
66+
su2double Quantity_Coarse = 0.0;
67+
68+
/*--- Loop again to average coarser value. ---*/
69+
for (auto iChildren = 0u; iChildren < nodes->GetnChildren_CV(Point_Coarse); iChildren++) {
70+
const auto Point_Fine = nodes->GetChildren_CV(Point_Coarse, iChildren);
71+
const auto isVertex = geometry->nodes->GetDomain(Point_Fine) &&
72+
(geometry->nodes->GetVertex(Point_Fine, val_marker) != -1);
73+
if (isVertex) {
74+
const auto Vertex_Fine = geometry->nodes->GetVertex(Point_Fine, val_marker);
75+
const auto Area_Children = geometry->nodes->GetVolume(Point_Fine);
76+
Quantity_Coarse += wall_quantity.Get(Vertex_Fine) * Area_Children / Area_Parent;
77+
}
78+
}
79+
80+
/*--- Set the value at the coarse level. ---*/
81+
wall_quantity.Set(iVertex, Quantity_Coarse);
82+
}
83+
}
84+
4085
public:
4186
/*--- This is to suppress Woverloaded-virtual, omitting it has no negative impact. ---*/
4287
using CGeometry::SetVertex;
@@ -134,14 +179,14 @@ class CMultiGridGeometry final : public CGeometry {
134179
* \param[in] geometry - Geometrical definition of the problem.
135180
* \param[in] val_marker - Index of the boundary marker.
136181
*/
137-
void SetMultiGridWallHeatFlux(CGeometry *geometry, unsigned short val_marker) override;
182+
void SetMultiGridWallHeatFlux(const CGeometry *geometry, unsigned short val_marker) override;
138183

139184
/*!
140185
* \brief Set a representative wall temperature of the agglomerated control volume on a particular boundary marker.
141186
* \param[in] geometry - Geometrical definition of the problem.
142187
* \param[in] val_marker - Index of the boundary marker.
143188
*/
144-
void SetMultiGridWallTemperature(CGeometry *geometry, unsigned short val_marker) override;
189+
void SetMultiGridWallTemperature(const CGeometry *geometry, unsigned short val_marker) override;
145190

146191
/*!
147192
* \brief Set the grid velocity at each node in the coarse mesh level based

Common/src/geometry/CMultiGridGeometry.cpp

Lines changed: 26 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,96 +1055,42 @@ void CMultiGridGeometry::SetCoord(CGeometry *geometry) {
10551055
END_SU2_OMP_FOR
10561056
}
10571057

1058-
void CMultiGridGeometry::SetMultiGridWallHeatFlux(CGeometry *geometry, unsigned short val_marker){
1058+
void CMultiGridGeometry::SetMultiGridWallHeatFlux(const CGeometry *geometry, unsigned short val_marker) {
10591059

1060-
unsigned long Point_Fine, Point_Coarse, iVertex;
1061-
unsigned short iChildren;
1062-
long Vertex_Fine;
1063-
su2double Area_Parent, Area_Children;
1064-
su2double WallHeatFlux_Fine, WallHeatFlux_Coarse;
1065-
bool isVertex;
1066-
int numberVertexChildren;
1067-
1068-
for(iVertex=0; iVertex < nVertex[val_marker]; iVertex++){
1069-
Point_Coarse = vertex[val_marker][iVertex]->GetNode();
1070-
if (nodes->GetDomain(Point_Coarse)){
1071-
Area_Parent = 0.0;
1072-
WallHeatFlux_Coarse = 0.0;
1073-
numberVertexChildren = 0;
1074-
/*--- Compute area parent by taking into account only volumes that are on the marker ---*/
1075-
for(iChildren=0; iChildren < nodes->GetnChildren_CV(Point_Coarse); iChildren++){
1076-
Point_Fine = nodes->GetChildren_CV(Point_Coarse, iChildren);
1077-
isVertex = (nodes->GetDomain(Point_Fine) && geometry->nodes->GetVertex(Point_Fine, val_marker) != -1);
1078-
if (isVertex){
1079-
numberVertexChildren += 1;
1080-
Area_Parent += geometry->nodes->GetVolume(Point_Fine);
1081-
}
1082-
}
1060+
struct {
1061+
const CGeometry* fine_grid;
1062+
unsigned short marker;
1063+
su2double* target;
10831064

1084-
/*--- Loop again and propagate values to the coarser level ---*/
1085-
for(iChildren=0; iChildren < nodes->GetnChildren_CV(Point_Coarse); iChildren++){
1086-
Point_Fine = nodes->GetChildren_CV(Point_Coarse, iChildren);
1087-
Vertex_Fine = geometry->nodes->GetVertex(Point_Fine, val_marker);
1088-
isVertex = (nodes->GetDomain(Point_Fine) && Vertex_Fine != -1);
1089-
if(isVertex){
1090-
Area_Children = geometry->nodes->GetVolume(Point_Fine);
1091-
//Get the customized BC values on fine level and compute the values at coarse level
1092-
WallHeatFlux_Fine = geometry->GetCustomBoundaryHeatFlux(val_marker, Vertex_Fine);
1093-
WallHeatFlux_Coarse += WallHeatFlux_Fine*Area_Children/Area_Parent;
1094-
}
1065+
su2double Get(unsigned long iVertex) { return fine_grid->GetCustomBoundaryHeatFlux(marker, iVertex); }
1066+
void Set(unsigned long iVertex, const su2double& val) { target[iVertex] = val; }
10951067

1096-
}
1097-
//Set the customized BC values at coarse level
1098-
CustomBoundaryHeatFlux[val_marker][iVertex] = WallHeatFlux_Coarse;
1099-
}
1100-
}
1068+
} wall_heat_flux;
1069+
1070+
wall_heat_flux.fine_grid = geometry;
1071+
wall_heat_flux.marker = val_marker;
1072+
wall_heat_flux.target = CustomBoundaryHeatFlux[val_marker];
11011073

1074+
SetMultiGridWallQuantity(geometry, val_marker, wall_heat_flux);
11021075
}
11031076

1104-
void CMultiGridGeometry::SetMultiGridWallTemperature(CGeometry *geometry, unsigned short val_marker){
1077+
void CMultiGridGeometry::SetMultiGridWallTemperature(const CGeometry *geometry, unsigned short val_marker){
11051078

1106-
unsigned long Point_Fine, Point_Coarse, iVertex;
1107-
unsigned short iChildren;
1108-
long Vertex_Fine;
1109-
su2double Area_Parent, Area_Children;
1110-
su2double WallTemperature_Fine, WallTemperature_Coarse;
1111-
bool isVertex;
1112-
int numberVertexChildren;
1113-
1114-
for(iVertex=0; iVertex < nVertex[val_marker]; iVertex++){
1115-
Point_Coarse = vertex[val_marker][iVertex]->GetNode();
1116-
if (nodes->GetDomain(Point_Coarse)){
1117-
Area_Parent = 0.0;
1118-
WallTemperature_Coarse = 0.0;
1119-
numberVertexChildren = 0;
1120-
/*--- Compute area parent by taking into account only volumes that are on the marker ---*/
1121-
for(iChildren=0; iChildren < nodes->GetnChildren_CV(Point_Coarse); iChildren++){
1122-
Point_Fine = nodes->GetChildren_CV(Point_Coarse, iChildren);
1123-
isVertex = (nodes->GetDomain(Point_Fine) && geometry->nodes->GetVertex(Point_Fine, val_marker) != -1);
1124-
if (isVertex){
1125-
numberVertexChildren += 1;
1126-
Area_Parent += geometry->nodes->GetVolume(Point_Fine);
1127-
}
1128-
}
1079+
struct {
1080+
const CGeometry* fine_grid;
1081+
unsigned short marker;
1082+
su2double* target;
11291083

1130-
/*--- Loop again and propagate values to the coarser level ---*/
1131-
for(iChildren=0; iChildren < nodes->GetnChildren_CV(Point_Coarse); iChildren++){
1132-
Point_Fine = nodes->GetChildren_CV(Point_Coarse, iChildren);
1133-
Vertex_Fine = geometry->nodes->GetVertex(Point_Fine, val_marker);
1134-
isVertex = (nodes->GetDomain(Point_Fine) && Vertex_Fine != -1);
1135-
if(isVertex){
1136-
Area_Children = geometry->nodes->GetVolume(Point_Fine);
1137-
//Get the customized BC values on fine level and compute the values at coarse level
1138-
WallTemperature_Fine = geometry->GetCustomBoundaryTemperature(val_marker, Vertex_Fine);
1139-
WallTemperature_Coarse += WallTemperature_Fine*Area_Children/Area_Parent;
1140-
}
1084+
su2double Get(unsigned long iVertex) { return fine_grid->GetCustomBoundaryTemperature(marker, iVertex); }
1085+
void Set(unsigned long iVertex, const su2double& val) { target[iVertex] = val; }
11411086

1142-
}
1143-
//Set the customized BC values at coarse level
1144-
CustomBoundaryTemperature[val_marker][iVertex] = WallTemperature_Coarse;
1145-
}
1146-
}
1087+
} wall_temperature;
1088+
1089+
wall_temperature.fine_grid = geometry;
1090+
wall_temperature.marker = val_marker;
1091+
wall_temperature.target = CustomBoundaryTemperature[val_marker];
11471092

1093+
SetMultiGridWallQuantity(geometry, val_marker, wall_temperature);
11481094
}
11491095

11501096
void CMultiGridGeometry::SetRestricted_GridVelocity(CGeometry *fine_mesh, const CConfig *config) {

0 commit comments

Comments
 (0)