Skip to content

Commit 7d55b44

Browse files
committed
simplify
1 parent 1f1a4fe commit 7d55b44

File tree

3 files changed

+52
-86
lines changed

3 files changed

+52
-86
lines changed

Common/include/geometry/dual_grid/CVertex.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ 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-
unsigned long Nearest_Neighbor; /*!< \brief Index of the closest interior neighbor. */
5049
su2double Basis_Function[3] = {0.0}; /*!< \brief Basis function values for interpolation across zones. */
5150

5251
public:

SU2_CFD/include/solvers/CTurbSSTSolver.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ class CTurbSSTSolver final : public CTurbSolver {
5454
const CConfig *config,
5555
unsigned short val_marker);
5656

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+
5767
public:
5868
/*!
5969
* \brief Constructor.
@@ -302,6 +312,4 @@ class CTurbSSTSolver final : public CTurbSolver {
302312
*/
303313
inline su2double GetOmega_Inf(void) const override { return Solution_Inf[1]; }
304314

305-
su2double GetNearest_Neighbor(CGeometry *geometry, unsigned long iPoint,unsigned short iMarker, unsigned long iVertex);
306-
307315
};

SU2_CFD/src/solvers/CTurbSSTSolver.cpp

Lines changed: 42 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -251,44 +251,37 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai
251251

