[624] | 1 | /*! |
---|
| 2 | \file axis_algorithm_transformation.hpp |
---|
| 3 | \author Ha NGUYEN |
---|
| 4 | \since 14 May 2015 |
---|
[630] | 5 | \date 29 June 2015 |
---|
[624] | 6 | |
---|
| 7 | \brief Interface for all axis transformation algorithms. |
---|
| 8 | */ |
---|
| 9 | |
---|
[620] | 10 | #include "axis_algorithm_transformation.hpp" |
---|
[624] | 11 | #include "axis_algorithm_inverse.hpp" |
---|
| 12 | #include "axis_algorithm_zoom.hpp" |
---|
[862] | 13 | #include "context.hpp" |
---|
| 14 | #include "context_client.hpp" |
---|
| 15 | #include "client_client_dht_template.hpp" |
---|
[867] | 16 | #include "axis.hpp" |
---|
[620] | 17 | |
---|
| 18 | namespace xios { |
---|
| 19 | |
---|
[622] | 20 | CAxisAlgorithmTransformation::CAxisAlgorithmTransformation(CAxis* axisDestination, CAxis* axisSource) |
---|
[1275] | 21 | : CGenericAlgorithmTransformation(), axisDest_(axisDestination), axisSrc_(axisSource), domainSrc_(0),scalarSrc_(0) |
---|
[620] | 22 | { |
---|
[666] | 23 | axisDestGlobalSize_ = axisDestination->n_glo.getValue(); |
---|
| 24 | int niDest = axisDestination->n.getValue(); |
---|
| 25 | int ibeginDest = axisDestination->begin.getValue(); |
---|
[630] | 26 | |
---|
| 27 | for (int idx = 0; idx < niDest; ++idx) |
---|
| 28 | if ((axisDestination->mask)(idx)) axisDestGlobalIndex_.push_back(ibeginDest+idx); |
---|
[621] | 29 | } |
---|
[620] | 30 | |
---|
[895] | 31 | CAxisAlgorithmTransformation::CAxisAlgorithmTransformation(CAxis* axisDestination, CDomain* domainSource) |
---|
[1275] | 32 | : CGenericAlgorithmTransformation(), axisDest_(axisDestination), axisSrc_(0), domainSrc_(domainSource),scalarSrc_(0) |
---|
[895] | 33 | { |
---|
| 34 | axisDestGlobalSize_ = axisDestination->n_glo.getValue(); |
---|
| 35 | int niDest = axisDestination->n.getValue(); |
---|
| 36 | int ibeginDest = axisDestination->begin.getValue(); |
---|
| 37 | |
---|
| 38 | for (int idx = 0; idx < niDest; ++idx) |
---|
| 39 | if ((axisDestination->mask)(idx)) axisDestGlobalIndex_.push_back(ibeginDest+idx); |
---|
| 40 | } |
---|
| 41 | |
---|
[1275] | 42 | CAxisAlgorithmTransformation::CAxisAlgorithmTransformation(CAxis* axisDestination, CScalar* scalarSource) |
---|
| 43 | : CGenericAlgorithmTransformation(), axisDest_(axisDestination), axisSrc_(0), domainSrc_(0), scalarSrc_(scalarSource) |
---|
| 44 | { |
---|
| 45 | axisDestGlobalSize_ = axisDestination->n_glo.getValue(); |
---|
| 46 | int niDest = axisDestination->n.getValue(); |
---|
| 47 | int ibeginDest = axisDestination->begin.getValue(); |
---|
| 48 | |
---|
| 49 | for (int idx = 0; idx < niDest; ++idx) |
---|
| 50 | if ((axisDestination->mask)(idx)) axisDestGlobalIndex_.push_back(ibeginDest+idx); |
---|
| 51 | } |
---|
[621] | 52 | CAxisAlgorithmTransformation::~CAxisAlgorithmTransformation() |
---|
| 53 | { |
---|
[620] | 54 | } |
---|
| 55 | |
---|
[867] | 56 | void CAxisAlgorithmTransformation::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) |
---|
| 57 | { |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | /*! |
---|
| 61 | Compute global index of axis on different processes |
---|
| 62 | \param [in] globalAxisIndex global index of axis source |
---|
| 63 | \param [out] globalAxisIndexOnProc processes which contain the corresponding global index of axis source |
---|
| 64 | */ |
---|
[862] | 65 | void CAxisAlgorithmTransformation::computeExchangeGlobalIndex(const CArray<size_t,1>& globalAxisIndex, |
---|
[888] | 66 | int elementType, |
---|
[866] | 67 | CClientClientDHTInt::Index2VectorInfoTypeMap& globalAxisIndexOnProc) |
---|
[862] | 68 | { |
---|
| 69 | CContext* context = CContext::getCurrent(); |
---|
| 70 | CContextClient* client=context->client; |
---|
| 71 | int clientRank = client->clientRank; |
---|
| 72 | int clientSize = client->clientSize; |
---|
| 73 | |
---|
| 74 | size_t globalIndex; |
---|
[895] | 75 | int nIndexSize = 0; |
---|
[1403] | 76 | CArray<bool,1>* ptLocalMask ; |
---|
| 77 | CArray<bool,1> scalarMask(1) ; |
---|
| 78 | scalarMask=true ; |
---|
[1275] | 79 | |
---|
[1403] | 80 | if (2 == elementType) |
---|
| 81 | { |
---|
| 82 | nIndexSize = domainSrc_->i_index.numElements(); |
---|
| 83 | ptLocalMask=&(domainSrc_->localMask) ; |
---|
| 84 | } |
---|
| 85 | else if (1 == elementType) |
---|
| 86 | { |
---|
| 87 | nIndexSize = axisSrc_->index.numElements(); |
---|
| 88 | ptLocalMask=&(axisSrc_->mask) ; |
---|
| 89 | } |
---|
| 90 | else |
---|
| 91 | { |
---|
| 92 | nIndexSize=1 ; // scalar |
---|
| 93 | ptLocalMask=&scalarMask ; |
---|
| 94 | } |
---|
| 95 | CArray<bool,1>& localMask=*ptLocalMask ; |
---|
| 96 | |
---|
[862] | 97 | CClientClientDHTInt::Index2VectorInfoTypeMap globalIndex2ProcRank; |
---|
| 98 | globalIndex2ProcRank.rehash(std::ceil(nIndexSize/globalIndex2ProcRank.max_load_factor())); |
---|
| 99 | for (int idx = 0; idx < nIndexSize; ++idx) |
---|
| 100 | { |
---|
[1403] | 101 | if (localMask(idx)) |
---|
[895] | 102 | { |
---|
[1403] | 103 | if (2 == elementType) // domain |
---|
| 104 | { |
---|
| 105 | globalIndex = domainSrc_->i_index(idx) + domainSrc_->j_index(idx) * domainSrc_->ni_glo; |
---|
| 106 | } |
---|
| 107 | else if (1 == elementType) // axis |
---|
| 108 | { |
---|
| 109 | globalIndex = axisSrc_->index(idx); |
---|
| 110 | } |
---|
| 111 | else // scalar |
---|
| 112 | { |
---|
| 113 | globalIndex = 0; |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | globalIndex2ProcRank[globalIndex].resize(1); |
---|
| 117 | globalIndex2ProcRank[globalIndex][0] = clientRank; |
---|
[895] | 118 | } |
---|
[862] | 119 | } |
---|
| 120 | |
---|
| 121 | CClientClientDHTInt dhtIndexProcRank(globalIndex2ProcRank, client->intraComm); |
---|
| 122 | dhtIndexProcRank.computeIndexInfoMapping(globalAxisIndex); |
---|
| 123 | |
---|
[866] | 124 | globalAxisIndexOnProc = dhtIndexProcRank.getInfoIndexMap(); |
---|
[862] | 125 | } |
---|
| 126 | |
---|
[621] | 127 | } |
---|