source: XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.hpp @ 1301

Last change on this file since 1301 was 1291, checked in by ymipsl, 7 years ago

Fix in expand domain transformation. Local mask was not computed.

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: 8.7 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#include "server_distribution_description.hpp"
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     public:
48         enum EEventId
49         {
50           EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT, 
51           EVENT_ID_AREA, EVENT_ID_MASK,
52           EVENT_ID_DATA_INDEX, EVENT_ID_SERVER_ATTRIBUT
53         } ;
54
55      public:
56
57         typedef CDomainAttributes RelAttributes;
58         typedef CDomainGroup      RelGroup;
59         typedef CTransformation<CDomain>::TransformationMapTypes TransMapTypes;
60
61         /// Constructeurs ///
62         CDomain(void);
63         explicit CDomain(const StdString & id);
64         CDomain(const CDomain & domain);       // Not implemented yet.
65         CDomain(const CDomain * const domain); // Not implemented yet.
66
67         static CDomain* createDomain();
68         
69         CMesh* mesh;
70         void assignMesh(const StdString, const int);
71       
72         virtual void parse(xml::CXMLNode & node);
73
74         /// Vérifications ///
75         void checkAttributes(void);
76         void checkAttributesOnClient();
77         void checkAttributesOnClientAfterTransformation();
78         void checkEligibilityForCompressedOutput(void);
79
80         void sendCheckedAttributes();
81
82         bool hasTransformation();
83         void solveInheritanceTransformation();
84         TransMapTypes getAllTransformations();
85         void redistribute(int nbLocalDomain);
86         void duplicateTransformation(CDomain*);
87         CTransformation<CDomain>* addTransformation(ETranformationType transType, const StdString& id="");
88
89      public:
90         const std::set<StdString> & getRelFiles(void) const;
91         bool IsWritten(const StdString & filename) const;
92         bool isWrittenCompressed(const StdString& filename) const;
93         
94         int getNumberWrittenIndexes(MPI_Comm writtenCom);
95         int getTotalNumberWrittenIndexes(MPI_Comm writtenCom);
96         int getOffsetWrittenIndexes(MPI_Comm writtenCom);
97         CArray<int,1>& getCompressedIndexToWriteOnServer(MPI_Comm writtenCom);
98
99         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client);
100
101         bool isEmpty(void) const;
102         bool isDistributed(void) const;
103         bool isCompressible(void) const; 
104 
105         std::vector<int> getNbGlob();
106         bool isEqual(CDomain* domain);
107
108         static bool dispatchEvent(CEventServer& event);
109
110      public:
111         /// Mutateur ///
112         void addRelFile(const StdString & filename);
113         void addRelFileCompressed(const StdString& filename);           
114         
115         void computeWrittenIndex();
116         void computeWrittenCompressedIndex(MPI_Comm);
117
118         void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat,
119                                         CArray<double,1>& lon_g, CArray<double,1>& lat_g);
120
121         void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat,
122                                           CArray<double,2>& boundsLon, CArray<double,2>& boundsLat);
123         
124         void fillInLonLat();
125         bool distributionAttributesHaveValue() const;
126
127         size_t getGlobalWrittenSize() ;
128         /// Destructeur ///
129         virtual ~CDomain(void);
130
131         /// Accesseurs statiques ///
132         static StdString GetName(void);
133         static StdString GetDefName(void);
134
135         static ENodeType GetType(void);       
136
137      public:
138         CArray<double, 1> lonvalue, latvalue;
139         CArray<double, 2> bounds_lonvalue, bounds_latvalue;
140         CArray<double, 1> areavalue;
141
142         CArray<size_t,1> localIndexToWriteOnServer;         
143
144         CArray<bool, 1> localMask;
145         bool isCurvilinear ;
146         bool hasBounds ;
147         bool hasArea;
148         bool hasLonLat;
149         bool hasPole ;
150
151         void computeLocalMask(void) ;
152      private:
153         void checkDomain(void);
154         void checkLocalIDomain(void);
155         void checkLocalJDomain(void);
156
157         void checkMask(void);
158         void checkDomainData(void);
159         void checkCompression(void);
160
161         void checkBounds(void);
162         void checkArea(void);
163         void checkLonLat();
164         void checkZoom(void);
165
166         void setTransformations(const TransMapTypes&);         
167         void computeNGlobDomain();
168         void sendAttributes();
169         void sendIndex();
170         void sendDistributionAttributes();
171         void sendMask();
172         void sendArea();
173         void sendLonLat();         
174         void sendDataIndex();
175         void convertLonLatValue();
176         void fillInRectilinearLonLat();
177         void fillInCurvilinearLonLat();
178         void fillInUnstructuredLonLat();
179         
180         static void recvDistributionAttributes(CEventServer& event);
181         static void recvIndex(CEventServer& event);
182         static void recvIndexZoom(CEventServer& event);
183         static void recvMask(CEventServer& event);         
184         static void recvLon(CEventServer& event);
185         static void recvLat(CEventServer& event);
186         static void recvArea(CEventServer& event);
187         static void recvDataIndex(CEventServer& event);
188         void recvDistributionAttributes(CBufferIn& buffer);                 
189         void recvIndex(std::map<int, CBufferIn*>& rankBuffers);         
190         void recvMask(std::map<int, CBufferIn*>& rankBuffers);
191         void recvLon(std::map<int, CBufferIn*>& rankBuffers);
192         void recvLat(std::map<int, CBufferIn*>& rankBuffers);
193         void recvArea(std::map<int, CBufferIn*>& rankBuffers);         
194         void recvDataIndex(std::map<int, CBufferIn*>& rankBuffers);
195
196         void completeLonLatClient(void); 
197         void computeConnectedClients();   
198
199       private:         
200         bool doZoomByIndex_;
201         bool isChecked, computedWrittenIndex_;
202         std::set<StdString> relFiles, relFilesCompressed;
203         bool isClientChecked; // Verify whether all attributes of domain on the client side are good
204         bool isClientAfterTransformationChecked;
205         std::map<int, CArray<int,1> > indGlob_;
206         std::map<CContextClient*, map<int,int> > nbSenders; // Mapping of number of communicating client to a server
207
208         std::map<CContextClient*, boost::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server         
209         // std::map<CContextClient*, std::map<int, vector<int> > > indWrittenSrv_; // Global written index of each client sent to server
210         std::vector<int> indexesToWrite;
211         std::vector<int> recvClientRanks_;
212         std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
213         std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer;     
214         std::map<CContextClient*, std::map<int,size_t> > connectedDataSize_;
215         std::map<CContextClient*, std::vector<int> > connectedServerRank_;
216
217         //! True if and only if the data defined on the domain can be outputted in a compressed way
218         bool isCompressible_;
219         bool isRedistributed_;
220         TransMapTypes transformationMap_;         
221         bool isUnstructed_;
222         boost::unordered_map<size_t,size_t> globalLocalIndexMap_;
223       
224       private:
225         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
226         static std::map<StdString, ETranformationType> transformationMapList_;
227         static bool _dummyTransformationMapList;
228
229         DECLARE_REF_FUNC(Domain,domain)
230
231   }; // class CDomain
232
233   ///--------------------------------------------------------------
234
235   // Declare/Define CDomainGroup and CDomainDefinition
236   DECLARE_GROUP(CDomain);
237
238   ///--------------------------------------------------------------
239
240} // namespace xios
241
242#endif //__XIOS_CDomain__
Note: See TracBrowser for help on using the repository browser.