source: XIOS/trunk/src/transformation/scalar_algorithm_transformation.cpp @ 888

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

Adding new transformation for scalar: Reducing an axis to a scalar

+) Add new xml node for new transformation
+) Add new algorithms for axis reduction
+) Make change in some place to make sure everything work fine

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

File size: 2.7 KB
Line 
1/*!
2   \file scalar_algorithm_transformation.hpp
3   \author Ha NGUYEN
4   \since 23 June 2016
5   \date 23 June 2016
6
7   \brief Interface for all scalar transformation algorithms.
8 */
9
10#include "scalar_algorithm_transformation.hpp"
11#include "context.hpp"
12#include "context_client.hpp"
13#include "client_client_dht_template.hpp"
14#include "domain.hpp"
15#include "axis.hpp"
16#include "scalar.hpp"
17
18namespace xios {
19
20CScalarAlgorithmTransformation::CScalarAlgorithmTransformation(CScalar* scalarDestination, CScalar* scalarSource)
21 : CGenericAlgorithmTransformation(),
22   scalarDest_(scalarDestination),
23   scalarSrc_(scalarSource), axisSrc_(0), domainSrc_(0)
24{
25}
26
27CScalarAlgorithmTransformation::CScalarAlgorithmTransformation(CScalar* scalarDestination, CAxis* axisSource)
28 : CGenericAlgorithmTransformation(),
29   scalarDest_(scalarDestination),
30   scalarSrc_(0), axisSrc_(axisSource), domainSrc_(0)
31{
32}
33
34CScalarAlgorithmTransformation::CScalarAlgorithmTransformation(CScalar* scalarDestination, CDomain* domainSource)
35 : CGenericAlgorithmTransformation(),
36   scalarDest_(scalarDestination),
37   scalarSrc_(0), axisSrc_(0), domainSrc_(domainSource)
38{
39}
40
41CScalarAlgorithmTransformation::~CScalarAlgorithmTransformation()
42{
43}
44
45void CScalarAlgorithmTransformation::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs)
46{
47}
48
49/*!
50  Compute global index of scalar on different processes
51  \param [in] globalScalarIndex global index of scalar source
52  \param [out] globalScalarIndexOnProc processes which contain the corresponding global index of scalar source
53*/
54void CScalarAlgorithmTransformation::computeExchangeGlobalIndex(const CArray<size_t,1>& globalScalarIndex,
55                                                                int elementType,
56                                                                CClientClientDHTInt::Index2VectorInfoTypeMap& globalScalarIndexOnProc)
57{
58  CContext* context = CContext::getCurrent();
59  CContextClient* client=context->client;
60  int clientRank = client->clientRank;
61  int clientSize = client->clientSize;
62
63  if (1 == elementType)
64  {
65    size_t globalIndex;
66    int nIndexSize = axisSrc_->index.numElements();
67    CClientClientDHTInt::Index2VectorInfoTypeMap globalIndex2ProcRank;
68    globalIndex2ProcRank.rehash(std::ceil(nIndexSize/globalIndex2ProcRank.max_load_factor()));
69    for (int idx = 0; idx < nIndexSize; ++idx)
70    {
71      globalIndex = axisSrc_->index(idx);
72      globalIndex2ProcRank[globalIndex].resize(1);
73      globalIndex2ProcRank[globalIndex][0] = clientRank;
74    }
75
76    CClientClientDHTInt dhtIndexProcRank(globalIndex2ProcRank, client->intraComm);
77    dhtIndexProcRank.computeIndexInfoMapping(globalScalarIndex);
78    globalScalarIndexOnProc = dhtIndexProcRank.getInfoIndexMap();
79  }
80}
81
82}
Note: See TracBrowser for help on using the repository browser.