source: XIOS/dev/dev_olga/src/node/domain.hpp @ 987

Last change on this file since 987 was 987, checked in by mhnguyen, 7 years ago

First working version.
There are more things to do with it

  • 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: 8.0 KB
Line 
1#ifndef __XIOS_CDomain__
2#define __XIOS_CDomain__
3
4/// XIOS headers ///
5#include "xios_spl.hpp"
6#include "group_factory.hpp"
7
8#include "declare_group.hpp"
9#include "declare_ref_func.hpp"
10#include "event_client.hpp"
11#include "event_server.hpp"
12#include "buffer_in.hpp"
13#include "array_new.hpp"
14#include "attribute_array.hpp"
15#include "attribute_enum.hpp"
16#include "transformation.hpp"
17#include "transformation_enum.hpp"
18
19#include "mesh.hpp"
20
21namespace xios {
22
23   /// ////////////////////// Déclarations ////////////////////// ///
24
25   class CDomainGroup;
26   class CDomainAttributes;
27   class CDomain;
28   class CFile;
29
30   ///--------------------------------------------------------------
31
32   // Declare/Define CDomainAttribute
33   BEGIN_DECLARE_ATTRIBUTE_MAP(CDomain)
34#  include "domain_attribute.conf"
35#  include "domain_attribute_private.conf"
36   END_DECLARE_ATTRIBUTE_MAP(CDomain)
37
38   ///--------------------------------------------------------------
39
40   class CDomain
41      : public CObjectTemplate<CDomain>
42      , public CDomainAttributes
43   {
44               /// typedef ///
45         typedef CObjectTemplate<CDomain>   SuperClass;
46         typedef CDomainAttributes SuperClassAttribute;
47         
48      public :
49         enum EEventId
50         {
51           EVENT_ID_SERVER_ATTRIBUT, EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT, EVENT_ID_AREA
52         } ;
53
54
55
56      public:
57
58         typedef CDomainAttributes RelAttributes;
59         typedef CDomainGroup      RelGroup;
60         typedef CTransformation<CDomain>::TransformationMapTypes TransMapTypes;
61
62         /// Constructeurs ///
63         CDomain(void);
64         explicit CDomain(const StdString & id);
65         CDomain(const CDomain & domain);       // Not implemented yet.
66         CDomain(const CDomain * const domain); // Not implemented yet.
67
68         static CDomain* createDomain();
69         
70         CMesh* mesh;
71         void assignMesh(const StdString, const int);
72       
73         virtual void parse(xml::CXMLNode & node);
74
75         /// Vérifications ///
76         void checkAttributes(void);
77
78         void checkAttributesOnClient();
79         void checkAttributesOnClientAfterTransformation();
80
81         void checkEligibilityForCompressedOutput(void);
82
83         void sendCheckedAttributes();
84
85         bool hasTransformation();
86         void solveInheritanceTransformation();
87         TransMapTypes getAllTransformations();
88         void redistribute(int nbLocalDomain);
89         void duplicateTransformation(CDomain*);
90         CTransformation<CDomain>* addTransformation(ETranformationType transType, const StdString& id="");
91
92      public:
93         const std::set<StdString> & getRelFiles(void) const;
94         bool IsWritten(const StdString & filename) const;
95         bool isWrittenCompressed(const StdString& filename) const;
96
97         const std::vector<int>& getIndexesToWrite(void) const;
98         int getNumberWrittenIndexes() const;
99         int getTotalNumberWrittenIndexes() const;
100         int getOffsetWrittenIndexes() const;
101
102         std::map<int, StdSize> getAttributesBufferSize();
103
104         bool isEmpty(void) const;
105         bool isDistributed(void) const;
106         bool isCompressible(void) const;
107
108         int ni_srv,ibegin_srv,iend_srv ;
109         int zoom_ni_srv,zoom_ibegin_srv,zoom_iend_srv ;
110
111         int nj_srv,jbegin_srv,jend_srv ;
112         int zoom_nj_srv,zoom_jbegin_srv,zoom_jend_srv ;
113
114         CArray<double, 1> lonvalue_srv, latvalue_srv ;
115         CArray<double, 2> bounds_lon_srv, bounds_lat_srv ;
116         CArray<double, 1> lonvalue_client, latvalue_client;
117         CArray<double, 2> bounds_lon_client, bounds_lat_client;
118         CArray<double, 1> area_srv;
119
120        vector<int> connectedServer ; // list of connected server
121        vector<int> nbSenders ; // for each communication with a server, number of communicating client
122        vector<int> nbDataSrv ; // size of data to send to each server
123        vector< vector<int> > i_indSrv ; // for each server, i global index to send
124        vector< vector<int> > j_indSrv ; // for each server, j global index to send
125
126      public:
127         /// Mutateur ///
128         void addRelFile(const StdString & filename);
129         void addRelFileCompressed(const StdString& filename);
130         void completeLonLatClient(void);
131         void sendServerAttribut(void) ;
132         void sendLonLatArea(void);
133         void computeConnectedServer(void) ;
134
135         void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat,
136                                         CArray<double,1>& lon_g, CArray<double,1>& lat_g);
137
138         void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat,
139                                           CArray<double,2>& boundsLon, CArray<double,2>& boundsLat);
140         void fillInRectilinearLonLat();
141
142         static bool dispatchEvent(CEventServer& event);
143         static void recvServerAttribut(CEventServer& event);
144         static void recvIndex(CEventServer& event);
145         static void recvLon(CEventServer& event);
146         static void recvLat(CEventServer& event);
147         static void recvArea(CEventServer& event);
148         void recvServerAttribut(CBufferIn& buffer);
149         void recvIndex(int rank, CBufferIn& buffer);
150         void recvLon(int rank, CBufferIn& buffer);
151         void recvLat(int rank, CBufferIn& buffer);
152         void recvArea(int rank, CBufferIn& buffer);
153
154         /// Destructeur ///
155         virtual ~CDomain(void);
156
157         /// Accesseurs statiques ///
158         static StdString GetName(void);
159         static StdString GetDefName(void);
160
161         static ENodeType GetType(void);
162         const std::map<int, vector<size_t> >& getIndexServer() const;
163         CArray<bool, 1> localMask;
164         bool isCurvilinear ;
165         bool hasBounds ;
166         bool hasArea;
167         bool hasLonLat;
168         bool hasPole ;
169
170      private:
171         void checkDomain(void);
172         void checkLocalIDomain(void);
173         void checkLocalJDomain(void);
174
175         void checkMask(void);
176         void checkDomainData(void);
177         void checkCompression(void);
178
179         void checkBounds(void);
180         void checkArea(void);
181         void checkLonLat();
182         void checkZoom(void);
183         void computeLocalMask(void) ;
184
185         void checkTransformations();
186         void setTransformations(const TransMapTypes&);
187         void computeNGlobDomain();
188
189         void sendIndex();
190         void sendArea();
191         void sendLonLat();
192
193       private:
194         bool isChecked;
195         std::set<StdString> relFiles, relFilesCompressed;
196         bool isClientChecked; // Verify whether all attributes of domain on the client side are good
197         bool isClientAfterTransformationChecked;
198         std::map<int, CArray<int,1> > indiSrv, indjSrv;
199         std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server
200         std::map<int, vector<size_t> > indSrv_; // Global index of each client sent to server
201         std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server
202         std::vector<int> indexesToWrite;
203         int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
204         std::vector<int> connectedServerRank_;
205         bool isDistributed_;
206         //! True if and only if the data defined on the domain can be outputted in a compressed way
207         bool isCompressible_;
208         bool isRedistributed_;
209         TransMapTypes transformationMap_;
210         std::vector<int> nGlobDomain_;
211         bool isUnstructed_;
212       
213       private:
214         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
215         static std::map<StdString, ETranformationType> transformationMapList_;
216         static bool _dummyTransformationMapList;
217
218         DECLARE_REF_FUNC(Domain,domain)
219
220   }; // class CDomain
221
222   ///--------------------------------------------------------------
223
224   // Declare/Define CDomainGroup and CDomainDefinition
225   DECLARE_GROUP(CDomain);
226
227   ///--------------------------------------------------------------
228
229} // namespace xios
230
231#endif //__XIOS_CDomain__
Note: See TracBrowser for help on using the repository browser.