[624] | 1 | /*! |
---|
| 2 | \file generic_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 transformation algorithms. |
---|
| 8 | */ |
---|
[620] | 9 | #include "generic_algorithm_transformation.hpp" |
---|
| 10 | |
---|
| 11 | namespace xios { |
---|
| 12 | |
---|
| 13 | CGenericAlgorithmTransformation::CGenericAlgorithmTransformation() |
---|
[630] | 14 | : transformationMapping_(), transformationWeight_() |
---|
[620] | 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) |
---|
[631] | 23 | \param[in] gridSrcGlobalDim dimension size of source grid (it should share the same size for all dimension, maybe except the domain on which transformation is performed) |
---|
[620] | 24 | \param[in] globalIndexGridDestSendToServer global index of grid destination on the current client to send to server |
---|
[630] | 25 | \param[in/out] globaIndexWeightFromDestToSource mapping between transformed global index of grid destination |
---|
| 26 | and the weighted value as long as global index from grid index source |
---|
[620] | 27 | */ |
---|
| 28 | void CGenericAlgorithmTransformation::computeGlobalSourceIndex(int elementPositionInGrid, |
---|
| 29 | const std::vector<int>& gridDestGlobalDim, |
---|
[631] | 30 | const std::vector<int>& gridSrcGlobalDim, |
---|
[668] | 31 | const std::vector<size_t>& globalIndexGridDestSendToServer, |
---|
[630] | 32 | std::map<size_t, std::vector<std::pair<size_t,double> > >& globaIndexWeightFromDestToSource) |
---|
[620] | 33 | { |
---|
[709] | 34 | std::map<int, std::vector<int> >::const_iterator itbTransMap = transformationMapping_.begin(), itTransMap, |
---|
[620] | 35 | iteTransMap = transformationMapping_.end(); |
---|
[630] | 36 | std::map<int, std::vector<double> >::const_iterator itTransWeight = transformationWeight_.begin(); |
---|
| 37 | std::vector<std::vector<size_t> > globalIndexSrcGrid; |
---|
[620] | 38 | CArray<size_t,1> globalIndexDestGrid; |
---|
[668] | 39 | std::vector<size_t> vecGlobalIndexGridSendToServer(globalIndexGridDestSendToServer.begin(), globalIndexGridDestSendToServer.end()); |
---|
| 40 | std::sort(vecGlobalIndexGridSendToServer.begin(), vecGlobalIndexGridSendToServer.end()); |
---|
[630] | 41 | for (itTransMap = itbTransMap; itTransMap != iteTransMap; ++itTransMap, ++itTransWeight) |
---|
[620] | 42 | { |
---|
[630] | 43 | this->computeGlobalGridIndexFromGlobalIndexElement(itTransMap->first, |
---|
[620] | 44 | itTransMap->second, |
---|
| 45 | elementPositionInGrid, |
---|
| 46 | gridDestGlobalDim, |
---|
[631] | 47 | gridSrcGlobalDim, |
---|
[668] | 48 | vecGlobalIndexGridSendToServer, |
---|
[620] | 49 | globalIndexDestGrid, |
---|
| 50 | globalIndexSrcGrid); |
---|
| 51 | size_t globalIndexSize = globalIndexDestGrid.numElements(); |
---|
[657] | 52 | const std::vector<double>& currentVecWeight = itTransWeight->second; |
---|
[620] | 53 | for (size_t idx = 0; idx < globalIndexSize; ++idx) |
---|
| 54 | { |
---|
[630] | 55 | size_t globalIndex = globalIndexDestGrid(idx); |
---|
| 56 | for (int i = 0; i < globalIndexSrcGrid[idx].size(); ++i) |
---|
[620] | 57 | { |
---|
[630] | 58 | globaIndexWeightFromDestToSource[globalIndex].push_back(make_pair(globalIndexSrcGrid[idx][i], currentVecWeight[i])); |
---|
[620] | 59 | } |
---|
| 60 | } |
---|
| 61 | } |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | } |
---|