source: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/zoom_axis.cpp @ 2247

Last change on this file since 2247 was 2011, checked in by ymipsl, 3 years ago
  • bug fix when createing mask on server side when overlapping grid
  • implement axis interpolation on pressure coordinate
  • big cleaning in transformation

YM

File size: 4.1 KB
Line 
1#include "zoom_axis.hpp"
2#include "axis_algorithm_zoom.hpp"
3#include "type.hpp"
4
5namespace xios {
6
7  /// ////////////////////// Définitions ////////////////////// ///
8
9  CZoomAxis::CZoomAxis(void)
10    : CObjectTemplate<CZoomAxis>(), CZoomAxisAttributes(), CTransformation<CAxis>()
11  { /* Ne rien faire de plus */ }
12
13  CZoomAxis::CZoomAxis(const StdString & id)
14    : CObjectTemplate<CZoomAxis>(id), CZoomAxisAttributes(), CTransformation<CAxis>()
15  { /* Ne rien faire de plus */ }
16
17  CZoomAxis::~CZoomAxis(void)
18  {}
19
20  CTransformation<CAxis>* CZoomAxis::create(const StdString& id, xml::CXMLNode* node)
21  {
22    CZoomAxis* zoomAxis = CZoomAxisGroup::get("zoom_axis_definition")->createChild(id);
23    if (node) zoomAxis->parse(*node);
24    return static_cast<CTransformation<CAxis>*>(zoomAxis);
25  }
26
27  bool CZoomAxis::registerTrans()
28  {
29    return registerTransformation(TRANS_ZOOM_AXIS, {create, getTransformation});
30  }
31
32  bool CZoomAxis::_dummyRegistered = CZoomAxis::registerTrans();
33
34  //----------------------------------------------------------------
35
36  StdString CZoomAxis::GetName(void)    { return StdString("zoom_axis"); }
37  StdString CZoomAxis::GetDefName(void) { return StdString("zoom_axis"); }
38  ENodeType CZoomAxis::GetType(void)    { return eZoomAxis; }
39
40  void CZoomAxis::checkValid(CAxis* axisDest)
41  {
42    int axisIBegin, axisNi, axisGlobalSize;
43    int begin, end, n;
44
45    axisIBegin = axisDest->begin.getValue();
46    axisNi     = axisDest->n.getValue();
47    axisGlobalSize   = axisDest->n_glo.getValue();
48
49    bool zoomByIndex = !this->index.isEmpty() && (0 != this->index.numElements());
50
51    if (zoomByIndex)
52    {
53      begin = min(this->index);
54      end   = max(this->index);
55      n     = end - begin + 1;
56    }
57    else
58    {
59      begin = (this->begin.isEmpty()) ?  0 : this->begin.getValue();
60      n     = (this->n.isEmpty()) ?  axisGlobalSize : this->n.getValue();
61      end   = begin+n-1;
62    }
63
64    if (begin < 0 || begin > axisGlobalSize - 1 || end < 0 || end > axisGlobalSize - 1
65        || n < 1 || n > axisGlobalSize || begin > end)
66      ERROR("CZoomAxis::checkValid(CAxis* axisDest)",
67            << "One or more attributes among 'begin' (" << begin << "), 'end' (" << end << "), 'n' (" << n << ") "
68            << "of axis transformation [ id = '" << axisDest->getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] are not well specified");
69   
70    if (zoomByIndex && (!this->begin.isEmpty() || !this->n.isEmpty()))
71      ERROR("CZoomAxis::checkValid(CAxis* axisDest)",
72            << "Only one type of zoom is accepted. Define zoom by index with global_zoom_index or define zoom with begin and n. "
73            << "Axis transformation [ id = '" << axisDest->getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] are not well specified");
74
75    this->begin.setValue(begin);
76    this->n.setValue(n);
77
78  }
79
80  CGenericAlgorithmTransformation* CZoomAxis::createAlgorithm(bool isSource,
81                                                        CGrid* gridDst, CGrid* gridSrc,
82                                                        int elementPositionInGrid,
83                                                        std::map<int, int>& elementPositionInGridSrc2ScalarPosition,
84                                                        std::map<int, int>& elementPositionInGridSrc2AxisPosition,
85                                                        std::map<int, int>& elementPositionInGridSrc2DomainPosition,
86                                                        std::map<int, int>& elementPositionInGridDst2ScalarPosition,
87                                                        std::map<int, int>& elementPositionInGridDst2AxisPosition,
88                                                        std::map<int, int>& elementPositionInGridDst2DomainPosition)
89  {
90    return CAxisAlgorithmZoom::create(isSource, gridDst,  gridSrc, this, elementPositionInGrid,
91                       elementPositionInGridSrc2ScalarPosition, elementPositionInGridSrc2AxisPosition, elementPositionInGridSrc2DomainPosition,
92                       elementPositionInGridDst2ScalarPosition, elementPositionInGridDst2AxisPosition, elementPositionInGridDst2DomainPosition);
93  }
94}
Note: See TracBrowser for help on using the repository browser.