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