1 | /*! |
---|
2 | \file generic_algorithm_transformation.hpp |
---|
3 | \author Ha NGUYEN |
---|
4 | \since 14 May 2015 |
---|
5 | \date 09 June 2015 |
---|
6 | |
---|
7 | \brief Interface for all transformation algorithms. |
---|
8 | */ |
---|
9 | #include "generic_algorithm_transformation.hpp" |
---|
10 | |
---|
11 | namespace xios { |
---|
12 | |
---|
13 | CGenericAlgorithmTransformation::CGenericAlgorithmTransformation() |
---|
14 | : transformationMapping_() |
---|
15 | { |
---|
16 | } |
---|
17 | |
---|
18 | /*! |
---|
19 | This function computes the global indexes of grid source, which the grid destination is in demand. |
---|
20 | \param[in] elementPositionInGrid position of an element in a grid .E.g: if grid is composed of domain and axis (in order), |
---|
21 | then position of axis in grid is 2 (since a domain is considered to contain 2 elements (axis) |
---|
22 | \param[in] gridDestGlobalDim global size of each dimension of grid source (all dimension must have the same size except of the one on which transformation is performed) |
---|
23 | \param[in] globalIndexGridDestSendToServer global index of grid destination on the current client to send to server |
---|
24 | \param[in/out] globaIndexMapFromDestToSource mapping between transformed global index of grid destination |
---|
25 | and the demanded global index of grid source |
---|
26 | */ |
---|
27 | void CGenericAlgorithmTransformation::computeGlobalSourceIndex(int elementPositionInGrid, |
---|
28 | const std::vector<int>& gridDestGlobalDim, |
---|
29 | const CArray<size_t,1>& globalIndexGridDestSendToServer, |
---|
30 | std::map<size_t, std::set<size_t> >& globaIndexMapFromDestToSource) |
---|
31 | { |
---|
32 | std::map<int, std::vector<int> >::const_iterator itbTransMap = transformationMapping_.begin(), |
---|
33 | itTransMap = itbTransMap, |
---|
34 | iteTransMap = transformationMapping_.end(); |
---|
35 | std::vector<int>::const_iterator itbVec, itVec, iteVec; |
---|
36 | std::vector<CArray<size_t,1> > globalIndexSrcGrid; //((itTransMap->second).size()); |
---|
37 | CArray<size_t,1> globalIndexDestGrid; |
---|
38 | for (itTransMap = itbTransMap; itTransMap != iteTransMap; ++itTransMap) |
---|
39 | { |
---|
40 | |
---|
41 | this->computeGlobalIndexFromGlobalIndexElement(itTransMap->first, |
---|
42 | itTransMap->second, |
---|
43 | elementPositionInGrid, |
---|
44 | gridDestGlobalDim, |
---|
45 | globalIndexGridDestSendToServer, |
---|
46 | globalIndexDestGrid, |
---|
47 | globalIndexSrcGrid); |
---|
48 | size_t globalIndexSize = globalIndexDestGrid.numElements(); |
---|
49 | for (size_t idx = 0; idx < globalIndexSize; ++idx) |
---|
50 | { |
---|
51 | for (int i = 0; i < globalIndexSrcGrid.size(); ++i) |
---|
52 | { |
---|
53 | globaIndexMapFromDestToSource[globalIndexDestGrid(idx)].insert(globalIndexSrcGrid[i](idx)); |
---|
54 | } |
---|
55 | } |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | } |
---|