source: XMLIO_V2/dev/common/src/node/grid.hpp @ 300

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

nouvelle version de developpement de xios

  • nouvelle interface fortran
  • recodage complet de la couche de communication
  • et bien d'autres choses...

YM

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