source: XIOS/dev/dev_olga/src/transformation/grid_generate.cpp @ 1620

Last change on this file since 1620 was 1612, checked in by oabramkina, 22 months ago

Dev: adding exception handling.

To activate it, compilation flag -DXIOS_EXCEPTION should be added.

File size: 4.6 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)
32TRY
33{
34  CGenericAlgorithmTransformation* algo = 0;
35  algoTransformation_.push_back(algo);
36}
37CATCH
38
39/*!
40  Select algorithm of an axis correspoding to its transformation type and its position in each element
41  \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)
42                                             and position of axis is 2
43  \param [in] transType transformation type, for now we have Zoom_axis, inverse_axis
44  \param [in] transformationOrder position of the transformation in an element (an element can have several transformation)
45*/
46void CGridGenerate::selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder)
47TRY
48{
49  CGenericAlgorithmTransformation* algo = 0;
50  algoTransformation_.push_back(algo);
51}
52CATCH
53
54/*!
55  Select algorithm of a domain correspoding to its transformation type and its position in each element
56  \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)
57                                             and position of axis is 2
58  \param [in] transType transformation type, for now we have Zoom_axis, inverse_axis
59  \param [in] transformationOrder position of the transformation in an element (an element can have several transformation)
60*/
61void CGridGenerate::selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder)
62TRY
63{
64  std::vector<CDomain*> domainListDestP = gridDestination_->getDomains();
65  std::vector<CDomain*> domainListSrcP(domainListDestP.size());
66  if (0 != gridSource_) domainListSrcP = gridSource_->getDomains();
67
68  int domainIndex =  elementPositionInGridDst2DomainPosition_[elementPositionInGrid];
69  CDomain::TransMapTypes trans = domainListDestP[domainIndex]->getAllTransformations();
70  CDomain::TransMapTypes::const_iterator it = trans.begin();
71
72  for (int i = 0; i < transformationOrder; ++i, ++it) {}  // Find the correct transformation
73
74  CGenerateRectilinearDomain* genRectDomain = 0;
75  CGenericAlgorithmTransformation* algo = 0;
76  switch (transType)
77  {
78    case TRANS_GENERATE_RECTILINEAR_DOMAIN:
79      if (0 == transformationOrder)
80      {
81        genRectDomain = dynamic_cast<CGenerateRectilinearDomain*> (it->second);
82        algo = new CDomainAlgorithmGenerateRectilinear(domainListDestP[domainIndex], domainListSrcP[domainIndex],
83                                                       gridDestination_, gridSource_, genRectDomain);
84      }
85      else
86      {
87         ERROR("CGridGenerate::selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder)",
88           << "Generate rectilinear domain must be the first transformation");
89      }
90      break;
91    default:
92      break;
93  }
94  algoTransformation_.push_back(algo);
95}
96CATCH
97
98/*!
99
100*/
101void CGridGenerate::completeGrid()
102TRY
103{
104  ListAlgoType::const_iterator itb = listAlgos_.begin(),
105                               ite = listAlgos_.end(), it;
106  CGenericAlgorithmTransformation* algo = 0;
107
108  for (it = itb; it != ite; ++it)
109  {
110    int elementPositionInGrid = it->first;
111    ETranformationType transType = (it->second).first;
112    int transformationOrder = (it->second).second.first;
113    int algoType = (it->second).second.second;
114
115    // First of all, select an algorithm
116    selectAlgo(elementPositionInGrid, transType, transformationOrder, algoType);
117  }
118}
119CATCH
120
121}
Note: See TracBrowser for help on using the repository browser.