Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fix cornernode normal #2392

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Common/include/geometry/CGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,12 @@ 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.
*/
Expand Down
8 changes: 7 additions & 1 deletion Common/include/geometry/CMultiGridGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,17 @@ class CMultiGridGeometry final : public CGeometry {
void SetRestricted_GridVelocity(const CGeometry* fine_grid) override;

/*!
* \brief Find and store the closest neighbor to a vertex.
* \brief Find and store the closest, most normal, neighbor to a vertex.
* \param[in] config - Definition of the particular problem.
*/
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.
Expand Down
8 changes: 7 additions & 1 deletion Common/include/geometry/CPhysicalGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,17 @@ class CPhysicalGeometry final : public CGeometry {
void ComputeMeshQualityStatistics(const CConfig* config) override;

/*!
* \brief Find and store the closest neighbor to a vertex.
* \brief Find and store the closest, most normal, neighbor to a vertex.
* \param[in] config - Definition of the particular problem.
*/
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.
Expand Down
15 changes: 14 additions & 1 deletion Common/include/geometry/dual_grid/CVertex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class CVertex : public CDualGrid {
long PeriodicPoint[5] = {-1}; /*!< \brief Store the periodic point of a boundary (iProcessor, iPoint) */
bool ActDisk_Perimeter = false; /*!< \brief Identify nodes at the perimeter of the actuator disk */
short Rotation_Type; /*!< \brief Type of rotation associated with the vertex (MPI and periodic) */
unsigned long Normal_Neighbor; /*!< \brief Index of the closest neighbor. */
unsigned long Normal_Neighbor; /*!< \brief Index of the closest, most normal, neighbor. */
unsigned long Nearest_Neighbor; /*!< \brief Index of the closest interior neighbor. */
su2double Basis_Function[3] = {0.0}; /*!< \brief Basis function values for interpolation across zones. */

public:
Expand Down Expand Up @@ -319,4 +320,16 @@ class CVertex : public CDualGrid {
* \return Index of the closest neighbor.
*/
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; }
};
79 changes: 79 additions & 0 deletions Common/src/geometry/CMultiGridGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1089,3 +1089,82 @@ 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<su2double> 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<su2double> 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);
}
}
}
}
80 changes: 80 additions & 0 deletions Common/src/geometry/CPhysicalGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8133,6 +8133,86 @@ 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<su2double> 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<su2double> 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;
Expand Down
13 changes: 11 additions & 2 deletions SU2_CFD/src/drivers/CDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,12 @@ 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;
Expand Down Expand Up @@ -833,10 +839,13 @@ void CDriver::InitializeGeometryFVM(CConfig *config, CGeometry **&geometry) {
geometry[iMGlevel]->SetBoundControlVolume(geometry[iMGlevel-1], config, ALLOCATE);
geometry[iMGlevel]->SetCoord(geometry[iMGlevel-1]);

/*--- Find closest neighbor to a surface point ---*/
/*--- Find closest, most normal, neighbor to a surface point ---*/

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);
Expand Down Expand Up @@ -2517,7 +2526,7 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet
else
interface_type = NO_TRANSFER;
}

if (interface_type != NO_TRANSFER) {
auto nVar = 4;
interface[donor][target] = new CConjugateHeatInterface(nVar, 0);
Expand Down
9 changes: 6 additions & 3 deletions SU2_CFD/src/solvers/CTurbSSTSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@
/*--- 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]->GetNormal_Neighbor();
const auto jPoint = geometry->vertex[iMarker][iVertex]->GetNearest_Neighbor();
//const auto jPoint = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor();

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

su2double shearStress = 0.0;
for(auto iDim = 0u; iDim < nDim; iDim++) {
Expand Down Expand Up @@ -459,7 +460,8 @@
} 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]->GetNormal_Neighbor();

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
const auto jPoint = geometry->vertex[val_marker][iVertex]->GetNearest_Neighbor();

su2double distance2 = GeometryToolbox::SquaredDistance(nDim,
geometry->nodes->GetCoord(iPoint),
Expand Down Expand Up @@ -507,7 +509,8 @@
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]->GetNormal_Neighbor();

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
const auto iPoint_Neighbor = geometry->vertex[val_marker][iVertex]->GetNearest_Neighbor();
if (!geometry->nodes->GetDomain(iPoint_Neighbor)) continue;

su2double Y_Plus = solver_container[FLOW_SOL]->GetYPlus(val_marker, iVertex);
Expand Down
Loading