source: XIOS/trunk/src/node/distribution_client.hpp @ 562

Last change on this file since 562 was 554, checked in by mhnguyen, 9 years ago

Changing interface of tests to make sure global index begins at zero (0)

+) In all tests, ibegin, jbegin starts at zero (0), so there are some minor changes in field_glo
+) Improve a littel bit class design

Test
+) On Curie,
+) All test passed and results are the same as before

File size: 3.7 KB
Line 
1/*!
2   \file distribution_client.hpp
3   \author Ha NGUYEN
4   \since 13 Jan 2015
5   \date 09 Feb 2015
6
7   \brief Index distribution on client side.
8 */
9#ifndef __XIOS_DISTRIBUTIONCLIENT_HPP__
10#define __XIOS_DISTRIBUTIONCLIENT_HPP__
11
12#include <distribution.hpp>
13#include "axis.hpp"
14#include "domain.hpp"
15#include "grid.hpp"
16
17namespace xios {
18
19class CGrid;
20class CDomain;
21class CAxis;
22
23/*!
24  \class CDistributionClient
25  This class bases on the knowledge of distribution on client side (decided by users)
26to calculate the global index of its local data.
27*/
28class CDistributionClient : public CDistribution
29{
30  public:
31    /** Default constructor */
32    CDistributionClient(int rank, int dims, CArray<size_t,1>* globalIndex = 0);
33    CDistributionClient(int rank, CGrid* grid);
34
35    /** Default destructor */
36    virtual ~CDistributionClient();
37
38    virtual const CArray<int,1>& getLocalDataIndexOnClient() const;
39    std::vector<int> getNGlob() { return nGlob_; }
40
41  protected:
42    void createGlobalIndex();
43    void readDistributionInfo(CGrid* grid);
44    void readDistributionInfo(const std::vector<CDomain*>& domList,
45                              const std::vector<CAxis*>& axisList,
46                              const CArray<bool,1>& axisDomainOrder,
47                              const CArray<bool,3>& gridMask);
48
49  private:
50    //! Create local index of a domain
51    void createLocalDomainDataIndex();
52
53    //! Create local index of an axis
54    void createLocalAxisDataIndex();
55
56    inline int getDomainIndex(const int& dataIIndex, const int& dataJIndex,
57                              const int& dataIBegin, const int& dataJBegin,
58                              const int& dataDim, const int& ni, int& j);
59    inline int getAxisIndex(const int& dataIndex, const int& dataBegin, const int& ni);
60
61  private:
62    //!< LocalData index on client
63    CArray<int,1>* localDataIndex_;
64
65  private:
66    /*! Domains and axis are considered elements.
67     * A grid composed of 1 domain and 1 axis has 2 elements */
68    int numElement_;
69    CArray<bool,1> axisDomainOrder_; //!< Order of axis and domain of a grid
70
71    std::vector<int> nLocal_; //!< Local size of each dimension (ni, nj, etc, ...)
72    std::vector<int> nGlob_; //!< Global size of each dimension (e.x: ni_glo, nj_glo, etc, ...)
73    std::vector<int> nBeginLocal_;//!< Begin index of each dimension (e.x: for domain, it's always 0, for axis, it's zoom_begin, ...)
74    std::vector<int> nBeginGlobal_; //!< Begin index of each dimension (e.x: ibegin, jbegin, ...)
75    std::vector<int> nZoomBegin_; //!< Begin index of zoom of each dimension
76    std::vector<int> nZoomEnd_; //!< End index of zoom of each dimension
77
78    // Data_n_index of domain or axis (For now, axis uses its size as data_n_index
79    std::vector<int> dataNIndex_; //!< Data_n_index in case of domain
80    std::vector<int> dataDims_; //!< Data_dim, domain can have data_dim == 1 or 2
81    std::vector<int> dataBegin_; //!< Data begin (data_ibegin, data_jbegin, etc)
82    std::vector<CArray<int,1> > dataIndex_; //!< Data index
83
84    std::vector<CArray<bool,2> > domainMasks_; //!< Domain mask
85    std::vector<CArray<bool,1> > axisMasks_; //!< Axis mask
86
87    // Just suppose that grid mask has 3 dimension. Need change
88    CArray<bool,3> gridMask_; // TODO: more general grid mask
89
90    std::vector<std::vector<int> > localDomainIndex_;
91    std::vector<std::vector<int> > localAxisIndex_;
92    std::vector<int> indexMap_; //!< Mapping element index to dimension index
93
94    // The correct index of a domain has true value, the ghost one has false value
95    std::vector<std::vector<bool> > indexDomainData_;
96    std::vector<std::vector<bool> > indexAxisData_;
97
98  private:
99    CDistributionClient(const CDistributionClient& distClient); //! Not implement
100};
101
102} // namespace xios
103#endif // __XIOS_DISTRIBUTIONCLIENT_HPP__
Note: See TracBrowser for help on using the repository browser.