Skip to content

Commit

Permalink
Buffer_Receive_GlobalPoint as su2vector<unsigned long>
Browse files Browse the repository at this point in the history
instead of raw array long*
  • Loading branch information
maxaehle committed Aug 5, 2021
1 parent ee8a905 commit 612be75
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 32 deletions.
4 changes: 2 additions & 2 deletions Common/include/interface_interpolation/CInterpolator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class CInterpolator {
Buffer_Send_nVertex_Donor[1], /*!< \brief Buffer to send number of vertices on the local processor. */
*Buffer_Receive_nVertex_Donor; /*!< \brief Buffer to store the number of vertices per processor on the Donor domain. */

long *Buffer_Send_GlobalPoint, /*!< \brief Buffer to send global point indices. */
*Buffer_Receive_GlobalPoint; /*!< \brief Buffer to receive global point indices. */
su2vector<unsigned long> Buffer_Send_GlobalPoint; /*!< \brief Buffer to send global point indices. */
su2vector<unsigned long> Buffer_Receive_GlobalPoint; /*!< \brief Buffer to receive global point indices. */

su2activematrix Buffer_Send_Coord; /*!< \brief Buffer to send coordinate values. */
su2activematrix Buffer_Receive_Coord; /*!< \brief Buffer to receive coordinate values. */
Expand Down
18 changes: 8 additions & 10 deletions Common/src/interface_interpolation/CInterpolator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,11 @@ void CInterpolator::Collect_VertexInfo(int markDonor, int markTarget,
iLocalVertexDonor++;
}
}
auto nBuffer_Point = MaxLocalVertex_Donor;

SU2_MPI::Allgather(Buffer_Send_Coord.data(), Buffer_Send_Coord.size(), MPI_DOUBLE,
Buffer_Receive_Coord.data(), Buffer_Send_Coord.size(), MPI_DOUBLE, SU2_MPI::GetComm());
SU2_MPI::Allgather(Buffer_Send_GlobalPoint, nBuffer_Point, MPI_LONG,
Buffer_Receive_GlobalPoint, nBuffer_Point, MPI_LONG, SU2_MPI::GetComm());
SU2_MPI::Allgather(Buffer_Send_GlobalPoint.data(), MaxLocalVertex_Donor, MPI_LONG,
Buffer_Receive_GlobalPoint.data(), MaxLocalVertex_Donor, MPI_LONG, SU2_MPI::GetComm());
}

