source: XIOS/trunk/src/transformation/grid_generate.cpp @ 978

Last change on this file since 978 was 978, checked in by mhnguyen, 4 years ago

Correcting various bugs relating to transformation

+) Fix the order of transformation selection
+) Correct domain transformation selection
+) Reorganize test_remap

Test
+) On Curie
+) All tests pass

File size: 4.5 KB
Line 
1/*!
2   \file grid_generate.cpp
3   \author Ha NGUYEN
4   \since 28 Aug 2015
5   \date 23 June 2016
6
7   \brief A special transformation to generate a grid.
8 */
9#include "grid_generate.hpp"
10#include "grid.hpp"
11#include "domain_algorithm_generate_rectilinear.hpp"
12#include "generate_rectilinear_domain.hpp"
13
14namespace xios {
15CGridGenerate::CGridGenerate(CGrid* destination, CGrid* source)
16  : CGridTransformationSelector(destination, source, special)
17{
18}
19
20CGridGenerate::~CGridGenerate()
21{
22}
23
24/*!
25  Select algorithm of an axis correspoding to its transformation type and its position in each element
26  \param [in] elementPositionInGrid position of element in grid. e.g: a grid has 1 domain and 1 axis, then position of domain is 1 (because it contains 2 basic elements)
27                                             and position of axis is 2
28  \param [in] transType transformation type, for now we have Zoom_axis, inverse_axis
29  \param [in] transformationOrder position of the transformation in an element (an element can have several transformation)
30*/
31void CGridGenerate::selectScalarAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder)
32{
33  CGenericAlgorithmTransformation* algo = 0;
34  algoTransformation_.push_back(algo);
35}
36
37/*!
38  Select algorithm of an axis correspoding to its transformation type and its position in each element
39  \param [in] elementPositionInGrid position of element in grid. e.g: a grid has 1 domain and 1 axis, then position of domain is 1 (because it contains 2 basic elements)
40                                             and position of axis is 2
41  \param [in] transType transformation type, for now we have Zoom_axis, inverse_axis
42  \param [in] transformationOrder position of the transformation in an element (an element can have several transformation)
43*/
44void CGridGenerate::selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder)
45{
46  CGenericAlgorithmTransformation* algo = 0;
47  algoTransformation_.push_back(algo);
48}
49
50/*!
51  Select algorithm of a domain correspoding to its transformation type and its position in each element
52  \param [in] elementPositionInGrid position of element in grid. e.g: a grid has 1 domain and 1 axis, then position of domain is 1 (because it contains 2 basic elements)
53                                             and position of axis is 2
54  \param [in] transType transformation type, for now we have Zoom_axis, inverse_axis
55  \param [in] transformationOrder position of the transformation in an element (an element can have several transformation)
56*/
57void CGridGenerate::selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder)
58{
59  std::vector<CDomain*> domainListDestP = gridDestination_->getDomains();
60  std::vector<CDomain*> domainListSrcP(domainListDestP.size());
61  if (0 != gridSource_) domainListSrcP = gridSource_->getDomains();
62
63  int domainIndex =  elementPositionInGridDst2DomainPosition_[elementPositionInGrid];
64  CDomain::TransMapTypes trans = domainListDestP[domainIndex]->getAllTransformations();
65  CDomain::TransMapTypes::const_iterator it = trans.begin();
66
67  for (int i = 0; i < transformationOrder; ++i, ++it) {}  // Find the correct transformation
68
69  CGenerateRectilinearDomain* genRectDomain = 0;
70  CGenericAlgorithmTransformation* algo = 0;
71  switch (transType)
72  {
73    case TRANS_GENERATE_RECTILINEAR_DOMAIN:
74      if (0 == transformationOrder)
75      {
76        genRectDomain = dynamic_cast<CGenerateRectilinearDomain*> (it->second);
77        algo = new CDomainAlgorithmGenerateRectilinear(domainListDestP[domainIndex], domainListSrcP[domainIndex],
78                                                       gridDestination_, gridSource_, genRectDomain);
79      }
80      else
81      {
82         ERROR("CGridGenerate::selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder)",
83           << "Generate rectilinear domain must be the first transformation");
84      }
85      break;
86    default:
87      break;
88  }
89  algoTransformation_.push_back(algo);
90}
91
92/*!
93
94*/
95void CGridGenerate::completeGrid()
96{
97  ListAlgoType::const_iterator itb = listAlgos_.begin(),
98                               ite = listAlgos_.end(), it;
99  CGenericAlgorithmTransformation* algo = 0;
100
101  for (it = itb; it != ite; ++it)
102  {
103    int elementPositionInGrid = it->first;
104    ETranformationType transType = (it->second).first;
105    int transformationOrder = (it->second).second.first;
106    int algoType = (it->second).second.second;
107
108    // First of all, select an algorithm
109    selectAlgo(elementPositionInGrid, transType, transformationOrder, algoType);
110  }
111}
112
113}
Note: See TracBrowser for help on using the repository browser.