source: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/distributed_view.cpp @ 2230

Last change on this file since 2230 was 1936, checked in by ymipsl, 4 years ago

XIOS coupling branch :
Blitz array resizeAndPreserve crash when size=0 => use resize instead

YM

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#include "element_view.hpp"
2#include "element.hpp"
3#include "distributed_view.hpp"
4
5namespace xios
6{
7
8  CDistributedView::CDistributedView(CDistributedElement* parent, CElementView::type, const std::map<int,CArray<int,1>>& indexView) 
9                                    : globalIndex_(parent->globalIndex_), globalSize_(parent->globalSize_), localSize_(parent->localSize_) 
10  {
11    for(auto& index : indexView) 
12    {
13      index_[index.first].reference(index.second.copy()) ;
14      size_[index.first] = index.second.numElements() ;
15    }
16  }
17
18  CDistributedView::CDistributedView(CDistributedElement* parent, CElementView::type, const std::map<int,CArray<bool,1>>& maskView) 
19                                    : globalIndex_(parent->globalIndex_), globalSize_(parent->globalSize_), localSize_(parent->localSize_) 
20  {
21    for(auto& it : maskView) 
22    {
23      int rank = it.first ;
24      auto& mask = it.second ;
25      int size = mask.numElements() ;
26      auto& index = index_[rank] ; 
27      index.resize(size) ;
28      int pos=0 ;
29      for(int i=0 ; i < size ; i++)
30        if (mask(i)) { index(pos) = i ; pos++ ; }
31      if (pos==0) index.resize(pos) ;
32      else index.resizeAndPreserve(pos) ;
33      size_[rank] = pos ;
34    }
35  } 
36}
Note: See TracBrowser for help on using the repository browser.