source: XIOS/trunk/src/filter/generic_algorithm_transformation.cpp @ 620

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

Implementing generic transformation algorithm (local commit)

+) Implement 3 important classes:

-gridTransformation to read transformation info from grid and interface with the rest of XIOS
-transformationMapping to be in charge of sending/receiving transformation info among clients
-transformationAlgorithm to represent various algorithms

+) Make some change on field to use the new classes

Test
+) Only test_new_features with inversed axis

File size: 2.7 KB
Line 
1#include "generic_algorithm_transformation.hpp"
2
3namespace xios {
4
5CGenericAlgorithmTransformation::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*/
19void 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}
Note: See TracBrowser for help on using the repository browser.