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

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

Dev: adding exception handling.

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

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 3.1 KB
Line 
1/*!
2   \file axis_algorithm_temporal_splitting.cpp
3
4   \brief Algorithm to split scalar into  axis by temporal accumulation
5 */
6#include "axis_algorithm_temporal_splitting.hpp"
7#include "temporal_splitting.hpp"
8#include "axis.hpp"
9#include "scalar.hpp"
10#include "grid.hpp"
11#include "grid_transformation_factory_impl.hpp"
12
13namespace xios {
14CGenericAlgorithmTransformation* CAxisAlgorithmTemporalSplitting::create(CGrid* gridDst, CGrid* gridSrc,
15                                                                     CTransformation<CAxis>* transformation,
16                                                                     int elementPositionInGrid,
17                                                                     std::map<int, int>& elementPositionInGridSrc2ScalarPosition,
18                                                                     std::map<int, int>& elementPositionInGridSrc2AxisPosition,
19                                                                     std::map<int, int>& elementPositionInGridSrc2DomainPosition,
20                                                                     std::map<int, int>& elementPositionInGridDst2ScalarPosition,
21                                                                     std::map<int, int>& elementPositionInGridDst2AxisPosition,
22                                                                     std::map<int, int>& elementPositionInGridDst2DomainPosition)
23TRY
24{
25  std::vector<CAxis*> axisListDestP = gridDst->getAxis();
26  std::vector<CScalar*> scalarListSrcP = gridSrc->getScalars();
27
28  CTemporalSplitting* temporalSplitting = dynamic_cast<CTemporalSplitting*> (transformation);
29  int axisDstIndex = elementPositionInGridDst2AxisPosition[elementPositionInGrid];
30  int scalarSrcIndex = elementPositionInGridSrc2ScalarPosition[elementPositionInGrid];
31
32  return (new CAxisAlgorithmTemporalSplitting(axisListDestP[axisDstIndex], scalarListSrcP[scalarSrcIndex], temporalSplitting));
33}
34CATCH
35
36bool CAxisAlgorithmTemporalSplitting::registerTrans()
37TRY
38{
39  CGridTransformationFactory<CAxis>::registerTransformation(TRANS_TEMPORAL_SPLITTING, create);
40}
41CATCH
42
43CAxisAlgorithmTemporalSplitting::CAxisAlgorithmTemporalSplitting(CAxis* axisDestination, CScalar* scalarSource, CTemporalSplitting* algo)
44 : CAxisAlgorithmTransformation(axisDestination, scalarSource)
45{
46
47}
48
49
50CAxisAlgorithmTemporalSplitting::~CAxisAlgorithmTemporalSplitting()
51{
52}
53
54void CAxisAlgorithmTemporalSplitting::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs)
55TRY
56{
57  this->transformationMapping_.resize(1);
58  this->transformationWeight_.resize(1);
59
60  TransformationIndexMap& transMap = this->transformationMapping_[0];
61  TransformationWeightMap& transWeight = this->transformationWeight_[0];
62
63  CArray<int,1>& axisDstIndex = axisDest_->index;
64
65  int nbAxisIdx = axisDstIndex.numElements();
66  for (int idxAxis = 0; idxAxis < nbAxisIdx; ++idxAxis)
67  {
68    int globalAxisIdx = axisDstIndex(idxAxis);
69    if (idxAxis==0)
70    {
71      transMap[globalAxisIdx].resize(1);
72      transWeight[globalAxisIdx].resize(1);
73      transMap[globalAxisIdx][0] = 0 ;
74      transWeight[globalAxisIdx][0] = 1.0 ;
75    }
76  }
77}
78CATCH
79
80}
Note: See TracBrowser for help on using the repository browser.