source: XIOS/trunk/src/node/interpolate_axis.cpp @ 2250

Last change on this file since 2250 was 1980, checked in by yushan, 3 years ago

trunk : axis interpolate can have coordinate source (coordinate_src) and coordinate destination (coordinate_dst), while previous attribute coordinate compatible to source

File size: 4.6 KB
Line 
1#include "interpolate_axis.hpp"
2#include "type.hpp"
3#include "field.hpp"
4
5namespace xios {
6
7  /// ////////////////////// Définitions ////////////////////// ///
8
9  CInterpolateAxis::CInterpolateAxis(void)
10    : CObjectTemplate<CInterpolateAxis>(), CInterpolateAxisAttributes(), CTransformation<CAxis>()
11  { /* Ne rien faire de plus */ }
12
13  CInterpolateAxis::CInterpolateAxis(const StdString & id)
14    : CObjectTemplate<CInterpolateAxis>(id), CInterpolateAxisAttributes(), CTransformation<CAxis>()
15  { /* Ne rien faire de plus */ }
16
17  CInterpolateAxis::~CInterpolateAxis(void)
18  {}
19
20  CTransformation<CAxis>* CInterpolateAxis::create(const StdString& id, xml::CXMLNode* node)
21  {
22    CInterpolateAxis* interpAxis = CInterpolateAxisGroup::get("interpolate_axis_definition")->createChild(id);
23    if (node) interpAxis->parse(*node);
24    return static_cast<CTransformation<CAxis>*>(interpAxis);
25  }
26
27  bool CInterpolateAxis::registerTrans()
28  {
29    return registerTransformation(TRANS_INTERPOLATE_AXIS, CInterpolateAxis::create);
30  }
31
32  bool CInterpolateAxis::_dummyRegistered = CInterpolateAxis::registerTrans();
33
34  //----------------------------------------------------------------
35
36  StdString CInterpolateAxis::GetName(void)    { return StdString("interpolate_axis"); }
37  StdString CInterpolateAxis::GetDefName(void) { return StdString("interpolate_axis"); }
38  ENodeType CInterpolateAxis::GetType(void)    { return eInterpolateAxis; }
39
40  void CInterpolateAxis::checkValid(CAxis* axisSrc)
41  {
42    if (this->order.isEmpty()) this->order.setValue(1);
43    if (this->coordinate.isEmpty() && !this->coordinate_src.isEmpty()) this->coordinate.setValue(this->coordinate_src.getValue());
44    if (this->coordinate_src.isEmpty() && !this->coordinate.isEmpty()) this->coordinate_src.setValue(this->coordinate.getValue());
45    int order = this->order.getValue();
46    if (order >= axisSrc->n_glo.getValue())
47    {
48      ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)",
49             << "Order of interpolation is greater than global size of axis source"
50             << "Size of axis source " <<axisSrc->getId() << " is " << axisSrc->n_glo.getValue()  << std::endl
51             << "Order of interpolation is " << order );
52    }
53
54    if (order < 1)
55    {
56      ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)",
57             << "Order of interpolation is smaller than 1"
58             << "Size of axis source " <<axisSrc->getId() << " is " << axisSrc->n_glo.getValue()  << std::endl
59             << "Order of interpolation is " << order );
60    }
61
62
63    if (!this->coordinate.isEmpty())
64    {
65      StdString coordinate = this->coordinate.getValue();
66      if (!CField::has(coordinate))
67        ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)",
68               << "Coordinate field whose id " << coordinate << "does not exist "
69               << "Please define one");
70    }
71   
72    if (!this->coordinate_dst.isEmpty())
73    {
74      StdString coordinate = this->coordinate_dst.getValue();
75      if (!CField::has(coordinate))
76        ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)",
77               << "Coordinate field whose id " << coordinate << "does not exist "
78               << "Please define one");
79    }
80   
81  }
82
83  std::vector<StdString> CInterpolateAxis::checkAuxInputs_()
84  {
85    std::vector<StdString> auxInputs;
86    if (!this->coordinate.isEmpty() && this->coordinate_src.isEmpty())
87    {
88      StdString coordinate = this->coordinate.getValue();
89      this->coordinate_src.setValue(coordinate);
90      if (!CField::has(coordinate))
91        ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)",
92               << "Coordinate field whose id " << coordinate << "does not exist "
93               << "Please define one");
94      auxInputs.push_back(coordinate);
95    }
96    if (!this->coordinate_src.isEmpty() || !this->coordinate.isEmpty())
97    {
98      StdString coordinate = !this->coordinate.isEmpty()? this->coordinate.getValue():this->coordinate_src.getValue();
99      this->coordinate.setValue(coordinate);
100      if (!CField::has(coordinate))
101        ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)",
102               << "Coordinate field whose id " << coordinate << "does not exist "
103               << "Please define one");
104      auxInputs.push_back(coordinate);
105    }
106   
107    if (!this->coordinate_dst.isEmpty())
108    {
109      StdString coordinate = this->coordinate_dst.getValue();
110      if (!CField::has(coordinate))
111        ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)",
112               << "Coordinate field whose id " << coordinate << "does not exist "
113               << "Please define one");
114      auxInputs.push_back(coordinate);
115    }
116
117    return auxInputs;
118  }
119}
Note: See TracBrowser for help on using the repository browser.