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

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

Implementing zooming on a domain

+) Add algorithm to do zooming on a domain
+) Remove some redundant codes

Test
+) On Curie
+) test_complete and test_client are correct

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 CArray<size_t,1>& 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(),
35                                                   itTransMap = itbTransMap,
36                                                   iteTransMap = transformationMapping_.end();
37  std::map<int, std::vector<double> >::const_iterator itTransWeight = transformationWeight_.begin();
38  std::map<size_t, std::vector<std::pair<size_t,double> > >::iterator iteWeight, itWeight;
39  std::vector<int>::const_iterator itbVec, itVec, iteVec;
40  std::vector<std::vector<size_t> > globalIndexSrcGrid;
41  CArray<size_t,1> globalIndexDestGrid;
42
43  for (itTransMap = itbTransMap; itTransMap != iteTransMap; ++itTransMap, ++itTransWeight)
44  {
45    this->computeGlobalGridIndexFromGlobalIndexElement(itTransMap->first,
46                                                   itTransMap->second,
47                                                   elementPositionInGrid,
48                                                   gridDestGlobalDim,
49                                                   gridSrcGlobalDim,
50                                                   globalIndexGridDestSendToServer,
51                                                   globalIndexDestGrid,
52                                                   globalIndexSrcGrid);
53    size_t globalIndexSize = globalIndexDestGrid.numElements();
54    std::vector<double> currentVecWeight = itTransWeight->second;
55    for (size_t idx = 0; idx < globalIndexSize; ++idx)
56    {
57      size_t globalIndex = globalIndexDestGrid(idx);
58      for (int i = 0; i < globalIndexSrcGrid[idx].size(); ++i)
59      {
60        globaIndexWeightFromDestToSource[globalIndex].push_back(make_pair(globalIndexSrcGrid[idx][i], currentVecWeight[i]));
61      }
62    }
63  }
64}
65
66}
Note: See TracBrowser for help on using the repository browser.