source: XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/domain_algorithm_transformation.cpp @ 1853

Last change on this file since 1853 was 1784, checked in by ymipsl, 4 years ago
  • Preparing coupling functionalities.
  • Make some cleaner things

YM

File size: 2.3 KB
Line 
1/*!
2   \file domain_algorithm_transformation.hpp
3   \author Ha NGUYEN
4   \since 02 Jul 2015
5   \date 02 Jul 2015
6
7   \brief Interface for all domain transformation algorithms.
8 */
9
10#include "domain_algorithm_transformation.hpp"
11#include "context.hpp"
12#include "context_client.hpp"
13#include "domain.hpp"
14
15namespace xios {
16
17CDomainAlgorithmTransformation::CDomainAlgorithmTransformation(CDomain* domainDestination, CDomain* domainSource)
18 : CGenericAlgorithmTransformation(), domainDest_(domainDestination), domainSrc_(domainSource)
19{
20}
21
22CDomainAlgorithmTransformation::~CDomainAlgorithmTransformation()
23{
24}
25
26void CDomainAlgorithmTransformation::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs)
27{
28}
29
30/*!
31  Compute global index of domain on different processes
32  \param [in] globalDomainIndex global index of domain source
33  \param [out] globalDomainIndexOnProc processes which contain the corresponding global index of domain source
34*/
35void CDomainAlgorithmTransformation::computeExchangeGlobalIndex(const CArray<size_t,1>& globalDomainIndex,
36                                                                int elementType,
37                                                                CClientClientDHTInt::Index2VectorInfoTypeMap& globalDomainIndexOnProc)
38TRY
39{
40  CContext* context = CContext::getCurrent();
41  int clientRank = context->intraCommRank_;
42  int clientSize = context->intraCommSize_;
43
44  int niGlob = domainSrc_->ni_glo.getValue();
45  int njGlob = domainSrc_->nj_glo.getValue();
46  size_t globalIndex;
47  int nIndexSize = domainSrc_->i_index.numElements(), i_ind, j_ind;
48  CClientClientDHTInt::Index2VectorInfoTypeMap globalIndex2ProcRank;
49  globalIndex2ProcRank.rehash(std::ceil(nIndexSize/globalIndex2ProcRank.max_load_factor()));
50  CArray<bool,1>& localMask=domainSrc_->localMask ;
51  for (int idx = 0; idx < nIndexSize; ++idx)
52  {
53    if (localMask(idx))
54    {
55      i_ind=domainSrc_->i_index(idx) ;
56      j_ind=domainSrc_->j_index(idx) ;
57
58      globalIndex = i_ind + j_ind * niGlob;
59      globalIndex2ProcRank[globalIndex].push_back(clientRank);
60    }
61  }
62
63  CClientClientDHTInt dhtIndexProcRank(globalIndex2ProcRank, context->intraComm_);
64  dhtIndexProcRank.computeIndexInfoMapping(globalDomainIndex);
65  globalDomainIndexOnProc = dhtIndexProcRank.getInfoIndexMap();
66}
67CATCH
68
69}
Note: See TracBrowser for help on using the repository browser.