unsigned long CInterpolator::Collect_ElementInfo(int markDonor, unsigned short nDim, bool compress,
Expand Down Expand Up @@ -206,7 +205,7 @@ void CInterpolator::ReconstructBoundary(unsigned long val_zone, int val_marker){
// coordinates of all domain vertices on the marker
su2activematrix Buffer_Send_Coord(nLocalVertex, nDim);
// global point IDs of all domain vertices on the marker
long *Buffer_Send_GlobalPoint = new long [ nVertex ];
su2vector<unsigned long> Buffer_Send_GlobalPoint(nVertex);

// Assign to each domain vertex on the marker, identified by local point ID,
// a set of surface-neighbor vertices on the marker, identified by global point ID.
Expand All @@ -217,7 +216,7 @@ void CInterpolator::ReconstructBoundary(unsigned long val_zone, int val_marker){
iPoint = geom->vertex[val_marker][iVertex]->GetNode();
if (geom->nodes->GetDomain(iPoint)) {
unsigned long iLocalVertex = iVertex_to_iLocalVertex[iVertex];
Buffer_Send_GlobalPoint[iLocalVertex] = static_cast<long>( geom->nodes->GetGlobalIndex(iPoint) );
Buffer_Send_GlobalPoint[iLocalVertex] = geom->nodes->GetGlobalIndex(iPoint);
for (iDim = 0; iDim < nDim; iDim++)
Buffer_Send_Coord[iLocalVertex][iDim] = geom->nodes->GetCoord(iPoint, iDim);
neighbors.insert(pair<unsigned long, unordered_set<unsigned long> >(iPoint, unordered_set<unsigned long>()));
Expand Down Expand Up @@ -277,7 +276,7 @@ void CInterpolator::ReconstructBoundary(unsigned long val_zone, int val_marker){
SU2_MPI::Allreduce(&nLocalLinkedNodes, &nGlobalLinkedNodes, 1, MPI_UNSIGNED_LONG, MPI_SUM, SU2_MPI::GetComm());

Buffer_Receive_Coord.resize(nGlobalVertex, nDim);
Buffer_Receive_GlobalPoint = new long[ nGlobalVertex ];
Buffer_Receive_GlobalPoint.resize(nGlobalVertex);
Buffer_Receive_Proc.resize(nGlobalVertex);

Buffer_Receive_nLinkedNodes = new unsigned long[ nGlobalVertex ];
Expand Down Expand Up @@ -337,7 +336,7 @@ void CInterpolator::ReconstructBoundary(unsigned long val_zone, int val_marker){
SU2_MPI::Send( &nLocalVertex, 1, MPI_UNSIGNED_LONG, 0, 0, SU2_MPI::GetComm());
SU2_MPI::Send(Buffer_Send_Coord.data(), Buffer_Send_Coord.size(), MPI_DOUBLE, 0, 1, SU2_MPI::GetComm());

SU2_MPI::Send( Buffer_Send_GlobalPoint, nLocalVertex, MPI_LONG, 0, 1, SU2_MPI::GetComm());
SU2_MPI::Send( Buffer_Send_GlobalPoint.data(), nLocalVertex, MPI_LONG, 0, 1, SU2_MPI::GetComm());
SU2_MPI::Send( Buffer_Send_nLinkedNodes.data(), nLocalVertex, MPI_UNSIGNED_LONG, 0, 1, SU2_MPI::GetComm());
SU2_MPI::Send(Buffer_Send_StartLinkedNodes, nLocalVertex, MPI_UNSIGNED_LONG, 0, 1, SU2_MPI::GetComm());
}
Expand Down Expand Up @@ -367,7 +366,7 @@ void CInterpolator::ReconstructBoundary(unsigned long val_zone, int val_marker){
unsigned long jPoint = uptr[ jLinkedNode ];
bool found = false; // Global point index has been found
for (kVertex = 0; kVertex < nGlobalVertex; kVertex++){
if( Buffer_Receive_GlobalPoint[kVertex] == long(jPoint) ){
if( Buffer_Receive_GlobalPoint[kVertex] == jPoint ){
uptr[ jLinkedNode ] = kVertex;
found = true;
break;
Expand All @@ -385,15 +384,14 @@ void CInterpolator::ReconstructBoundary(unsigned long val_zone, int val_marker){
}
}

SU2_MPI::Bcast(Buffer_Receive_GlobalPoint, nGlobalVertex, MPI_LONG, 0, SU2_MPI::GetComm());
SU2_MPI::Bcast(Buffer_Receive_GlobalPoint.data(), nGlobalVertex, MPI_UNSIGNED_LONG, 0, SU2_MPI::GetComm());
SU2_MPI::Bcast(Buffer_Receive_Coord.data(), Buffer_Receive_Coord.size(), MPI_DOUBLE, 0, SU2_MPI::GetComm());
SU2_MPI::Bcast(Buffer_Receive_Proc.data(), nGlobalVertex, MPI_UNSIGNED_LONG, 0, SU2_MPI::GetComm());

SU2_MPI::Bcast(Buffer_Receive_nLinkedNodes, nGlobalVertex, MPI_UNSIGNED_LONG, 0, SU2_MPI::GetComm());
SU2_MPI::Bcast(Buffer_Receive_StartLinkedNodes, nGlobalVertex, MPI_UNSIGNED_LONG, 0, SU2_MPI::GetComm());
SU2_MPI::Bcast(Buffer_Receive_LinkedNodes.data(), nGlobalLinkedNodes, MPI_UNSIGNED_LONG, 0, SU2_MPI::GetComm());

delete [] Buffer_Send_GlobalPoint; Buffer_Send_GlobalPoint = nullptr;
delete [] Buffer_Send_LinkedNodes; Buffer_Send_LinkedNodes = nullptr;
delete [] Buffer_Send_StartLinkedNodes; Buffer_Send_StartLinkedNodes = nullptr;

Expand Down
7 changes: 2 additions & 5 deletions Common/src/interface_interpolation/CIsoparametric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ void CIsoparametric::SetTransferCoeff(const CConfig* const* config) {
Buffer_Receive_nVertex_Donor+nProcessor, 0ul);

Buffer_Send_Coord.resize(MaxLocalVertex_Donor, nDim);
Buffer_Send_GlobalPoint = new long [ MaxLocalVertex_Donor ];
Buffer_Send_GlobalPoint .resize(MaxLocalVertex_Donor);
Buffer_Receive_Coord.resize(nProcessor*MaxLocalVertex_Donor,nDim);
Buffer_Receive_GlobalPoint = new long [ nProcessor * MaxLocalVertex_Donor ];
Buffer_Receive_GlobalPoint.resize(nProcessor * MaxLocalVertex_Donor);

/*--- Collect coordinates and global point indices. ---*/
Collect_VertexInfo(markDonor, markTarget, nVertexDonor, nDim);
Expand Down Expand Up @@ -125,9 +125,6 @@ void CIsoparametric::SetTransferCoeff(const CConfig* const* config) {
}
assert((iCount == nGlobalVertexDonor) && "Global donor point count mismatch.");

delete[] Buffer_Send_GlobalPoint;
delete[] Buffer_Receive_GlobalPoint;

/*--- Collect donor element (face) information. ---*/

vector<unsigned long> allNumElem;
Expand Down
7 changes: 2 additions & 5 deletions Common/src/interface_interpolation/CNearestNeighbor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ void CNearestNeighbor::SetTransferCoeff(const CConfig* const* config) {
Buffer_Receive_nVertex_Donor+nProcessor, 0ul);

Buffer_Send_Coord.resize(MaxLocalVertex_Donor, nDim);
Buffer_Send_GlobalPoint = new long [ MaxLocalVertex_Donor ];
Buffer_Send_GlobalPoint.resize(MaxLocalVertex_Donor);
Buffer_Receive_Coord.resize(nProcessor * MaxLocalVertex_Donor, nDim);
Buffer_Receive_GlobalPoint = new long [ nProcessor * MaxLocalVertex_Donor ];
Buffer_Receive_GlobalPoint.resize(nProcessor * MaxLocalVertex_Donor);

/*--- Collect coordinates and global point indices. ---*/
Collect_VertexInfo(markDonor, markTarget, nVertexDonor, nDim);
Expand Down Expand Up @@ -169,9 +169,6 @@ void CNearestNeighbor::SetTransferCoeff(const CConfig* const* config) {
}
END_SU2_OMP_PARALLEL

delete[] Buffer_Send_GlobalPoint;
delete[] Buffer_Receive_GlobalPoint;

}

delete[] Buffer_Receive_nVertex_Donor;
Expand Down
7 changes: 2 additions & 5 deletions Common/src/interface_interpolation/CRadialBasisFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ void CRadialBasisFunction::SetTransferCoeff(const CConfig* const* config) {

/*--- Gather coordinates and global point indices. ---*/
Buffer_Send_Coord.resize(MaxLocalVertex_Donor, nDim);
Buffer_Send_GlobalPoint = new long [ MaxLocalVertex_Donor ];
Buffer_Send_GlobalPoint.resize(MaxLocalVertex_Donor);
Buffer_Receive_Coord.resize(nProcessor * MaxLocalVertex_Donor, nDim);
Buffer_Receive_GlobalPoint = new long [ nProcessor * MaxLocalVertex_Donor ];
Buffer_Receive_GlobalPoint.resize(nProcessor * MaxLocalVertex_Donor);

Collect_VertexInfo(markDonor, markTarget, nVertexDonor, nDim);

Expand All @@ -171,9 +171,6 @@ void CRadialBasisFunction::SetTransferCoeff(const CConfig* const* config) {
}
assert((iCount == nGlobalVertexDonor) && "Global donor point count mismatch.");

delete[] Buffer_Send_GlobalPoint;
delete[] Buffer_Receive_GlobalPoint;

/*--- Give an MPI-independent order to the points (required due to high condition
* number of the RBF matrix, avoids diff results with diff number of ranks. ---*/
vector<int> order(nGlobalVertexDonor);
Expand Down
8 changes: 3 additions & 5 deletions Common/src/interface_interpolation/CSlidingMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void CSlidingMesh::SetTransferCoeff(const CConfig* const* config) {

unsigned long *Target_nLinkedNodes, *Target_StartLinkedNodes, *target_segment;
su2vector<unsigned long> Target_LinkedNodes;
long *Target_GlobalPoint, *Donor_GlobalPoint;
su2vector<unsigned long> Target_GlobalPoint, Donor_GlobalPoint;

su2double *target_iMidEdge_point, *target_jMidEdge_point, **target_element;
su2activematrix TargetPoint_Coord;
Expand Down Expand Up @@ -226,7 +226,7 @@ void CSlidingMesh::SetTransferCoeff(const CConfig* const* config) {

/*--- Contruct information regarding the target cell ---*/

long dPoint = target_geometry->nodes->GetGlobalIndex(target_iPoint);
unsigned long dPoint = target_geometry->nodes->GetGlobalIndex(target_iPoint);
for (jVertexTarget = 0; jVertexTarget < nGlobalVertex_Target; jVertexTarget++)
if( dPoint == Target_GlobalPoint[jVertexTarget] )
break;
Expand Down Expand Up @@ -461,7 +461,7 @@ void CSlidingMesh::SetTransferCoeff(const CConfig* const* config) {
for (iDim = 0; iDim < nDim; iDim++)
Coord_i[iDim] = target_geometry->nodes->GetCoord(target_iPoint, iDim);

long dPoint = target_geometry->nodes->GetGlobalIndex(target_iPoint);
unsigned long dPoint = target_geometry->nodes->GetGlobalIndex(target_iPoint);
for (target_iPoint = 0; target_iPoint < nGlobalVertex_Target; target_iPoint++){
if( dPoint == Target_GlobalPoint[target_iPoint] )
break;
Expand Down Expand Up @@ -703,11 +703,9 @@ void CSlidingMesh::SetTransferCoeff(const CConfig* const* config) {
}
}

delete [] Target_GlobalPoint;
delete [] Target_nLinkedNodes;
delete [] Target_StartLinkedNodes;

delete [] Donor_GlobalPoint;
delete [] Donor_nLinkedNodes;
delete [] Donor_StartLinkedNodes;

Expand Down

0 comments on commit 612be75

Please sign in to comment.