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

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

Fix conflict between for domain mask_1d and mask_2d when inheritance is done after transformation. Now class attribute "domainMask" is fill either by mask_1d or mask_2d and will be used instead of mask_1d in code.
This is a temporary fix which will solve later by reconstructing a cleanear grid graph.

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.8 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> domainMask; // mask_1d, mask_2d -> domainMask
145         CArray<bool, 1> localMask; // domainMask + indexing
146         bool isCurvilinear ;
147         bool hasBounds ;
148         bool hasArea;
149         bool hasLonLat;
150         bool hasPole ;
151
152         void computeLocalMask(void) ;
153      private:
154         void checkDomain(void);
155         void checkLocalIDomain(void);
156         void checkLocalJDomain(void);
157
158         void checkMask(void);
159         void checkDomainData(void);
160         void checkCompression(void);
161
162         void checkBounds(void);
163         void checkArea(void);
164         void checkLonLat();
165         void checkZoom(void);
166
167         void setTransformations(const TransMapTypes&);         
168         void computeNGlobDomain();
169         void sendAttributes();
170         void sendIndex();
171         void sendDistributionAttributes();
172         void sendMask();
173         void sendArea();
174         void sendLonLat();         
175         void sendDataIndex();
176         void convertLonLatValue();
177         void fillInRectilinearLonLat();
178         void fillInCurvilinearLonLat();
179         void fillInUnstructuredLonLat();
180         
181         static void recvDistributionAttributes(CEventServer& event);
182         static void recvIndex(CEventServer& event);
183         static void recvIndexZoom(CEventServer& event);
184         static void recvMask(CEventServer& event);         
185         static void recvLon(CEventServer& event);
186         static void recvLat(CEventServer& event);
187         static void recvArea(CEventServer& event);
188         static void recvDataIndex(CEventServer& event);
189         void recvDistributionAttributes(CBufferIn& buffer);                 
190         void recvIndex(std::map<int, CBufferIn*>& rankBuffers);         
191         void recvMask(std::map<int, CBufferIn*>& rankBuffers);
192         void recvLon(std::map<int, CBufferIn*>& rankBuffers);
193         void recvLat(std::map<int, CBufferIn*>& rankBuffers);
194         void recvArea(std::map<int, CBufferIn*>& rankBuffers);         
195         void recvDataIndex(std::map<int, CBufferIn*>& rankBuffers);
196
197         void completeLonLatClient(void); 
198         void computeConnectedClients();   
199
200       private:         
201         bool doZoomByIndex_;
202         bool isChecked, computedWrittenIndex_;
203         std::set<StdString> relFiles, relFilesCompressed;
204         bool isClientChecked; // Verify whether all attributes of domain on the client side are good
205         bool isClientAfterTransformationChecked;
206         std::map<int, CArray<int,1> > indGlob_;
207         std::map<CContextClient*, map<int,int> > nbSenders; // Mapping of number of communicating client to a server
208
209         std::map<CContextClient*, boost::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server         
210         // std::map<CContextClient*, std::map<int, vector<int> > > indWrittenSrv_; // Global written index of each client sent to server
211         std::vector<int> indexesToWrite;
212         std::vector<int> recvClientRanks_;
213         std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
214         std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer;     
215         std::map<CContextClient*, std::map<int,size_t> > connectedDataSize_;
216         std::map<CContextClient*, std::vector<int> > connectedServerRank_;
217
218         //! True if and only if the data defined on the domain can be outputted in a compressed way
219         bool isCompressible_;
220         bool isRedistributed_;
221         TransMapTypes transformationMap_;         
222         bool isUnstructed_;
223         boost::unordered_map<size_t,size_t> globalLocalIndexMap_;
224       
225       private:
226         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
227         static std::map<StdString, ETranformationType> transformationMapList_;
228         static bool _dummyTransformationMapList;
229
230         DECLARE_REF_FUNC(Domain,domain)
231
232   }; // class CDomain
233
234   ///--------------------------------------------------------------
235
236   // Declare/Define CDomainGroup and CDomainDefinition
237   DECLARE_GROUP(CDomain);
238
239   ///--------------------------------------------------------------
240
241} // namespace xios
242
243#endif //__XIOS_CDomain__
Note: See TracBrowser for help on using the repository browser.