source: XIOS/trunk/src/transformation/generic_algorithm_transformation.cpp @ 709

Last change on this file since 709 was 709, checked in by mhnguyen, 9 years ago

Correcting a bug in interpolation domain

+) Replace shared send buffer by seperate buffer for each proc
+) Remove some redundant codes

Test
+) On Curie
+) test_client, test_complete and test_remap pass

File size: 3.6 KB
Line 
1/*!
2   \file generic_algorithm_transformation.hpp
3   \author Ha NGUYEN
4   \since 14 May 2015
5   \date 29 June 2015
6
7   \brief Interface for all transformation algorithms.
8 */
9#include "generic_algorithm_transformation.hpp"
10
11namespace xios {
12
13CGenericAlgorithmTransformation::CGenericAlgorithmTransformation()
14 : transformationMapping_(), transformationWeight_()
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] gridSrcGlobalDim dimension size of source grid (it should share the same size for all dimension, maybe except the domain on which transformation is performed)
24  \param[in] globalIndexGridDestSendToServer global index of grid destination on the current client to send to server
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
27*/
28void CGenericAlgorithmTransformation::computeGlobalSourceIndex(int elementPositionInGrid,
29                                                             const std::vector<int>& gridDestGlobalDim,
30                                                             const std::vector<int>& gridSrcGlobalDim,
31                                                             const std::vector<size_t>& globalIndexGridDestSendToServer,
32                                                             std::map<size_t, std::vector<std::pair<size_t,double> > >& globaIndexWeightFromDestToSource)
33{
34  std::map<int, std::vector<int> >::const_iterator itbTransMap = transformationMapping_.begin(), itTransMap,
35                                                   iteTransMap = transformationMapping_.end();
36  std::map<int, std::vector<double> >::const_iterator itTransWeight = transformationWeight_.begin();
37  std::vector<std::vector<size_t> > globalIndexSrcGrid;
38  CArray<size_t,1> globalIndexDestGrid;
39  std::vector<size_t> vecGlobalIndexGridSendToServer(globalIndexGridDestSendToServer.begin(), globalIndexGridDestSendToServer.end());
40  std::sort(vecGlobalIndexGridSendToServer.begin(), vecGlobalIndexGridSendToServer.end());
41  for (itTransMap = itbTransMap; itTransMap != iteTransMap; ++itTransMap, ++itTransWeight)
42  {
43    this->computeGlobalGridIndexFromGlobalIndexElement(itTransMap->first,
44                                                   itTransMap->second,
45                                                   elementPositionInGrid,
46                                                   gridDestGlobalDim,
47                                                   gridSrcGlobalDim,
48                                                   vecGlobalIndexGridSendToServer,
49                                                   globalIndexDestGrid,
50                                                   globalIndexSrcGrid);
51    size_t globalIndexSize = globalIndexDestGrid.numElements();
52    const std::vector<double>& currentVecWeight = itTransWeight->second;
53    for (size_t idx = 0; idx < globalIndexSize; ++idx)
54    {
55      size_t globalIndex = globalIndexDestGrid(idx);
56      for (int i = 0; i < globalIndexSrcGrid[idx].size(); ++i)
57      {
58        globaIndexWeightFromDestToSource[globalIndex].push_back(make_pair(globalIndexSrcGrid[idx][i], currentVecWeight[i]));
59      }
60    }
61  }
62}
63
64}
Note: See TracBrowser for help on using the repository browser.