diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index 007a423e408..738618ba2cd 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -1179,12 +1179,6 @@ class CGeometry { */ inline virtual void FindNormal_Neighbor(const CConfig* config) {} - /*! - * \brief A virtual member. - * \param[in] config - Definition of the particular problem. - */ - inline virtual void FindNearest_Neighbor(const CConfig* config) {} - /*! * \brief A virtual member. */ diff --git a/Common/include/geometry/CMultiGridGeometry.hpp b/Common/include/geometry/CMultiGridGeometry.hpp index cecb65bbd75..09a3ca06d90 100644 --- a/Common/include/geometry/CMultiGridGeometry.hpp +++ b/Common/include/geometry/CMultiGridGeometry.hpp @@ -128,12 +128,6 @@ class CMultiGridGeometry final : public CGeometry { */ void FindNormal_Neighbor(const CConfig* config) override; - /*! - * \brief Find and store the closest interior neighbor to a vertex. - * \param[in] config - Definition of the particular problem. - */ - void FindNearest_Neighbor(const CConfig* config) override; - /*! * \brief Mach the near field boundary condition. * \param[in] config - Definition of the particular problem. diff --git a/Common/include/geometry/CPhysicalGeometry.hpp b/Common/include/geometry/CPhysicalGeometry.hpp index 8681fbc772f..3abbdb72ac5 100644 --- a/Common/include/geometry/CPhysicalGeometry.hpp +++ b/Common/include/geometry/CPhysicalGeometry.hpp @@ -565,12 +565,6 @@ class CPhysicalGeometry final : public CGeometry { */ void FindNormal_Neighbor(const CConfig* config) override; - /*! - * \brief Find and store the closest interior neighbor to a vertex. - * \param[in] config - Definition of the particular problem. - */ - void FindNearest_Neighbor(const CConfig* config) override; - /*! * \brief Read the sensitivity from an input file. * \param[in] config - Definition of the particular problem. diff --git a/Common/include/geometry/dual_grid/CVertex.hpp b/Common/include/geometry/dual_grid/CVertex.hpp index 4a31ee80bdb..9dd4c691386 100644 --- a/Common/include/geometry/dual_grid/CVertex.hpp +++ b/Common/include/geometry/dual_grid/CVertex.hpp @@ -321,15 +321,4 @@ class CVertex : public CDualGrid { */ inline unsigned long GetNormal_Neighbor(void) const { return Normal_Neighbor; } - /*! - * \brief Set the index of the closest interior neighbor to a point on the boundaries. - * \param[in] val_Nearest_Neighbor - Index of the closest neighbor. - */ - inline void SetNearest_Neighbor(unsigned long val_Nearest_Neighbor) { Nearest_Neighbor = val_Nearest_Neighbor; } - - /*! - * \brief Get the value of the closest neighbor. - * \return Index of the closest neighbor. - */ - inline unsigned long GetNearest_Neighbor(void) const { return Nearest_Neighbor; } }; diff --git a/Common/src/geometry/CMultiGridGeometry.cpp b/Common/src/geometry/CMultiGridGeometry.cpp index 291df133c94..c3c600e8a12 100644 --- a/Common/src/geometry/CMultiGridGeometry.cpp +++ b/Common/src/geometry/CMultiGridGeometry.cpp @@ -1089,82 +1089,3 @@ void CMultiGridGeometry::FindNormal_Neighbor(const CConfig* config) { } } } -/*--- We determine the interior node that is closest to the wall node. If there is no - interior node, we have to take the closest wall node. ---*/ -void CMultiGridGeometry::FindNearest_Neighbor(const CConfig* config) { - su2double dist_min; - unsigned long Point_Normal, jPoint; - unsigned short iNeigh, iMarker, jNeigh; - unsigned long iPoint, kPoint, iVertex; - // did we find an interiornode? - bool interiorNode; - - for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - if (config->GetMarker_All_KindBC(iMarker) != SEND_RECEIVE && - config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY && - config->GetMarker_All_KindBC(iMarker) != NEARFIELD_BOUNDARY) { - for (iVertex = 0; iVertex < nVertex[iMarker]; iVertex++) { - iPoint = vertex[iMarker][iVertex]->GetNode(); - const su2double* Coord_i = nodes->GetCoord(iPoint); - - /*--- Compute closest normal neighbor, note that the normal are oriented inwards ---*/ - Point_Normal = 0; - // we use distance - dist_min = 1.0e10; - interiorNode = false; - for (iNeigh = 0; iNeigh < nodes->GetnPoint(iPoint); iNeigh++) { - jPoint = nodes->GetPoint(iPoint, iNeigh); - const su2double* Coord_j = nodes->GetCoord(jPoint); - - su2double distance = 0.0; - vector edgeVector(nDim); - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - edgeVector[iDim] = Coord_j[iDim] - Coord_i[iDim]; - // squared distance - distance += edgeVector[iDim] * edgeVector[iDim]; - } - - // Take the interior node that is closest to the wall node. - if ((nodes->GetViscousBoundary(jPoint) == false) && (distance < dist_min)) { - Point_Normal = jPoint; - dist_min = distance; - interiorNode = true; - } - } - - // if we did not find a normal neighbor, then loop over the cells that are connected to the point - if (interiorNode == false) { - // find neighbor nodes to i. - for (iNeigh = 0; iNeigh < nodes->GetnPoint(iPoint); iNeigh++) { - jPoint = nodes->GetPoint(iPoint, iNeigh); - // now loop over the nodes of the neighbors - for (jNeigh = 0; jNeigh < nodes->GetnPoint(jPoint); jNeigh++) { - kPoint = nodes->GetPoint(jPoint, jNeigh); - - if (kPoint == iPoint) continue; - - const su2double* Coord_k = nodes->GetCoord(kPoint); - // now find the distance from ipoint to kpoint - su2double distance = 0.0; - vector edgeVector(nDim); - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - edgeVector[iDim] = Coord_k[iDim] - Coord_i[iDim]; - // squared distance - distance += edgeVector[iDim] * edgeVector[iDim]; - } - - // Take the interior node that is closest to the wall node. - if ((nodes->GetViscousBoundary(kPoint) == false) && (distance < dist_min)) { - Point_Normal = kPoint; - dist_min = distance; - interiorNode = true; - } - } - } - } - - vertex[iMarker][iVertex]->SetNearest_Neighbor(Point_Normal); - } - } - } -} diff --git a/Common/src/geometry/CPhysicalGeometry.cpp b/Common/src/geometry/CPhysicalGeometry.cpp index 91252fc9ed5..6e34e715be5 100644 --- a/Common/src/geometry/CPhysicalGeometry.cpp +++ b/Common/src/geometry/CPhysicalGeometry.cpp @@ -8133,86 +8133,6 @@ void CPhysicalGeometry::FindNormal_Neighbor(const CConfig* config) { } } -/*--- We determine the interior node that is closest to the wall node. If there is no - interior node, we have to take the closest wall node. ---*/ -void CPhysicalGeometry::FindNearest_Neighbor(const CConfig* config) { - su2double dist_min; - unsigned long Point_Normal, jPoint; - unsigned short iNeigh, iMarker, jNeigh; - unsigned long iPoint, kPoint, iVertex; - // did we find an interiornode? - bool interiorNode; - - for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - if (config->GetMarker_All_KindBC(iMarker) != SEND_RECEIVE && - config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY && - config->GetMarker_All_KindBC(iMarker) != NEARFIELD_BOUNDARY) { - for (iVertex = 0; iVertex < nVertex[iMarker]; iVertex++) { - iPoint = vertex[iMarker][iVertex]->GetNode(); - const su2double* Coord_i = nodes->GetCoord(iPoint); - - /*--- Compute closest normal neighbor, note that the normal are oriented inwards ---*/ - Point_Normal = 0; - // we use distance - dist_min = 1.0e10; - interiorNode = false; - for (iNeigh = 0; iNeigh < nodes->GetnPoint(iPoint); iNeigh++) { - jPoint = nodes->GetPoint(iPoint, iNeigh); - const su2double* Coord_j = nodes->GetCoord(jPoint); - - su2double distance = 0.0; - vector edgeVector(nDim); - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - edgeVector[iDim] = Coord_j[iDim] - Coord_i[iDim]; - // squared distance - distance += edgeVector[iDim] * edgeVector[iDim]; - } - - // Take the interior node that is closest to the wall node. - if ((nodes->GetViscousBoundary(jPoint) == false) && (distance < dist_min)) { - Point_Normal = jPoint; - dist_min = distance; - interiorNode = true; - } - } - - // if we did not find a normal neighbor, then loop over the cells that are connected to the point - if (interiorNode == false) { - // find neighbor nodes to i. - for (iNeigh = 0; iNeigh < nodes->GetnPoint(iPoint); iNeigh++) { - jPoint = nodes->GetPoint(iPoint, iNeigh); - // now loop over the nodes of the neighbors - for (jNeigh = 0; jNeigh < nodes->GetnPoint(jPoint); jNeigh++) { - kPoint = nodes->GetPoint(jPoint, jNeigh); - - if (kPoint == iPoint) continue; - - const su2double* Coord_k = nodes->GetCoord(kPoint); - // now find the distance from ipoint to kpoint - su2double distance = 0.0; - vector edgeVector(nDim); - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - edgeVector[iDim] = Coord_k[iDim] - Coord_i[iDim]; - // squared distance - distance += edgeVector[iDim] * edgeVector[iDim]; - } - - // Take the interior node that is closest to the wall node. - if ((nodes->GetViscousBoundary(kPoint) == false) && (distance < dist_min)) { - Point_Normal = kPoint; - dist_min = distance; - interiorNode = true; - } - } - } - } - - vertex[iMarker][iVertex]->SetNearest_Neighbor(Point_Normal); - } - } - } -} - void CPhysicalGeometry::SetBoundSensitivity(CConfig* config) { unsigned short iMarker, icommas; unsigned long iVertex, iPoint, (*Point2Vertex)[2], nPointLocal = 0, nPointGlobal = 0; diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp index 2aa31880bae..d5ed37c1848 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp @@ -2419,6 +2419,14 @@ class CFVMFlowSolverBase : public CSolver { return YPlus[val_marker][val_vertex]; } + /*! + * \brief Set the y plus. + * \param[in] val_yplus - new value of yplus + */ + inline void SetYPlus(su2double val_yplus, unsigned short val_marker, unsigned long val_vertex) final { + YPlus[val_marker][val_vertex] = val_yplus; + } + /*! * \brief Get the u_tau . * \param[in] val_marker - Surface marker where the coefficient is computed. diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index d7a634e8227..6db04c40111 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -2498,10 +2498,15 @@ void CFVMFlowSolverBase::Friction_Forces(const CGeometry* geometr FrictionVel = sqrt(fabs(WallShearStress[iMarker][iVertex]) / Density); if (!wallfunctions && (MGLevel == MESH_0 || geometry->nodes->GetDomain(iPoint))) { - // for CMultiGridGeometry, the normal neighbor of halo nodes in not set + // for CMultiGridGeometry, the normal neighbor of halo nodes is not set iPointNormal = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor(); Coord_Normal = geometry->nodes->GetCoord(iPointNormal); WallDistMod = GeometryToolbox::Distance(nDim, Coord, Coord_Normal); + //nijso: we can modifiy y+ as well now? + + + + YPlus[iMarker][iVertex] = WallDistMod * FrictionVel / (Viscosity / Density); } diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 2ed78a78a9b..343c2fec26a 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -2989,6 +2989,14 @@ class CSolver { */ inline virtual su2double GetYPlus(unsigned short val_marker, unsigned long val_vertex) const { return 0; } + /*! + * \brief A virtual member. + * \param[in] val_marker - Surface marker where the coefficient is computed. + * \param[in] val_vertex - Vertex of the marker val_marker where the coefficient is evaluated. + * \return Value of the y plus. + */ + inline virtual void SetYPlus(su2double val_yplus, unsigned short val_marker, unsigned long val_vertex) {}; + /*! * \brief A virtual member. * \param[in] val_marker - Surface marker where the coefficient is computed. diff --git a/SU2_CFD/include/solvers/CTurbSSTSolver.hpp b/SU2_CFD/include/solvers/CTurbSSTSolver.hpp index 78aa7720095..506797769fd 100644 --- a/SU2_CFD/include/solvers/CTurbSSTSolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSSTSolver.hpp @@ -302,5 +302,6 @@ class CTurbSSTSolver final : public CTurbSolver { */ inline su2double GetOmega_Inf(void) const override { return Solution_Inf[1]; } + su2double GetNearest_Neighbor(CGeometry *geometry, unsigned long iPoint,unsigned short iMarker, unsigned long iVertex); }; diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index dd7ad5da513..04765070107 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -777,12 +777,6 @@ void CDriver::InitializeGeometryFVM(CConfig *config, CGeometry **&geometry) { if (rank == MASTER_NODE) cout << "Searching for the closest normal neighbors to the surfaces." << endl; geometry[MESH_0]->FindNormal_Neighbor(config); - /*--- Identify closest interior neighbor, this is a replacement of the FindNormal_Neighbor implementation ---*/ - - if (rank == MASTER_NODE) cout << "Searching for the closest interior neighbors to the surfaces." << endl; - geometry[MESH_0]->FindNearest_Neighbor(config); - - /*--- Store the global to local mapping. ---*/ if (rank == MASTER_NODE) cout << "Storing a mapping from global to local point index." << endl; @@ -843,9 +837,6 @@ void CDriver::InitializeGeometryFVM(CConfig *config, CGeometry **&geometry) { geometry[iMGlevel]->FindNormal_Neighbor(config); - /*--- Find closest interior neighbor to a surface point (eventual replacement of FindNormal_Neighbor) ---*/ - geometry[iMGlevel]->FindNearest_Neighbor(config); - /*--- Store our multigrid index. ---*/ geometry[iMGlevel]->SetMGLevel(iMGlevel); diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index 33c27733b3e..a29c3f8b485 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -259,9 +259,10 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai /*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/ + if (geometry->nodes->GetDomain(iPoint)) { - const auto jPoint = geometry->vertex[iMarker][iVertex]->GetNearest_Neighbor(); - //const auto jPoint = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor(); + + const auto jPoint = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor(); su2double shearStress = 0.0; for(auto iDim = 0u; iDim < nDim; iDim++) { @@ -270,7 +271,8 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai shearStress = sqrt(shearStress); const su2double FrictionVelocity = sqrt(shearStress/flowNodes->GetDensity(iPoint)); - const su2double wall_dist = geometry->nodes->GetWall_Distance(jPoint); + //const su2double wall_dist = geometry->nodes->GetWall_Distance(jPoint); + const su2double wall_dist = GetNearest_Neighbor(geometry,iPoint,iMarker,iVertex); const su2double Derivative = flowNodes->GetLaminarViscosity(jPoint) * pow(nodes->GetSolution(jPoint, 0), 0.673) / wall_dist; const su2double turbulence_index = 6.1 * Derivative / pow(FrictionVelocity, 2.346); @@ -460,12 +462,12 @@ void CTurbSSTSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_cont } else { // smooth wall /*--- distance to closest neighbor ---*/ - //const auto jPoint = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor(); - const auto jPoint = geometry->vertex[val_marker][iVertex]->GetNearest_Neighbor(); + const auto jPoint = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor(); + const su2double wall_dist = GetNearest_Neighbor(geometry,iPoint,val_marker, iVertex); - su2double distance2 = GeometryToolbox::SquaredDistance(nDim, - geometry->nodes->GetCoord(iPoint), - geometry->nodes->GetCoord(jPoint)); + //su2double distance2 = GeometryToolbox::SquaredDistance(nDim, + // geometry->nodes->GetCoord(iPoint), + // geometry->nodes->GetCoord(jPoint)); /*--- Set wall values ---*/ su2double density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(jPoint); @@ -474,7 +476,7 @@ void CTurbSSTSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_cont su2double beta_1 = constants[4]; su2double solution[MAXNVAR]; solution[0] = 0.0; - solution[1] = 60.0*laminar_viscosity/(density*beta_1*distance2); + solution[1] = 60.0*laminar_viscosity/(density*beta_1*wall_dist*wall_dist); /*--- Set the solution values and zero the residual ---*/ nodes->SetSolution_Old(iPoint,solution); @@ -509,8 +511,7 @@ void CTurbSSTSolver::SetTurbVars_WF(CGeometry *geometry, CSolver **solver_contai for (auto iVertex = 0u; iVertex < geometry->nVertex[val_marker]; iVertex++) { const auto iPoint = geometry->vertex[val_marker][iVertex]->GetNode(); - //const auto iPoint_Neighbor = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor(); - const auto iPoint_Neighbor = geometry->vertex[val_marker][iVertex]->GetNearest_Neighbor(); + const auto iPoint_Neighbor = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor(); if (!geometry->nodes->GetDomain(iPoint_Neighbor)) continue; su2double Y_Plus = solver_container[FLOW_SOL]->GetYPlus(val_marker, iVertex); @@ -1015,8 +1016,7 @@ su2double CTurbSSTSolver::GetInletAtVertex(unsigned short iMarker, unsigned long su2double Normal[MAXNDIM] = {0.0}; geometry->vertex[iMarker][iVertex]->GetNormal(Normal); - return GeometryToolbox::Norm(nDim, Normal); -} + return GeometryToolbox::Norm(nDim, Normal);} void CTurbSSTSolver::SetUniformInlet(const CConfig* config, unsigned short iMarker) { if (config->GetMarker_All_KindBC(iMarker) == INLET_FLOW) { @@ -1027,3 +1027,72 @@ void CTurbSSTSolver::SetUniformInlet(const CConfig* config, unsigned short iMark } } + +/*--- We determine the interior node that is closest to the wall node. If there is no + interior node, we have to take the closest wall node. ---*/ +su2double CTurbSSTSolver::GetNearest_Neighbor(CGeometry *geometry, unsigned long iPoint, unsigned short iMarker, unsigned long iVertex) { + su2double dist_min; + su2double distance = 0.0; + unsigned long Point_Normal, jPoint; + unsigned short iNeigh, jNeigh; + unsigned long kPoint; + + const su2double* Coord_i = geometry->nodes->GetCoord(iPoint); + + /*--- Compute closest normal neighbor, note that the normal are oriented inwards ---*/ + Point_Normal = 0; + // we use distance + dist_min = 1.0e10; + for (iNeigh = 0; iNeigh < geometry->nodes->GetnPoint(iPoint); iNeigh++) { + jPoint = geometry->nodes->GetPoint(iPoint, iNeigh); + const su2double* Coord_j = geometry->nodes->GetCoord(jPoint); + + su2double distance = 0.0; + vector edgeVector(nDim); + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + edgeVector[iDim] = Coord_j[iDim] - Coord_i[iDim]; + // squared distance + distance += edgeVector[iDim] * edgeVector[iDim]; + } + + // Take the interior node that is closest to the wall node. + if ((geometry->nodes->GetViscousBoundary(jPoint) == false) && (distance < dist_min)) { + Point_Normal = jPoint; + dist_min = distance; + } + } + + if (jPoint==0) { + su2double Area = 0.0; + su2double TwoVol = 2.0* (geometry->nodes->GetVolume(iPoint) + geometry->nodes->GetPeriodicVolume(iPoint)); + for (size_t iNeigh = 0; iNeigh < geometry->nodes->GetnPoint(iPoint); ++iNeigh) { + size_t iEdge = geometry->nodes->GetEdge(iPoint, iNeigh); + size_t jPoint = geometry->nodes->GetPoint(iPoint, iNeigh); + + /*--- Determine if edge points inwards or outwards of iPoint. + * If inwards we need to flip the area vector. ---*/ + + su2double dir = (iPoint < jPoint) ? 1.0 : -1.0; + su2double weight = dir * TwoVol; + const su2double* Normal = geometry->edges->GetNormal(iEdge); + Area = GeometryToolbox::Norm(nDim, Normal); + + + //thscale += TwoVol * geometry->edges->GetNormal(iEdge); + dist_min += TwoVol * Area; + } + } + + // old value of yplus + su2double yplus = GetYPlus(iMarker,iVertex); + unsigned long iPointNormal = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor(); + const su2double *Coord_Normal = geometry->nodes->GetCoord(iPointNormal); + const su2double *Coord = geometry->nodes->GetCoord(iPoint); + + su2double WallDistMod = GeometryToolbox::Distance(nDim, Coord, Coord_Normal); + // new value of y+ + yplus = dist_min * (yplus / WallDistMod); + SetYPlus(yplus,iMarker,iVertex); + + return (dist_min); +}