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

Last change on this file since 2250 was 1314, checked in by ymipsl, 6 years ago

Add 2 new spatial transformations :

  • reduce_scalar_to_scalar : global reduction between scalar
  • duplicate_scalar_to_axis : a scalar value is duplicated on each level of the axis.

YM

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1#include "reduce_axis_to_axis.hpp"
2#include "type.hpp"
3#include "axis.hpp"
4
5namespace xios {
6
7  /// ////////////////////// Définitions ////////////////////// ///
8
9  CReduceAxisToAxis::CReduceAxisToAxis(void)
10    : CObjectTemplate<CReduceAxisToAxis>(), CReduceAxisToAxisAttributes(), CTransformation<CAxis>()
11  { /* Ne rien faire de plus */ }
12
13  CReduceAxisToAxis::CReduceAxisToAxis(const StdString & id)
14    : CObjectTemplate<CReduceAxisToAxis>(id), CReduceAxisToAxisAttributes(), CTransformation<CAxis>()
15  { /* Ne rien faire de plus */ }
16
17  CReduceAxisToAxis::~CReduceAxisToAxis(void)
18  {}
19
20  CTransformation<CAxis>* CReduceAxisToAxis::create(const StdString& id, xml::CXMLNode* node)
21  {
22    CReduceAxisToAxis* reduceAxis = CReduceAxisToAxisGroup::get("reduce_axis_to_axis_definition")->createChild(id);
23    if (node) reduceAxis->parse(*node);
24    return static_cast<CTransformation<CAxis>*>(reduceAxis);
25  }
26
27  bool CReduceAxisToAxis::registerTrans()
28  {
29    return registerTransformation(TRANS_REDUCE_AXIS_TO_AXIS, CReduceAxisToAxis::create);
30  }
31
32  bool CReduceAxisToAxis::_dummyRegistered = CReduceAxisToAxis::registerTrans();
33
34  //----------------------------------------------------------------
35
36  StdString CReduceAxisToAxis::GetName(void)    { return StdString("reduce_axis_to_axis"); }
37  StdString CReduceAxisToAxis::GetDefName(void) { return StdString("reduce_axis_to_axis"); }
38  ENodeType CReduceAxisToAxis::GetType(void)    { return eReduceAxisToAxis; }
39
40  void CReduceAxisToAxis::checkValid(CAxis* axisDst, CAxis* axisSrc)
41  {
42 
43    if (this->operation.isEmpty())
44      ERROR("CReduceAxisToAxis::checkValid(CAxis* axisDst, CAxis* axisSrc)",
45             << "An operation must be defined."
46             << "Axis source " <<axisSrc->getId() << std::endl
47             << "Axis destination " << axisDst->getId());
48
49
50    if (axisDst->n_glo != axisSrc->n_glo)
51       ERROR("CReduceAxisToAxis::checkValid(CAxis* axisDst, CAxis* axisSrc)",
52            << "both axis should have same n_glo"
53            << "Axis source " <<axisSrc->getId() << " has n_glo " << axisSrc->n_glo << std::endl
54            << "Axis destination " << axisDst->getId() << " has n_glo " << axisDst->n_glo);
55   
56  }
57
58}
Note: See TracBrowser for help on using the repository browser.