source: XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/grid_algorithm_generic.cpp @ 2007

Last change on this file since 2007 was 2007, checked in by ymipsl, 3 years ago
  • fix some problem in transformation
  • implement new temporal splitting transformation

YM

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.2 KB
Line 
1#include "grid_algorithm_generic.hpp"
2#include "grid_elements.hpp"
3#include "grid_local_view.hpp"
4#include "grid.hpp"
5#include "algo_types.hpp"
6#include "context.hpp"
7#include "transform_filter.hpp"
8
9namespace xios
10{
11
12  CGridAlgorithmGeneric::CGridAlgorithmGeneric(CGrid* gridSrc, CGrid* gridDst, int pos,  CGenericAlgorithmTransformation* algo)
13  : CGridAlgorithm(algo), gridSrc_(gridSrc), gridDst_(gridDst), pos_(pos)
14  {
15    computeAlgorithm() ;
16  }
17
18  void CGridAlgorithmGeneric::computeAlgorithm(void)
19  {
20    CGridLocalElements* gridSrcElements = gridSrc_->getGridLocalElements() ;
21    CGridLocalElements* gridDstElements = gridDst_->getGridLocalElements() ;
22   
23    CGridLocalView* srcView = gridSrcElements->getView(CElementView::WORKFLOW) ;
24    CGridLocalView* dstView = gridDstElements->getView(CElementView::WORKFLOW) ;
25    MPI_Comm comm = CContext::getCurrent()->getIntraComm() ;
26    int commSize = CContext::getCurrent()->getIntraCommSize() ;
27    int commRank = CContext::getCurrent()->getIntraCommRank() ;
28   
29    auto& elements =  gridSrcElements->getElements() ;
30    int nElements = elements.size() ;
31    vector<CLocalElement*> remoteElements(nElements) ;
32    vector<CLocalView*> remoteViews(nElements) ;
33    for(int i=0;i<nElements;i++)
34    {
35      if (i==pos_) remoteElements[i] = algorithm_->getRecvElement() ;
36      else
37      { 
38        CArray<size_t,1> globalIndexView ;
39        srcView->getView(i)->getGlobalIndexView(globalIndexView) ;
40        remoteElements[i] = new CLocalElement(commRank, srcView->getView(i)->getGlobalSize(),globalIndexView) ;
41        remoteElements[i]->addFullView() ;
42        if (i>pos_) dimBefore_ *= srcView->getView(i)->getSize() ;
43        else dimAfter_ *= srcView->getView(i)->getSize() ;
44         
45      }
46      remoteViews[i] = remoteElements[i] -> getView(CElementView::FULL);
47    }
48
49    gridTransformConnector_ = new CGridTransformConnector(srcView->getViews(), remoteViews, comm ) ;
50 
51  }
52
53  void CGridAlgorithmGeneric::apply(const CArray<double,1>& dataIn, CArray<double,1>& dataOut)
54  {
55    CArray<double,1> dataOutTmp ;
56    gridTransformConnector_->transfer(dataIn, dataOutTmp) ;
57    algorithm_->apply(dimBefore_, dimAfter_, dataOutTmp, dataOut) ;
58  }
59
60 
61
62}
Note: See TracBrowser for help on using the repository browser.