source: XIOS/trunk/src/transformation/axis_algorithm_transformation.cpp @ 1221

Last change on this file since 1221 was 895, checked in by mhnguyen, 8 years ago

Adding a new transformation: Reduce a domain to an axis

Test
+) On Curie
+) Tests pass and are correct

File size: 3.2 KB
RevLine 
[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
18namespace xios {
19
[622]20CAxisAlgorithmTransformation::CAxisAlgorithmTransformation(CAxis* axisDestination, CAxis* axisSource)
[895]21 : CGenericAlgorithmTransformation(), axisDest_(axisDestination), axisSrc_(axisSource), domainSrc_(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]31CAxisAlgorithmTransformation::CAxisAlgorithmTransformation(CAxis* axisDestination, CDomain* domainSource)
32 : CGenericAlgorithmTransformation(), axisDest_(axisDestination), axisSrc_(0), domainSrc_(domainSource)
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
[621]42CAxisAlgorithmTransformation::~CAxisAlgorithmTransformation()
43{
[620]44}
45
[867]46void CAxisAlgorithmTransformation::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs)
47{
48}
49
50/*!
51  Compute global index of axis on different processes
52  \param [in] globalAxisIndex global index of axis source
53  \param [out] globalAxisIndexOnProc processes which contain the corresponding global index of axis source
54*/
[862]55void CAxisAlgorithmTransformation::computeExchangeGlobalIndex(const CArray<size_t,1>& globalAxisIndex,
[888]56                                                              int elementType,
[866]57                                                              CClientClientDHTInt::Index2VectorInfoTypeMap& globalAxisIndexOnProc)
[862]58{
59  CContext* context = CContext::getCurrent();
60  CContextClient* client=context->client;
61  int clientRank = client->clientRank;
62  int clientSize = client->clientSize;
63
64  size_t globalIndex;
[895]65  int nIndexSize = 0;
66  if (2 == elementType) nIndexSize = domainSrc_->i_index.numElements();
67  else if (1 == elementType) nIndexSize = axisSrc_->index.numElements();
[862]68  CClientClientDHTInt::Index2VectorInfoTypeMap globalIndex2ProcRank;
69  globalIndex2ProcRank.rehash(std::ceil(nIndexSize/globalIndex2ProcRank.max_load_factor()));
70  for (int idx = 0; idx < nIndexSize; ++idx)
71  {
[895]72    if (2 == elementType)
73    {
74      globalIndex = domainSrc_->i_index(idx) + domainSrc_->j_index(idx) * domainSrc_->ni_glo;
75    }
76    else if (1 == elementType)
77    {
78      globalIndex = axisSrc_->index(idx);
79    }
80
[866]81    globalIndex2ProcRank[globalIndex].resize(1);
82    globalIndex2ProcRank[globalIndex][0] = clientRank;
[862]83  }
84
85  CClientClientDHTInt dhtIndexProcRank(globalIndex2ProcRank, client->intraComm);
86  dhtIndexProcRank.computeIndexInfoMapping(globalAxisIndex);
87
[866]88  globalAxisIndexOnProc = dhtIndexProcRank.getInfoIndexMap();
[862]89}
90
[621]91}
Note: See TracBrowser for help on using the repository browser.