source: XIOS/trunk/src/node/grid.hpp @ 345

Last change on this file since 345 was 345, checked in by ymipsl, 12 years ago

removed "tree" namespace

YM

File size: 6.0 KB
Line 
1#ifndef __XMLIO_CGrid__
2#define __XMLIO_CGrid__
3
4/// xios headers ///
5#include "xmlioserver_spl.hpp"
6#include "group_factory.hpp"
7
8#include "declare_group.hpp"
9#include "domain.hpp"
10#include "axis.hpp"
11
12namespace xios {
13   
14   /// ////////////////////// Déclarations ////////////////////// ///
15
16   class CGridGroup;
17   class CGridAttributes;
18   class CGrid;
19
20   ///--------------------------------------------------------------
21
22   // Declare/Define CGridAttribute
23   BEGIN_DECLARE_ATTRIBUTE_MAP(CGrid)
24#  include "grid_attribute.conf"
25   END_DECLARE_ATTRIBUTE_MAP(CGrid)
26
27   ///--------------------------------------------------------------
28
29   class CGrid
30      : public CObjectTemplate<CGrid>
31      , public CGridAttributes
32   {
33         /// typedef ///
34         typedef CObjectTemplate<CGrid>   SuperClass;
35         typedef CGridAttributes SuperClassAttribute;
36
37      public :
38
39         typedef CGridAttributes RelAttributes;
40         typedef CGridGroup      RelGroup;
41
42         enum EEventId
43         {
44           EVENT_ID_INDEX
45         } ;
46         
47         /// Constructeurs ///
48         CGrid(void);
49         explicit CGrid(const StdString & id);
50         CGrid(const CGrid & grid);       // Not implemented yet.
51         CGrid(const CGrid * const grid); // Not implemented yet.
52
53         /// Traitements ///
54         void solveReference(void);
55
56         virtual void toBinary  (StdOStream & os) const;
57         virtual void fromBinary(StdIStream & is);
58
59         /// Tests ///
60         bool hasAxis(void) const;
61
62      public :
63
64         /// Accesseurs ///
65         const std::deque<ARRAY(int, 1)> & getStoreIndex(void) const;
66         const std::deque<ARRAY(int, 1)> & getOutIIndex(void)  const;
67         const std::deque<ARRAY(int, 1)> & getOutJIndex(void)  const;
68         const std::deque<ARRAY(int, 1)> & getOutLIndex(void)  const;
69
70         const boost::shared_ptr<CAxis>   getRelAxis  (void) const;
71         const boost::shared_ptr<CDomain> getRelDomain(void) const;
72
73         StdSize getDimension(void) const;
74         
75         StdSize getLocalSize(void) const;
76         StdSize getGlobalSize(void) const;
77         StdSize  getDataSize(void) const;
78         std::vector<StdSize> getLocalShape(void) const;
79         std::vector<StdSize> getGlobalShape(void) const;
80
81         /// Entrées-sorties de champs ///
82         template <StdSize n>
83            void inputField(const ARRAY(double, n) field, ARRAY(double, 1) stored) const;
84           
85         void inputFieldServer(const std::deque<ARRAY(double, 1)> storedClient,
86                                                ARRAY(double, 1)  storedServer) const;
87/*
88         template <StdSize n>
89            void outputField(const ARRAY(double, 1) stored,  ARRAY(double, n) field) const;
90*/
91         void outputField(int rank, const ARRAY(double, 1) stored,  ARRAY(double, 3) field)  ;
92         void outputField(int rank, const ARRAY(double, 1) stored,  ARRAY(double, 2) field)  ;
93         void outputField(int rank,const ARRAY(double, 1) stored,  ARRAY(double, 1) field)  ; 
94   
95         /// Destructeur ///
96         virtual ~CGrid(void);
97
98      public :
99
100         /// Accesseurs statiques ///
101         static StdString GetName(void);
102         static StdString GetDefName(void);
103         
104         static ENodeType GetType(void);
105
106         /// Instanciateurs Statiques ///
107         static boost::shared_ptr<CGrid>
108            CreateGrid(boost::shared_ptr<CDomain> domain);
109         static boost::shared_ptr<CGrid>
110            CreateGrid(boost::shared_ptr<CDomain> domain, boost::shared_ptr<CAxis> axis);
111
112      public :
113
114         /// Entrées-sorties de champs (interne) ///
115         void storeField_arr(const double * const data, ARRAY(double, 1) stored) const;
116
117         /// Traitements protégés ///
118         void computeIndexServer(void);
119         void computeIndex(void);
120         void solveDomainRef(void);
121         void solveAxisRef(void);
122
123         static bool dispatchEvent(CEventServer& event) ;
124         void outputFieldToServer(ARRAY(double, 1) fieldIn, int rank, ARRAY(double, 1) fieldOut) ;
125         static void recvIndex(CEventServer& event) ;
126         void recvIndex(int rank, CBufferIn& buffer) ;
127         void sendIndex(void) ;
128         
129      public:
130
131         /// Propriétés privées ///
132         bool withAxis ;
133         bool isChecked;
134
135         boost::shared_ptr<CAxis>   axis ;
136         boost::shared_ptr<CDomain> domain ;
137
138         std::deque<ARRAY(int, 1)> storeIndex ;
139         std::deque<ARRAY(int, 1)> out_i_index ;
140         std::deque<ARRAY(int, 1)> out_j_index ;
141         std::deque<ARRAY(int, 1)> out_l_index ;
142         ARRAY(int, 1) storeIndex_client ;
143         ARRAY(int, 1) out_i_client ;
144         ARRAY(int, 1) out_j_client ;
145         ARRAY(int, 1) out_l_client ;
146         
147         map<int,ARRAY(int, 1)>  storeIndex_toSrv ;
148         map<int,int> nbSenders ;
149//         std::deque<ARRAY(int, 1)> out_i_toSrv ;
150//         std::deque<ARRAY(int, 1)> out_j_toSrv ;
151//         std::deque<ARRAY(int, 1)> out_l_toSrv ;
152         
153         map<int,ARRAY(int, 1)> out_i_fromClient ;
154         map<int,ARRAY(int, 1)> out_j_fromClient ;
155         map<int,ARRAY(int, 1)> out_l_fromClient ;
156         
157   }; // class CGrid
158
159   ///--------------------------------------------------------------
160
161   template <StdSize n>
162      void CGrid::inputField(const  ARRAY(double, n) field, ARRAY(double, 1) stored) const
163   {
164      if (this->getDataSize() != field->num_elements())
165         ERROR("CGrid::inputField(const  ARRAY(double, n) field, ARRAY(double, 1) stored)",
166                << "[ Taille des données attendue = " << this->getDataSize()       << ", "
167                << "Taille des données reçue = "      << field->num_elements() << " ] "
168                << "Le tableau de données n'a pas la bonne taille !") ;
169      this->storeField_arr(field->data(), stored) ;
170   }
171
172   ///--------------------------------------------------------------
173
174   // Declare/Define CGridGroup and CGridDefinition
175   DECLARE_GROUP(CGrid);
176
177   ///--------------------------------------------------------------
178
179} // namespace xios
180
181#endif // __XMLIO_CGrid__
Note: See TracBrowser for help on using the repository browser.