Skip to content

Commit aa92b1d

Browse files
committed
corrections
1 parent 1925cb3 commit aa92b1d

2 files changed

Lines changed: 29 additions & 16 deletions

File tree

Common/include/interface_interpolation/CInterpolator.hpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include "../../include/basic_types/datatype_structure.hpp"
3030
#include "../../include/containers/C2DContainer.hpp"
3131
#include <vector>
32+
#include <forward_list>
33+
#include <algorithm>
3234

3335
class CConfig;
3436
class CGeometry;
@@ -59,11 +61,15 @@ class CInterpolator {
5961
su2double *Buffer_Send_Coord, /*!< \brief Buffer to send coordinate values. */
6062
*Buffer_Receive_Coord; /*!< \brief Buffer to receive coordinate values. */
6163

62-
unsigned long
63-
*Buffer_Receive_nLinkedNodes, /*!< \brief Buffer to receive the number of edges surface-connected to each node. */
64-
*Buffer_Receive_LinkedNodes, /*!< \brief Buffer to receive the list of nodes surface-connected to the nodes through an edge. */
65-
*Buffer_Receive_StartLinkedNodes, /*!< \brief Buffer to receive the index of the Receive_LinkedNodes buffer where corresponding list of linked nodes begins. */
66-
*Buffer_Receive_Proc; /*!< \brief Buffer to receive the thread that owns the node. */
64+
/*! \brief Buffer to receive the number of surface-connected edges, for each vertex. */
65+
unsigned long *Buffer_Receive_nLinkedNodes;
66+
/*! \brief Buffer to receive the index of the Receive_LinkedNodes buffer where corresponding list of linked nodes begins. */
67+
unsigned long *Buffer_Receive_StartLinkedNodes;
68+
/*! \brief Buffer to receive the list of surface-connected nodes, for each vertex.
69+
* \details The vertices are ordered as in Buffer_Receive_nLinkedNodes and Buffer_Receive_StartLinkedNodes, but for each*/
70+
unsigned long *Buffer_Receive_LinkedNodes;
71+
/*! \brief Buffer to receive the rank that owns the vertex. */
72+
unsigned long *Buffer_Receive_Proc;
6773

6874
unsigned long
6975
nGlobalVertex_Target, /*!< \brief Global number of vertex of the target boundary. */

Common/src/interface_interpolation/CInterpolator.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -201,33 +201,38 @@ void CInterpolator::ReconstructBoundary(unsigned long val_zone, int val_marker){
201201
// coordinates of all domain vertices on the marker
202202
su2double *Buffer_Send_Coord = new su2double [ nLocalVertex * nDim ];
203203
// global point IDs of all domain vertices on the marker
204-
unsigned long *Buffer_Send_GlobalPoint = new unsigned long [ nVertex ];
204+
long *Buffer_Send_GlobalPoint = new long [ nVertex ];
205205

206206
// Assign to each domain vertex on the marker, identified by local point ID,
207207
// a set of surface-neighbor vertices on the marker, identified by global point ID.
208-
map<unsigned long, set<unsigned long>*> neighbors;
208+
map<unsigned long, forward_list<unsigned long>*> neighbors;
209209

210210
/*--- Define or initialize them. ---*/
211211
for (iVertex = 0; iVertex < nVertex; iVertex++) {
212212
iPoint = geom->vertex[val_marker][iVertex]->GetNode();
213213
if (geom->nodes->GetDomain(iPoint)) {
214214
unsigned long iLocalVertex = iVertex_to_iLocalVertex[iVertex];
215-
Buffer_Send_GlobalPoint[iLocalVertex] = geom->nodes->GetGlobalIndex(iPoint);
215+
Buffer_Send_GlobalPoint[iLocalVertex] = (long) geom->nodes->GetGlobalIndex(iPoint);
216216
for (iDim = 0; iDim < nDim; iDim++)
217217
Buffer_Send_Coord[iLocalVertex*nDim+iDim] = geom->nodes->GetCoord(iPoint, iDim);
218-
neighbors[iPoint] = new set<unsigned long>;
218+
neighbors.insert(pair<unsigned long, forward_list<unsigned long>*>(iPoint, new forward_list<unsigned long>));
219219
}
220220
}
221221

222222
/*--- Define the neighbors map. ---*/
223-
for(unsigned long iElem; iElem < geom->nElem_Bound[val_marker]; iElem++){
223+
for(unsigned long iElem=0; iElem < geom->nElem_Bound[val_marker]; iElem++){
224224
CPrimalGrid* elem = geom->bound[val_marker][iElem];
225225
for(unsigned short iNode=0; iNode<elem->GetnNodes(); iNode++){
226-
unsigned short iPoint = elem->GetNode(iNode);
227-
for(unsigned short iNeighbor=0; iNeighbor<elem->GetnNeighbor_Nodes(iNeighbor); iNeighbor++){
228-
unsigned long jPoint = elem->GetNode( elem->GetNeighbor_Nodes(iNode,iNeighbor) );
229-
unsigned long jPoint_global = geom->nodes->GetGlobalIndex(jPoint);
230-
neighbors[iPoint]->insert( jPoint_global );
226+
iPoint = elem->GetNode(iNode);
227+
if (geom->nodes->GetDomain(iPoint)) {
228+
forward_list<unsigned long>* neighb = neighbors.at(iPoint);
229+
for(unsigned short iNeighbor=0; iNeighbor<elem->GetnNeighbor_Nodes(iNode); iNeighbor++){
230+
unsigned long jPoint = elem->GetNode( elem->GetNeighbor_Nodes(iNode,iNeighbor) );
231+
unsigned long jPoint_global = geom->nodes->GetGlobalIndex(jPoint);
232+
if( std::find(std::begin(*neighb), std::end(*neighb), jPoint_global) == std::end(*neighb) ){
233+
neighb->emplace_front( jPoint_global );
234+
}
235+
}
231236
}
232237
}
233238
}
@@ -241,7 +246,9 @@ void CInterpolator::ReconstructBoundary(unsigned long val_zone, int val_marker){
241246
iPoint = geom->vertex[val_marker][iVertex]->GetNode();
242247
if (geom->nodes->GetDomain(iPoint)) {
243248
unsigned long iLocalVertex = iVertex_to_iLocalVertex[iVertex];
244-
Buffer_Send_nLinkedNodes[iLocalVertex] = neighbors[iPoint]->size();
249+
Buffer_Send_nLinkedNodes[iLocalVertex] = std::count_if(
250+
std::begin(*neighbors[iPoint]), std::end(*neighbors[iPoint]),
251+
[](unsigned long i){return true;} );
245252
Buffer_Send_StartLinkedNodes[iLocalVertex] = nLocalLinkedNodes;
246253
nLocalLinkedNodes += Buffer_Send_nLinkedNodes[iLocalVertex];
247254
}

0 commit comments

Comments
 (0)