Ignore:
Timestamp:
09/02/16 09:41:27 (8 years ago)
Author:
oabramkina
Message:

Parallel version of UGRID norms.

The following connectivity parameters have been implemented:

edge_nodes
face_nodes
face_edges
edge_faces
face_faces.

Test with a regular(structured) quadrilateral mesh (test_regular) has been added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/dht_auto_indexing.cpp

    r892 r924  
    1212{ 
    1313 
    14 /*! 
    15   Constructor with initial distribution information and the corresponding index 
    16   Each process holds a piece of hash value, which has no information (global index) associated. 
    17 The constructor tries to assign this information to each process basing on their rank. 
    18 The global index (information) are assigned across processes in the incremental manner. 
    19 The process has lower rank will have low global index. 
    20   \param [in] hashValue Carray contains hash value 
    21   \param [in] clientIntraComm communicator of clients 
    22 */ 
     14  CDHTAutoIndexing::~CDHTAutoIndexing() 
     15  { 
     16  } 
    2317 
    24 CDHTAutoIndexing::CDHTAutoIndexing(const CArray<size_t,1>& hashValue, 
    25                                    const MPI_Comm& clientIntraComm) 
    26   : CClientClientDHTTemplate<size_t>(clientIntraComm) 
    27 { 
    28   Index2VectorInfoTypeMap indexToVecInfoMap; 
    29   indexToVecInfoMap.rehash(std::ceil(hashValue.size()/indexToVecInfoMap.max_load_factor())); 
    30   CArray<size_t,1>::const_iterator it = hashValue.begin(), ite = hashValue.end(); 
     18  /*! 
     19    \param [in] 
     20    \param [in] 
     21  */ 
    3122 
    32   // Just use a dummy value to initialize 
    33   int nbLvl = this->getNbLevel(); 
    34   for (; it != ite; ++it) 
     23  CDHTAutoIndexing::CDHTAutoIndexing(const CArray<size_t,1>& hashValue, 
     24                                     const MPI_Comm& clientIntraComm) 
     25    : CClientClientDHTTemplate<size_t>(clientIntraComm) 
    3526  { 
    36     indexToVecInfoMap[*it].resize(1); 
    37     indexToVecInfoMap[*it][0] = 0; 
     27 
     28    nbIndexOnProc_ = hashValue.size(); 
     29    size_t nbIndexAccum; 
     30    MPI_Scan(&nbIndexOnProc_, &nbIndexAccum, 1, MPI_UNSIGNED_LONG, MPI_SUM, clientIntraComm); 
     31 
     32    // Broadcasting the total number of indexes 
     33    int rank, size; 
     34    MPI_Comm_rank(clientIntraComm, &rank); 
     35    MPI_Comm_size(clientIntraComm, &size); 
     36    if (rank == (size-1)) nbIndexesGlobal_ = nbIndexAccum; 
     37    MPI_Bcast(&nbIndexesGlobal_, 1, MPI_UNSIGNED_LONG, size-1, clientIntraComm); 
     38 
     39    CArray<size_t,1>::const_iterator itbIdx = hashValue.begin(), itIdx, 
     40                                     iteIdx = hashValue.end(); 
     41 
     42    size_t idx = 0; 
     43    beginIndexOnProc_ = nbIndexAccum - nbIndexOnProc_; 
     44    globalIndex_.resize(nbIndexOnProc_); 
     45    for (itIdx = itbIdx; itIdx != iteIdx; ++itIdx) 
     46    { 
     47      globalIndex_[idx] = beginIndexOnProc_ + idx; 
     48      ++idx ; 
     49    } 
    3850  } 
    39   computeDistributedIndex(indexToVecInfoMap, clientIntraComm, nbLvl-1); 
    4051 
    41   // Find out number of index on other proc 
    42   size_t nbIndexOnProc = index2InfoMapping_.size(); 
    43   size_t nbIndexAccum; 
     52  /*! 
     53   * \fn void CDHTAutoIndexing::CDHTAutoIndexing(Index2VectorInfoTypeMap& hashInitMap, const MPI_Comm& clientIntraComm) 
     54   * Assigns a global index to unique input indexes. 
     55   * The returned map has unique indexes as a key and global indexes as a mapped value. 
     56   * \param [in] hashInitMap map<size_t, vector<size_t>> is a map of unique indexes. 
     57   * \param [in] clientIntraComm 
     58  */ 
     59  CDHTAutoIndexing::CDHTAutoIndexing(Index2VectorInfoTypeMap& hashInitMap, 
     60                                     const MPI_Comm& clientIntraComm) 
     61    : CClientClientDHTTemplate<size_t>(clientIntraComm) 
     62  { 
    4463 
    45   MPI_Scan(&nbIndexOnProc, &nbIndexAccum, 1, MPI_UNSIGNED_LONG, MPI_SUM, clientIntraComm); 
     64    nbIndexOnProc_ = hashInitMap.size(); 
     65    size_t nbIndexAccum; 
     66    MPI_Scan(&nbIndexOnProc_, &nbIndexAccum, 1, MPI_UNSIGNED_LONG, MPI_SUM, clientIntraComm); 
    4667 
    47   Index2VectorInfoTypeMap::iterator itbIdx = index2InfoMapping_.begin(), itIdx, 
    48                                     iteIdx = index2InfoMapping_.end(); 
    49   size_t idx = 0; 
    50   size_t idxBegin = nbIndexAccum - nbIndexOnProc; 
    51   for (itIdx = itbIdx; itIdx != iteIdx; ++itIdx) 
     68    int rank, size; 
     69    MPI_Comm_rank(clientIntraComm, &rank); 
     70    MPI_Comm_size(clientIntraComm, &size); 
     71    if (rank == (size-1)) nbIndexesGlobal_ = nbIndexAccum; 
     72    MPI_Bcast(&nbIndexesGlobal_, 1, MPI_UNSIGNED_LONG, size-1, clientIntraComm); 
     73 
     74    Index2VectorInfoTypeMap::iterator itbIdx = hashInitMap.begin(), itIdx, 
     75                                      iteIdx = hashInitMap.end(); 
     76    size_t idx = 0; 
     77    beginIndexOnProc_ = nbIndexAccum - nbIndexOnProc_; 
     78    globalIndex_.resize(nbIndexOnProc_); 
     79    for (itIdx = itbIdx; itIdx != iteIdx; ++itIdx) 
     80    { 
     81      (itIdx->second)[0] = beginIndexOnProc_ + idx; 
     82      globalIndex_[idx] = beginIndexOnProc_ + idx; 
     83      ++idx ; 
     84    } 
     85  } 
     86 
     87  /*! 
     88   * \fn size_t CDHTAutoIndexing::getNbIndexesGlobal() const 
     89   * Returns the total number of global indexes. 
     90  */ 
     91  size_t CDHTAutoIndexing::getNbIndexesGlobal() const 
    5292  { 
    53     (itIdx->second)[0] = idxBegin + idx; 
    54     ++idx ; 
     93    return nbIndexesGlobal_; 
    5594  } 
    56 } 
     95 
     96  /*! 
     97   * \fn size_t CDHTAutoIndexing::getIndexStart() const 
     98   * Returns the starting global index for a proc. 
     99  */ 
     100  size_t CDHTAutoIndexing::getIndexStart() const 
     101  { 
     102    return beginIndexOnProc_; 
     103  } 
     104 
     105  /*! 
     106   * \fn size_t CDHTAutoIndexing::getIndexCount() const 
     107   * Returns the number of global indexes on a proc. 
     108  */ 
     109  size_t CDHTAutoIndexing::getIndexCount() const 
     110  { 
     111    return nbIndexOnProc_; 
     112  } 
    57113 
    58114} 
Note: See TracChangeset for help on using the changeset viewer.