Skip to content

Commit fde5b39

Browse files
committed
move to CVertex
1 parent bf48e1b commit fde5b39

File tree

5 files changed

+100
-78
lines changed

5 files changed

+100
-78
lines changed

Common/include/geometry/dual_grid/CVertex.hpp

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class CVertex : public CDualGrid {
4646
bool ActDisk_Perimeter = false; /*!< \brief Identify nodes at the perimeter of the actuator disk */
4747
short Rotation_Type; /*!< \brief Type of rotation associated with the vertex (MPI and periodic) */
4848
unsigned long Normal_Neighbor; /*!< \brief Index of the closest, most normal, neighbor. */
49+
su2double NearestNeighborDist = 0.0; /*!< \brief Distance to nearest internal neighbor that is not a wall. */
4950
su2double Basis_Function[3] = {0.0}; /*!< \brief Basis function values for interpolation across zones. */
5051

5152
public:
@@ -98,7 +99,7 @@ class CVertex : public CDualGrid {
9899
* \brief Get the normal to a face of the control volume asociated with a vertex.
99100
* \return Dimensional normal vector, the modulus is the area of the face.
100101
*/
101-
inline su2double* GetNormal(void) override { return Normal; }
102+
inline su2double* GetNormal() override { return Normal; }
102103

103104
/*!
104105
* \brief Get the ith component of the normal.
@@ -108,7 +109,7 @@ class CVertex : public CDualGrid {
108109
/*!
109110
* \brief Initialize normal vector.
110111
*/
111-
inline void SetZeroValues(void) override {
112+
inline void SetZeroValues() override {
112113
for (unsigned short iDim = 0; iDim < nDim; iDim++) Normal[iDim] = 0.0;
113114
}
114115

@@ -122,7 +123,7 @@ class CVertex : public CDualGrid {
122123
* \brief Get the value of an auxiliary variable for gradient computation.
123124
* \return Value of the auxiliar variable.
124125
*/
125-
inline su2double GetAuxVar(void) const { return Aux_Var; }
126+
inline su2double GetAuxVar() const { return Aux_Var; }
126127

127128
/*!
128129
* \brief Add the value of an auxiliary variable for gradient computation.
@@ -167,7 +168,7 @@ class CVertex : public CDualGrid {
167168
* \brief Get the value of the coordinate variation due to a surface modification.
168169
* \return Variation of the coordinate.
169170
*/
170-
inline su2double* GetVarCoord(void) { return VarCoord; }
171+
inline su2double* GetVarCoord() { return VarCoord; }
171172

172173
/*!
173174
* \brief Set the value of the cartesian coordinate for the vertex.
@@ -181,7 +182,7 @@ class CVertex : public CDualGrid {
181182
* \brief Get the value of the cartesian coordinate for the vertex.
182183
* \return Value of the cartesian coordinate of the vertex.
183184
*/
184-
inline su2double* GetCoord(void) override { return CartCoord; }
185+
inline su2double* GetCoord() override { return CartCoord; }
185186

186187
/*!
187188
* \brief Get the value of the cartesian coordinate for the vertex.
@@ -200,7 +201,7 @@ class CVertex : public CDualGrid {
200201
* \brief Get the type of rotation associated to the vertex.
201202
* \return Value of the rotation that must be applied to the solution of the vertex
202203
*/
203-
inline short GetRotation_Type(void) const { return Rotation_Type; }
204+
inline short GetRotation_Type() const { return Rotation_Type; }
204205

205206
/*!
206207
* \overload
@@ -250,49 +251,49 @@ class CVertex : public CDualGrid {
250251
* \brief Get the value of the periodic point of a vertex.
251252
* \return Value of the periodic point of a vertex.
252253
*/
253-
inline long GetDonorPoint(void) const { return PeriodicPoint[0]; }
254+
inline long GetDonorPoint() const { return PeriodicPoint[0]; }
254255

255256
/*!
256257
* \brief Get the value of the periodic point of a vertex.
257258
* \return Value of the periodic point of a vertex.
258259
*/
259-
inline long GetDonorMarker(void) const { return PeriodicPoint[4]; }
260+
inline long GetDonorMarker() const { return PeriodicPoint[4]; }
260261

261262
/*!
262263
* \brief Get the value of the periodic point of a vertex.
263264
* \return Value of the periodic point of a vertex.
264265
*/
265-
inline long GetDonorVertex(void) const { return PeriodicPoint[3]; }
266+
inline long GetDonorVertex() const { return PeriodicPoint[3]; }
266267

267268
/*!
268269
* \brief Get the value of the periodic point of a vertex.
269270
* \return Value of the periodic point of a vertex.
270271
*/
271-
inline long GetDonorGlobalIndex(void) const { return PeriodicPoint[2]; }
272+
inline long GetDonorGlobalIndex() const { return PeriodicPoint[2]; }
272273

273274
/*!
274275
* \brief Get the value of the periodic point of a vertex.
275276
* \return Value of the periodic point of a vertex.
276277
*/
277-
inline long GetGlobalDonorPoint(void) const { return PeriodicPoint[2]; }
278+
inline long GetGlobalDonorPoint() const { return PeriodicPoint[2]; }
278279

279280
/*!
280281
* \brief Get the value of the periodic point of a vertex.
281282
* \return Value of the periodic point of a vertex.
282283
*/
283-
inline long GetDonorProcessor(void) const { return PeriodicPoint[1]; }
284+
inline long GetDonorProcessor() const { return PeriodicPoint[1]; }
284285

285286
/*!
286287
* \brief Get the value of the periodic point of a vertex, and its somain
287288
* \return Value of the periodic point of a vertex, and the domain.
288289
*/
289-
inline long* GetPeriodicPointDomain(void) { return PeriodicPoint; }
290+
inline long* GetPeriodicPointDomain() { return PeriodicPoint; }
290291

291292
/*!
292293
* \brief Get the value of the periodic point of a vertex, and its somain
293294
* \return Value of the periodic point of a vertex, and the domain.
294295
*/
295-
inline bool GetActDisk_Perimeter(void) const { return ActDisk_Perimeter; }
296+
inline bool GetActDisk_Perimeter() const { return ActDisk_Perimeter; }
296297

297298
/*!
298299
* \brief Set the finite element basis functions needed for interpolation.
@@ -318,5 +319,15 @@ class CVertex : public CDualGrid {
318319
* \brief Get the value of the closest neighbor.
319320
* \return Index of the closest neighbor.
320321
*/
321-
inline unsigned long GetNormal_Neighbor(void) const { return Normal_Neighbor; }
322+
inline unsigned long GetNormal_Neighbor() const { return Normal_Neighbor; }
323+
324+
/*!
325+
* \brief Set the distance of the nearest internal neighbor that is not a wall.
326+
*/
327+
inline void SetNearestNeighborDistance(const su2double& val) { NearestNeighborDist = val; }
328+
329+
/*!
330+
* \brief Get the distance to the nearest internal neighbor that is not a wall.
331+
*/
332+
inline const su2double& GetNearestNeighborDistance() const { return NearestNeighborDist; }
322333
};

Common/src/geometry/CGeometry.cpp

Lines changed: 69 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3902,6 +3902,36 @@ const CGeometry::CLineletInfo& CGeometry::GetLineletInfo(const CConfig* config)
39023902
return li;
39033903
}
39043904

3905+
namespace {
3906+
su2double NearestNeighborDistance(CGeometry* geometry, const CConfig* config, const unsigned long iPoint) {
3907+
const su2double max = std::numeric_limits<su2double>::max();
3908+
su2double distance = max;
3909+
for (const auto jPoint : geometry->nodes->GetPoints(iPoint)) {
3910+
const su2double dist = geometry->nodes->GetWall_Distance(jPoint);
3911+
if (dist > EPS) distance = fmin(distance, dist);
3912+
}
3913+
if (distance > 0 && distance < max) return distance;
3914+
3915+
/*--- The point only has wall neighbors, which all have 0 wall distance.
3916+
* Compute an alternative distance based on volume and wall area. ---*/
3917+
3918+
const auto nDim = geometry->GetnDim();
3919+
su2double Normal[3] = {};
3920+
for (auto iMarker = 0u; iMarker < config->GetnMarker_All(); iMarker++) {
3921+
if (!config->GetViscous_Wall(iMarker)) continue;
3922+
3923+
const auto iVertex = geometry->nodes->GetVertex(iPoint, iMarker);
3924+
if (iVertex < 0) continue;
3925+
3926+
for (auto iDim = 0u; iDim < nDim; iDim++) {
3927+
Normal[iDim] += geometry->vertex[iMarker][iVertex]->GetNormal(iDim);
3928+
}
3929+
}
3930+
const su2double Vol = geometry->nodes->GetVolume(iPoint) + geometry->nodes->GetPeriodicVolume(iPoint);
3931+
return 2 * Vol / GeometryToolbox::Norm(nDim, Normal);
3932+
}
3933+
} // namespace
3934+
39053935
void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeometry**** geometry_container) {
39063936
int nZone = config_container[ZONE_0]->GetnZone();
39073937
bool allEmpty = true;
@@ -3946,27 +3976,48 @@ void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeo
39463976
CGeometry* geometry = geometry_container[iZone][iInst][MESH_0];
39473977
geometry->SetWallDistance(0.0);
39483978
}
3979+
continue;
39493980
}
3950-
/*--- Otherwise, set wall roughnesses. ---*/
3951-
if (!allEmpty) {
3952-
/*--- Store all wall roughnesses in a common data structure. ---*/
3953-
// [iZone][iMarker] -> roughness, for this rank
3954-
auto roughness_f = make_pair(nZone, [config_container, geometry_container, iInst](unsigned long iZone) {
3955-
const CConfig* config = config_container[iZone];
3956-
const auto nMarker = geometry_container[iZone][iInst][MESH_0]->GetnMarker();
3957-
3958-
return make_pair(nMarker, [config](unsigned long iMarker) {
3959-
return config->GetWallRoughnessProperties(config->GetMarker_All_TagBound(iMarker)).second;
3960-
});
3981+
3982+
/*--- Otherwise, set wall roughnesses, storing them in a common data structure. ---*/
3983+
// [iZone][iMarker] -> roughness, for this rank
3984+
auto roughness_f = make_pair(nZone, [config_container, geometry_container, iInst](unsigned long iZone) {
3985+
const CConfig* config = config_container[iZone];
3986+
const auto nMarker = geometry_container[iZone][iInst][MESH_0]->GetnMarker();
3987+
3988+
return make_pair(nMarker, [config](unsigned long iMarker) {
3989+
return config->GetWallRoughnessProperties(config->GetMarker_All_TagBound(iMarker)).second;
39613990
});
3962-
NdFlattener<2> roughness_local(roughness_f);
3963-
// [rank][iZone][iMarker] -> roughness
3964-
NdFlattener<3> roughness_global(Nd_MPI_Environment(), roughness_local);
3965-
// use it to update roughnesses
3966-
for (int jZone = 0; jZone < nZone; jZone++) {
3967-
if (wallDistanceNeeded[jZone] && config_container[jZone]->GetnRoughWall() > 0) {
3968-
geometry_container[jZone][iInst][MESH_0]->nodes->SetWallRoughness(roughness_global);
3991+
});
3992+
NdFlattener<2> roughness_local(roughness_f);
3993+
// [rank][iZone][iMarker] -> roughness
3994+
NdFlattener<3> roughness_global(Nd_MPI_Environment(), roughness_local);
3995+
// use it to update roughnesses
3996+
for (int jZone = 0; jZone < nZone; jZone++) {
3997+
if (wallDistanceNeeded[jZone] && config_container[jZone]->GetnRoughWall() > 0) {
3998+
geometry_container[jZone][iInst][MESH_0]->nodes->SetWallRoughness(roughness_global);
3999+
}
4000+
}
4001+
4002+
for (int iZone = 0; iZone < nZone; iZone++) {
4003+
const auto* config = config_container[iZone];
4004+
auto* geometry = geometry_container[iZone][iInst][MESH_0];
4005+
4006+
for (unsigned short iMarker = 0; iMarker < config->GetnMarker_All(); ++iMarker) {
4007+
const auto viscous = config->GetViscous_Wall(iMarker);
4008+
4009+
SU2_OMP_FOR_STAT(OMP_MIN_SIZE)
4010+
for (auto iVertex = 0u; iVertex < geometry->nVertex[iMarker]; iVertex++) {
4011+
const auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode();
4012+
su2double dist = 0;
4013+
if (viscous && geometry->nodes->GetDomain(iPoint)) {
4014+
dist = NearestNeighborDistance(geometry, config, iPoint);
4015+
} else {
4016+
dist = geometry->nodes->GetWall_Distance(iPoint);
4017+
}
4018+
geometry->vertex[iMarker][iVertex]->SetNearestNeighborDistance(dist);
39694019
}
4020+
END_SU2_OMP_FOR
39704021
}
39714022
}
39724023
}

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,7 +2350,7 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
23502350

23512351
unsigned long iVertex, iPoint, iPointNormal;
23522352
unsigned short iMarker, iMarker_Monitoring, iDim, jDim;
2353-
su2double Viscosity = 0.0, Area, Density = 0.0, WallDistMod, FrictionVel,
2353+
su2double Viscosity = 0.0, Area, Density = 0.0, FrictionVel,
23542354
UnitNormal[3] = {0.0}, TauElem[3] = {0.0}, Tau[3][3] = {{0.0}}, Cp,
23552355
thermal_conductivity, MaxNorm = 8.0, Grad_Vel[3][3] = {{0.0}}, Grad_Temp[3] = {0.0},
23562356
Grad_Temp_ve[3] = {0.0}, AxiFactor;
@@ -2497,11 +2497,9 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
24972497

24982498
FrictionVel = sqrt(fabs(WallShearStress[iMarker][iVertex]) / Density);
24992499

2500-
if (!wallfunctions && (MGLevel == MESH_0 || geometry->nodes->GetDomain(iPoint))) {
2500+
if (!wallfunctions && MGLevel == MESH_0 && geometry->nodes->GetDomain(iPoint)) {
25012501
// for CMultiGridGeometry, the normal neighbor of halo nodes is not set
2502-
iPointNormal = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor();
2503-
Coord_Normal = geometry->nodes->GetCoord(iPointNormal);
2504-
WallDistMod = GeometryToolbox::Distance(nDim, Coord, Coord_Normal);
2502+
const su2double WallDistMod = geometry->vertex[iMarker][iVertex]->GetNearestNeighborDistance();
25052503
YPlus[iMarker][iVertex] = WallDistMod * FrictionVel / (Viscosity / Density);
25062504
}
25072505

SU2_CFD/include/solvers/CTurbSSTSolver.hpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,6 @@ class CTurbSSTSolver final : public CTurbSolver {
5353
CSolver **solver_container,
5454
const CConfig *config,
5555
unsigned short val_marker);
56-
57-
/*!
58-
* \brief Returns the smallest non-zero wall distance over the neighbors of iPoint.
59-
* If this is zero the distance is estimated from volume and area.
60-
* \param[in] geometry - Geometrical definition of the problem.
61-
* \param[in] config - Definition of the particular problem.
62-
* \param[in] iPoint - Index of the wall point.
63-
* \return Distance.
64-
*/
65-
su2double NearestNeighborDistance(CGeometry *geometry, const CConfig *config, unsigned long iPoint) const;
66-
6756
public:
6857
/*!
6958
* \brief Constructor.

SU2_CFD/src/solvers/CTurbSSTSolver.cpp

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai
271271
shearStress = sqrt(shearStress);
272272

273273
const su2double FrictionVelocity = sqrt(shearStress/flowNodes->GetDensity(iPoint));
274-
const su2double wall_dist = NearestNeighborDistance(geometry, config, iPoint);
274+
const su2double wall_dist = geometry->vertex[iMarker][iVertex]->GetNearestNeighborDistance();
275275

276276
const su2double Derivative = flowNodes->GetLaminarViscosity(jPoint) * pow(nodes->GetSolution(jPoint, 0), 0.673) / wall_dist;
277277
const su2double turbulence_index = 6.1 * Derivative / pow(FrictionVelocity, 2.346);
@@ -459,7 +459,7 @@ void CTurbSSTSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_cont
459459
} else { // smooth wall
460460

461461
/*--- distance to closest neighbor ---*/
462-
su2double wall_dist = NearestNeighborDistance(geometry, config, iPoint);
462+
su2double wall_dist = geometry->vertex[val_marker][iVertex]->GetNearestNeighborDistance();
463463

464464
/*--- Set wall values ---*/
465465
const auto jPoint = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor();
@@ -1020,30 +1020,3 @@ void CTurbSSTSolver::SetUniformInlet(const CConfig* config, unsigned short iMark
10201020
}
10211021

10221022
}
1023-
1024-
su2double CTurbSSTSolver::NearestNeighborDistance(CGeometry *geometry, const CConfig *config,
1025-
unsigned long iPoint) const {
1026-
const su2double max = std::numeric_limits<su2double>::max();
1027-
su2double distance = max;
1028-
for (const auto jPoint : geometry->nodes->GetPoints(iPoint)) {
1029-
const su2double dist = geometry->nodes->GetWall_Distance(jPoint);
1030-
if (dist > EPS) distance = fmin(distance, dist);
1031-
}
1032-
if (distance > 0 && distance < max) return distance;
1033-
1034-
/*--- The point only has wall neighbors, which all have 0 wall distance.
1035-
* Compute an alternative distance based on volume and wall area. ---*/
1036-
1037-
su2double Normal[MAXNDIM] = {};
1038-
for (auto iMarker = 0u; iMarker < config->GetnMarker_All(); iMarker++) {
1039-
if (!config->GetViscous_Wall(iMarker)) continue;
1040-
1041-
const auto iVertex = geometry->nodes->GetVertex(iPoint, iMarker);
1042-
if (iVertex < 0) continue;
1043-
1044-
for (auto iDim = 0u; iDim < nDim; iDim++)
1045-
Normal[iDim] += geometry->vertex[iMarker][iVertex]->GetNormal(iDim);
1046-
}
1047-
const su2double Vol = geometry->nodes->GetVolume(iPoint) + geometry->nodes->GetPeriodicVolume(iPoint);
1048-
return 2 * Vol / GeometryToolbox::Norm(nDim, Normal);
1049-
}

0 commit comments

Comments
 (0)