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

Last change on this file since 1620 was 1612, checked in by oabramkina, 2 years ago

Dev: adding exception handling.

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

File size: 4.6 KB
RevLine 
[687]1/*!
2   \file grid_generate.cpp
3   \author Ha NGUYEN
4   \since 28 Aug 2015
[887]5   \date 23 June 2016
[687]6
7   \brief A special transformation to generate a grid.
8 */
9#include "grid_generate.hpp"
[887]10#include "grid.hpp"
[687]11#include "domain_algorithm_generate_rectilinear.hpp"
12#include "generate_rectilinear_domain.hpp"
13
14namespace xios {
15CGridGenerate::CGridGenerate(CGrid* destination, CGrid* source)
[889]16  : CGridTransformationSelector(destination, source, special)
[687]17{
18}
19
20CGridGenerate::~CGridGenerate()
21{
22}
23
24/*!
[887]25  Select algorithm of an axis correspoding to its transformation type and its position in each element
[687]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*/
[887]31void CGridGenerate::selectScalarAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder)
[1612]32TRY
[687]33{
[887]34  CGenericAlgorithmTransformation* algo = 0;
35  algoTransformation_.push_back(algo);
[687]36}
[1612]37CATCH
[687]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)
[1612]47TRY
[687]48{
49  CGenericAlgorithmTransformation* algo = 0;
50  algoTransformation_.push_back(algo);
51}
[1612]52CATCH
[687]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)
[1612]62TRY
[687]63{
64  std::vector<CDomain*> domainListDestP = gridDestination_->getDomains();
[775]65  std::vector<CDomain*> domainListSrcP(domainListDestP.size());
66  if (0 != gridSource_) domainListSrcP = gridSource_->getDomains();
[687]67
[887]68  int domainIndex =  elementPositionInGridDst2DomainPosition_[elementPositionInGrid];
[687]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);
[775]82        algo = new CDomainAlgorithmGenerateRectilinear(domainListDestP[domainIndex], domainListSrcP[domainIndex],
83                                                       gridDestination_, gridSource_, genRectDomain);
[687]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}
[1612]96CATCH
[687]97
98/*!
99
100*/
101void CGridGenerate::completeGrid()
[1612]102TRY
[687]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;
[978]112    int transformationOrder = (it->second).second.first;
113    int algoType = (it->second).second.second;
[687]114
115    // First of all, select an algorithm
[978]116    selectAlgo(elementPositionInGrid, transType, transformationOrder, algoType);
[687]117  }
118}
[1612]119CATCH
[687]120
121}
Note: See TracBrowser for help on using the repository browser.