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

Last change on this file since 501 was 501, checked in by ymipsl, 10 years ago

Add licence copyright to all file ond directory src using the command :
svn propset -R copyright -F header_licence src

XIOS is now officialy under CeCILL licence

YM

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 5.8 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#include "array_new.hpp"
12#include "attribute_array.hpp"
13
14namespace xios {
15   
16   /// ////////////////////// Déclarations ////////////////////// ///
17
18   class CGridGroup;
19   class CGridAttributes;
20   class CGrid;
21
22   ///--------------------------------------------------------------
23
24   // Declare/Define CGridAttribute
25   BEGIN_DECLARE_ATTRIBUTE_MAP(CGrid)
26#  include "grid_attribute.conf"
27   END_DECLARE_ATTRIBUTE_MAP(CGrid)
28
29   ///--------------------------------------------------------------
30
31   class CGrid
32      : public CObjectTemplate<CGrid>
33      , public CGridAttributes
34   {
35         /// typedef ///
36         typedef CObjectTemplate<CGrid>   SuperClass;
37         typedef CGridAttributes SuperClassAttribute;
38
39      public :
40
41         typedef CGridAttributes RelAttributes;
42         typedef CGridGroup      RelGroup;
43
44         enum EEventId
45         {
46           EVENT_ID_INDEX
47         } ;
48         
49         /// Constructeurs ///
50         CGrid(void);
51         explicit CGrid(const StdString & id);
52         CGrid(const CGrid & grid);       // Not implemented yet.
53         CGrid(const CGrid * const grid); // Not implemented yet.
54
55         /// Traitements ///
56         void solveReference(void);
57
58 //        virtual void toBinary  (StdOStream & os) const;
59//         virtual void fromBinary(StdIStream & is);
60
61         /// Tests ///
62         bool hasAxis(void) const;
63
64      public :
65
66         /// Accesseurs ///
67         const std::deque< CArray<int, 1>* > & getStoreIndex(void) const;
68         const std::deque< CArray<int, 1>* > & getOutIIndex(void)  const;
69         const std::deque< CArray<int, 1>* > & getOutJIndex(void)  const;
70         const std::deque< CArray<int, 1>* > & getOutLIndex(void)  const;
71
72         const CAxis*   getRelAxis  (void) const;
73         const CDomain* getRelDomain(void) const;
74
75         StdSize getDimension(void) const;
76         
77//         StdSize getLocalSize(void) const;
78//         StdSize getGlobalSize(void) const;
79         StdSize  getDataSize(void) const;
80//         std::vector<StdSize> getLocalShape(void) const;
81//         std::vector<StdSize> getGlobalShape(void) const;
82
83         /// Entrées-sorties de champs ///
84         template <int n>
85            void inputField(const CArray<double,n>& field, CArray<double,1>& stored) const;
86           
87         void inputFieldServer(const std::deque< CArray<double, 1>* > storedClient,
88                               CArray<double, 1>&  storedServer) const;
89
90         void outputField(int rank, const CArray<double,1>& stored,  CArray<double,3>& field)  ;
91         void outputField(int rank, const CArray<double,1>& stored,  CArray<double,2>& field)  ;
92         void outputField(int rank, const CArray<double,1>& stored,  CArray<double,1>& field)  ; 
93   
94         /// Destructeur ///
95         virtual ~CGrid(void);
96
97      public :
98
99         /// Accesseurs statiques ///
100         static StdString GetName(void);
101         static StdString GetDefName(void);
102         
103         static ENodeType GetType(void);
104
105         /// Instanciateurs Statiques ///
106         static CGrid* createGrid(CDomain* domain);
107         static CGrid* createGrid(CDomain* domain, CAxis* axis);
108
109      public :
110
111         /// Entrées-sorties de champs (interne) ///
112         void storeField_arr(const double * const data, CArray<double,1>& stored) const;
113
114         /// Traitements protégés ///
115         void computeIndexServer(void);
116         void computeIndex(void);
117         void solveDomainRef(void);
118         void solveAxisRef(void);
119
120         static bool dispatchEvent(CEventServer& event) ;
121         void outputFieldToServer(CArray<double,1>& fieldIn, int rank, CArray<double,1>& fieldOut) ;
122         static void recvIndex(CEventServer& event) ;
123         void recvIndex(int rank, CBufferIn& buffer) ;
124         void sendIndex(void) ;
125         
126      public:
127
128         /// Propriétés privées ///
129         bool withAxis ;
130         bool isChecked;
131
132         CAxis*   axis ;
133         CDomain* domain ;
134
135         std::deque< CArray<int, 1>* > storeIndex ;
136         std::deque< CArray<int, 1>* > out_i_index ;
137         std::deque< CArray<int, 1>* > out_j_index ;
138         std::deque< CArray<int, 1>* > out_l_index ;
139         
140        CArray<int, 1>  storeIndex_client ;
141        CArray<int, 1>  out_i_client ;
142        CArray<int, 1>  out_j_client ;
143        CArray<int, 1>  out_l_client ;
144         
145         map<int, CArray<int, 1>* >  storeIndex_toSrv ;
146         map<int,int> nbSenders ;
147//         std::deque<ARRAY(int, 1)> out_i_toSrv ;
148//         std::deque<ARRAY(int, 1)> out_j_toSrv ;
149//         std::deque<ARRAY(int, 1)> out_l_toSrv ;
150         
151         map<int, CArray<int, 1>* > out_i_fromClient ;
152         map<int, CArray<int, 1>* > out_j_fromClient ;
153         map<int, CArray<int, 1>* > out_l_fromClient ;
154         void checkMask(void) ;
155   }; // class CGrid
156
157   ///--------------------------------------------------------------
158
159   template <int n>
160      void CGrid::inputField(const CArray<double,n>& field, CArray<double,1>& stored) const
161   {
162      if (this->getDataSize() != field.numElements())
163         ERROR("void CGrid::inputField(const  CArray<double,n>& field, CArray<double,1>& stored) const",
164                << "[ Awaiting size of the data = " << this->getDataSize()       << ", "
165                << "Received data size = "      << field.numElements() << " ] "
166                << "The array of data has not the good size !")
167      this->storeField_arr(field.dataFirst(), stored) ;
168   }
169
170   ///--------------------------------------------------------------
171
172   // Declare/Define CGridGroup and CGridDefinition
173   DECLARE_GROUP(CGrid);
174
175   ///--------------------------------------------------------------
176
177} // namespace xios
178
179#endif // __XMLIO_CGrid__
Note: See TracBrowser for help on using the repository browser.