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

Fix periodic boundary condition for nodes on axis of rotation #840

Merged
merged 7 commits into from
Jan 13, 2020
Merged
Changes from 2 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
32 changes: 27 additions & 5 deletions Common/src/geometry/CPhysicalGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7975,6 +7975,12 @@ void CPhysicalGeometry::MatchPeriodic(CConfig *config,
su2double rotMatrix[3][3] = {{1.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,1.0}};
su2double Theta, Phi, Psi, cosTheta, sinTheta, cosPhi, sinPhi, cosPsi, sinPsi;
su2double rotCoord[3] = {0.0, 0.0, 0.0};

bool pointonAxis = false;

bool chksamePoint = false;

su2double dist_to_Axis = 0.0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @koodlyakshay,
Please follow the most common naming convention (pointOnAxis, distToAxis).
Is this going to match points to themselves if they are on the axis?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pcarruscag,

Fixed the naming scheme.
Also, yes the idea is to map the CV around a node on the axis on one periodic face with the corresponding CV around the same node on the other periodic face.


/*--- Tolerance for distance-based match to report warning. ---*/

Expand Down Expand Up @@ -8183,6 +8189,17 @@ void CPhysicalGeometry::MatchPeriodic(CConfig *config,
rotMatrix[2][1]*dy +
rotMatrix[2][2]*dz + translation[2]);

/*--- Check if the point lies on the axis of rotation. If it does,
the rotated coordinate and the original coordinate are the same. ---*/

pointonAxis = false;
dist_to_Axis = 0.0;
for (iDim = 0; iDim < nDim; iDim++)
dist_to_Axis = (rotCoord[iDim] - Coord_i[iDim])*(rotCoord[iDim] - Coord_i[iDim]);
dist_to_Axis = sqrt(dist_to_Axis);

if (dist_to_Axis < epsilon) pointonAxis = true;

/*--- Our search is based on the minimum distance, so we
initialize the distance to a large value. ---*/

Expand Down Expand Up @@ -8211,7 +8228,7 @@ void CPhysicalGeometry::MatchPeriodic(CConfig *config,
sure that we avoid the original point by checking that the
global index values are not the same. ---*/

if ((jPointGlobal != iPointGlobal)) {
if ((jPointGlobal != iPointGlobal) || (pointonAxis)) {

/*--- Compute the distance between the candidate periodic
point and the transformed coordinates of the owned point. ---*/
Expand All @@ -8225,10 +8242,15 @@ void CPhysicalGeometry::MatchPeriodic(CConfig *config,

/*--- Compare the distance against the existing minimum
and also perform checks just to be sure that this is an
independent periodic point (even if on the same rank). ---*/
independent periodic point (even if on the same rank),
unless it lies on the axis of rotation. ---*/

chksamePoint = false;
chksamePoint = (((dist < mindist) && (iProcessor != rank)) ||
((dist < mindist) && (iProcessor == rank) &&
(jPoint != iPoint)));

if (((dist < mindist) && (iProcessor != rank)) ||
((dist < mindist) && (iProcessor == rank) && (jPoint != iPoint))) {
if (chksamePoint || ((dist < mindist) && (pointonAxis))) {

/*--- We have found an intermediate match. Store the
data for this point before continuing the search. ---*/
Expand Down Expand Up @@ -8258,7 +8280,7 @@ void CPhysicalGeometry::MatchPeriodic(CConfig *config,
if (mindist > epsilon) {
cout.precision(10);
cout << endl;
cout << " Bad match for point " << iPointGlobal << ".\tNearest";
cout << " Bad match for point " << iPointGlobal <<".\tNearest";
cout << " donor distance: " << scientific << mindist << ".";
maxdist_local = min(maxdist_local, 0.0);
isBadMatch = true;
Expand Down