252252
/*--- Compute turbulence index ---*/
253253
if (config->GetKind_Trans_Model() != TURB_TRANS_MODEL::NONE) {
254-
for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++)
255-
if (config->GetViscous_Wall(iMarker)) {
256-
SU2_OMP_FOR_STAT(OMP_MIN_SIZE)
257-
for (auto iVertex = 0u; iVertex < geometry->nVertex[iMarker]; iVertex++) {
258-
const auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode();
254+
for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) {
255+
if (!config->GetViscous_Wall(iMarker)) continue;
259256

260-
/*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/
257+
SU2_OMP_FOR_STAT(OMP_MIN_SIZE)
258+
for (auto iVertex = 0u; iVertex < geometry->nVertex[iMarker]; iVertex++) {
259+
const auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode();
261260

261+
/*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/
262262

263-
if (geometry->nodes->GetDomain(iPoint)) {
263+
if (!geometry->nodes->GetDomain(iPoint)) continue;
264264

265-
const auto jPoint = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor();
265+
const auto jPoint = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor();
266266

267-
su2double shearStress = 0.0;
268-
for(auto iDim = 0u; iDim < nDim; iDim++) {
269-
shearStress += pow(solver_container[FLOW_SOL]->GetCSkinFriction(iMarker, iVertex, iDim), 2.0);
270-
}
271-
shearStress = sqrt(shearStress);
272-
273-
const su2double FrictionVelocity = sqrt(shearStress/flowNodes->GetDensity(iPoint));
274-
const su2double wall_dist_old = geometry->nodes->GetWall_Distance(jPoint);
275-
276-
const su2double wall_dist = GetNearest_Neighbor(geometry,iPoint,iMarker,iVertex);
277-
278-
cout << "************************* wall distance old = " << wall_dist_old << " , wall distance new = " << wall_dist << endl;
267+
su2double shearStress = 0.0;
268+
for(auto iDim = 0u; iDim < nDim; iDim++) {
269+
shearStress += pow(solver_container[FLOW_SOL]->GetCSkinFriction(iMarker, iVertex, iDim), 2.0);
270+
}
271+
shearStress = sqrt(shearStress);
279272

280-
const su2double Derivative = flowNodes->GetLaminarViscosity(jPoint) * pow(nodes->GetSolution(jPoint, 0), 0.673) / wall_dist;
281-
const su2double turbulence_index = 6.1 * Derivative / pow(FrictionVelocity, 2.346);
273+
const su2double FrictionVelocity = sqrt(shearStress/flowNodes->GetDensity(iPoint));
274+
const su2double wall_dist = NearestNeighborDistance(geometry, config, iPoint);
282275

283-
nodes->SetTurbIndex(iPoint, turbulence_index);
276+
const su2double Derivative = flowNodes->GetLaminarViscosity(jPoint) * pow(nodes->GetSolution(jPoint, 0), 0.673) / wall_dist;
277+
const su2double turbulence_index = 6.1 * Derivative / pow(FrictionVelocity, 2.346);
284278

285-
}
286-
}
287-
END_SU2_OMP_FOR
279+
nodes->SetTurbIndex(iPoint, turbulence_index);
288280
}
281+
END_SU2_OMP_FOR
282+
}
289283
}
290284

291-
292285
AD::EndNoSharedReading();
293286
}
294287

@@ -466,22 +459,17 @@ void CTurbSSTSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_cont
466459
} else { // smooth wall
467460

468461
/*--- distance to closest neighbor ---*/
469-
su2double wall_dist = GetNearest_Neighbor(geometry,iPoint,val_marker, iVertex);
462+
su2double wall_dist = NearestNeighborDistance(geometry, config, iPoint);
470463

471-
const auto jPoint = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor();
472-
//su2double distance2 = GeometryToolbox::SquaredDistance(nDim,
473-
// geometry->nodes->GetCoord(iPoint),
474-
// geometry->nodes->GetCoord(jPoint));
475464
/*--- Set wall values ---*/
476-
465+
const auto jPoint = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor();
477466
su2double density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(jPoint);
478467
su2double laminar_viscosity = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(jPoint);
479468

480469
su2double beta_1 = constants[4];
481470
su2double solution[MAXNVAR];
482471
solution[0] = 0.0;
483-
solution[1] = 60.0*laminar_viscosity/(density*beta_1*wall_dist*wall_dist);
484-
//solution[1] = 60.0*laminar_viscosity/(density*beta_1*distance2);
472+
solution[1] = 60.0*laminar_viscosity/(density*beta_1*pow(wall_dist,2));
485473

486474
/*--- Set the solution values and zero the residual ---*/
487475
nodes->SetSolution_Old(iPoint,solution);
@@ -1033,58 +1021,29 @@ void CTurbSSTSolver::SetUniformInlet(const CConfig* config, unsigned short iMark
10331021

10341022
}
10351023

1036-
/*--- We determine the interior node that is closest to the wall node. If there is no
1037-
interior node, we have to take the closest wall node. ---*/
1038-
su2double CTurbSSTSolver::GetNearest_Neighbor(CGeometry *geometry, unsigned long iPoint, unsigned short iMarker, unsigned long iVertex) {
1039-
su2double dist_min;
1040-
su2double distance = 0.0;
1041-
unsigned long Point_Normal;
1042-
1043-
Point_Normal = 0;
1044-
dist_min = 0.0;
1045-
for (size_t iNeigh = 0; iNeigh < geometry->nodes->GetnPoint(iPoint); iNeigh++) {
1046-
size_t jPoint = geometry->nodes->GetPoint(iPoint, iNeigh);
1047-
if (geometry->nodes->GetViscousBoundary(jPoint) == false) {
1048-
su2double distance[MAXNDIM] = {0.0};
1049-
// compute distance between ipoint and jpoint (vector)
1050-
GeometryToolbox::Distance(nDim,
1051-
geometry->nodes->GetCoord(iPoint),
1052-
geometry->nodes->GetCoord(jPoint),
1053-
distance);
1054-
// get the edge
1055-
size_t iEdge = geometry->nodes->GetEdge(iPoint, iNeigh);
1056-
const su2double* Normal = geometry->edges->GetNormal(iEdge);
1057-
const su2double Area = GeometryToolbox::Norm(nDim, Normal);
1058-
su2double projdistance = abs(GeometryToolbox::DotProduct(nDim,distance,Normal) / Area);
1059-
1060-
// Take the interior node that is closest to the wall node.
1061-
// cout << "projected distance = " << projdistance << " , area="<< Area << endl;
1062-
1063-
Point_Normal = jPoint;
1064-
dist_min = projdistance;
1065-
}
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);
10661031
}
1032+
if (distance > 0 && distance < max) return distance;
10671033

1034+
/*--- The point only has wall neighbors, which all have 0 wall distance.
1035+
* Compute an alternative distance based on volume and wall area. ---*/
10681036

1069-
if (Point_Normal==0) {
1070-
//cout << "no point found at i = " << iPoint << endl;
1071-
su2double Area = 0.0;
1072-
su2double TwoVol = 2.0* (geometry->nodes->GetVolume(iPoint) + geometry->nodes->GetPeriodicVolume(iPoint));
1037+
su2double Normal[MAXNDIM] = {};
1038+
for (auto iMarker = 0u; iMarker < config->GetnMarker_All(); iMarker++) {
1039+
if (!config->GetViscous_Wall(iMarker)) continue;
10731040

1074-
for (size_t iNeigh = 0; iNeigh < geometry->nodes->GetnPoint(iPoint); ++iNeigh) {
1075-
size_t iEdge = geometry->nodes->GetEdge(iPoint, iNeigh);
1076-
size_t jPoint = geometry->nodes->GetPoint(iPoint, iNeigh);
1041+
const auto iVertex = geometry->nodes->GetVertex(iPoint, iMarker);
1042+
if (iVertex < 0) continue;
10771043

1078-
if (geometry->nodes->GetViscousBoundary(jPoint) == true) {
1079-
const su2double* Normal = geometry->edges->GetNormal(iEdge);
1080-
Area = GeometryToolbox::Norm(nDim, Normal);
1081-
dist_min += TwoVol / Area;
1082-
//cout << " distmin = " << dist_min << " , vol = "<<TwoVol << " , Area=" << Area<< endl;
1083-
}
1084-
1085-
}
1086-
//cout << "distmin = " << dist_min << " , vol = "<<TwoVol << " , Area=" << Area<< endl;
1044+
for (auto iDim = 0u; iDim < nDim; iDim++)
1045+
Normal[iDim] += geometry->vertex[iMarker][iVertex]->GetNormal(iDim);
10871046
}
1088-
1089-
return (dist_min);
1047+
const su2double Vol = geometry->nodes->GetVolume(iPoint) + geometry->nodes->GetPeriodicVolume(iPoint);
1048+
return 2 * Vol / GeometryToolbox::Norm(nDim, Normal);
10901049
}

0 commit comments

Comments
 (0)