source: XIOS/dev/dev_oa/src/node/domain.hpp @ 2338

Last change on this file since 2338 was 2034, checked in by oabramkina, 3 years ago

Adding a possibility of tiled and non-tiled sent on the same domain.

  • 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: 9.9 KB
RevLine 
[591]1#ifndef __XIOS_CDomain__
2#define __XIOS_CDomain__
[219]3
[591]4/// XIOS headers ///
5#include "xios_spl.hpp"
[219]6#include "group_factory.hpp"
7
8#include "declare_group.hpp"
[540]9#include "declare_ref_func.hpp"
[300]10#include "event_client.hpp"
11#include "event_server.hpp"
12#include "buffer_in.hpp"
[369]13#include "array_new.hpp"
14#include "attribute_array.hpp"
[449]15#include "attribute_enum.hpp"
[631]16#include "transformation.hpp"
17#include "transformation_enum.hpp"
[1025]18#include "server_distribution_description.hpp"
[878]19#include "mesh.hpp"
20
[335]21namespace xios {
[509]22
[219]23   /// ////////////////////// Déclarations ////////////////////// ///
24
25   class CDomainGroup;
26   class CDomainAttributes;
27   class CDomain;
[878]28   class CFile;
[219]29
30   ///--------------------------------------------------------------
31
32   // Declare/Define CDomainAttribute
33   BEGIN_DECLARE_ATTRIBUTE_MAP(CDomain)
34#  include "domain_attribute.conf"
[775]35#  include "domain_attribute_private.conf"
[219]36   END_DECLARE_ATTRIBUTE_MAP(CDomain)
37
38   ///--------------------------------------------------------------
39
40   class CDomain
41      : public CObjectTemplate<CDomain>
42      , public CDomainAttributes
43   {
[1158]44     /// typedef ///
45     typedef CObjectTemplate<CDomain>   SuperClass;
46     typedef CDomainAttributes SuperClassAttribute;
47     public:
[300]48         enum EEventId
49         {
[1025]50           EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT, 
[1637]51           EVENT_ID_AREA,
[1236]52           EVENT_ID_DATA_INDEX, EVENT_ID_SERVER_ATTRIBUT
[300]53         } ;
[509]54
[676]55      public:
[219]56
57         typedef CDomainAttributes RelAttributes;
58         typedef CDomainGroup      RelGroup;
[631]59         typedef CTransformation<CDomain>::TransformationMapTypes TransMapTypes;
[219]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
[622]67         static CDomain* createDomain();
[878]68         
69         CMesh* mesh;
[924]70         void assignMesh(const StdString, const int);
[878]71       
[631]72         virtual void parse(xml::CXMLNode & node);
73
[1345]74         void setContextClient(CContextClient* contextClient);
75
[219]76         /// Vérifications ///
77         void checkAttributes(void);
[509]78         void checkAttributesOnClient();
[657]79         void checkAttributesOnClientAfterTransformation();
[676]80         void checkEligibilityForCompressedOutput(void);
81
[509]82         void sendCheckedAttributes();
83
[631]84         bool hasTransformation();
85         void solveInheritanceTransformation();
86         TransMapTypes getAllTransformations();
[687]87         void redistribute(int nbLocalDomain);
[823]88         void duplicateTransformation(CDomain*);
[836]89         CTransformation<CDomain>* addTransformation(ETranformationType transType, const StdString& id="");
[631]90
[1158]91      public:
92         const std::set<StdString> & getRelFiles(void) const;
[219]93         bool IsWritten(const StdString & filename) const;
[676]94         bool isWrittenCompressed(const StdString& filename) const;
[1144]95         
[1639]96         int getNumberWrittenIndexes(MPI_Comm writtenCom);
97         int getTotalNumberWrittenIndexes(MPI_Comm writtenCom);
98         int getOffsetWrittenIndexes(MPI_Comm writtenCom);
99         CArray<int,1>& getCompressedIndexToWriteOnServer(MPI_Comm writtenCom);
[676]100
[1330]101         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, bool bufferForWriting = false);
[731]102
[219]103         bool isEmpty(void) const;
[594]104         bool isDistributed(void) const;
[1025]105         bool isCompressible(void) const; 
[1966]106
107         bool isTiled(void) const;
[2034]108         bool isTiledOnly(void) const;
[1966]109         int getTileId(int i, int j) const;
110         int getTileDataISize(int tileId) const;
111         int getTileDataJSize(int tileId) const;
[2034]112         void computeCompressionTiled(CArray<int,1>& dataIndexI, CArray<int,1>& dataIndexJ,
113                                      CArray<int,1>& infoIndexI, CArray<int,1>& infoIndexJ);
[1966]114
[1158]115         std::vector<int> getNbGlob();
116         bool isEqual(CDomain* domain);
[1236]117
118         static bool dispatchEvent(CEventServer& event);
119
[676]120      public:
[219]121         /// Mutateur ///
122         void addRelFile(const StdString & filename);
[1236]123         void addRelFileCompressed(const StdString& filename);           
124         
[1129]125         void computeWrittenIndex();
[1639]126         void computeWrittenCompressedIndex(MPI_Comm);
[821]127
128         void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat,
[809]129                                         CArray<double,1>& lon_g, CArray<double,1>& lat_g);
[821]130
131         void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat,
[809]132                                           CArray<double,2>& boundsLon, CArray<double,2>& boundsLat);
[1158]133         
134         void fillInLonLat();
135         bool distributionAttributesHaveValue() const;
[611]136
[1215]137         size_t getGlobalWrittenSize() ;
[219]138         /// Destructeur ///
139         virtual ~CDomain(void);
140
141         /// Accesseurs statiques ///
142         static StdString GetName(void);
143         static StdString GetDefName(void);
[509]144
[1236]145         static ENodeType GetType(void);       
146
147      public:
148         CArray<double, 1> lonvalue, latvalue;
149         CArray<double, 2> bounds_lonvalue, bounds_latvalue;
150         CArray<double, 1> areavalue;
151
[1637]152         CArray<int,1> localIndexToWriteOnServer;
[1236]153
[1311]154         CArray<bool, 1> domainMask; // mask_1d, mask_2d -> domainMask
155         CArray<bool, 1> localMask; // domainMask + indexing
[384]156         bool isCurvilinear ;
[449]157         bool hasBounds ;
[611]158         bool hasArea;
[665]159         bool hasLonLat;
[953]160         bool hasPole ;
[1578]161         bool hasLatInReadFile_ ; // specify if latitude is defined on read file, so it can be read later when grid distribution will be defined
162         bool hasBoundsLatInReadFile_ ; // specify if latitude boundarues are defined on read file, so it can be read later when grid distribution will be defined
163         bool hasLonInReadFile_ ; // specify if longitude is defined on read file, so it can be read later when grid distribution will be defined
164         bool hasBoundsLonInReadFile_ ; // specify if longitude boundaries are defined on read file, so it can be read later when grid distribution will be defined
[953]165
[1291]166         void computeLocalMask(void) ;
[631]167      private:
[667]168         void checkDomain(void);
169         void checkLocalIDomain(void);
170         void checkLocalJDomain(void);
171
172         void checkMask(void);
173         void checkDomainData(void);
174         void checkCompression(void);
175
176         void checkBounds(void);
177         void checkArea(void);
178         void checkLonLat();
[1966]179         void checkTiles();
[667]180
[1025]181         void setTransformations(const TransMapTypes&);         
[1158]182         void computeNGlobDomain();
[1025]183         void sendAttributes();
[665]184         void sendIndex();
[1025]185         void sendDistributionAttributes();
[665]186         void sendArea();
[1236]187         void sendLonLat();         
[1025]188         void sendDataIndex();
[1129]189         void convertLonLatValue();
[1158]190         void fillInRectilinearLonLat();
191         void fillInCurvilinearLonLat();
192         void fillInUnstructuredLonLat();
[1236]193         
194         static void recvDistributionAttributes(CEventServer& event);
195         static void recvIndex(CEventServer& event);
196         static void recvLon(CEventServer& event);
197         static void recvLat(CEventServer& event);
198         static void recvArea(CEventServer& event);
199         static void recvDataIndex(CEventServer& event);
200         void recvDistributionAttributes(CBufferIn& buffer);                 
201         void recvIndex(std::map<int, CBufferIn*>& rankBuffers);         
202         void recvLon(std::map<int, CBufferIn*>& rankBuffers);
203         void recvLat(std::map<int, CBufferIn*>& rankBuffers);
204         void recvArea(std::map<int, CBufferIn*>& rankBuffers);         
205         void recvDataIndex(std::map<int, CBufferIn*>& rankBuffers);
206
207         void completeLonLatClient(void); 
208         void computeConnectedClients();   
209
[1025]210       private:         
[1345]211
212/** Clients that have to send a domain. There can be multiple clients in case of secondary server, otherwise only one client. */
[1353]213         std::list<CContextClient*> clients;
214         std::set<CContextClient*> clientsSet;
[1345]215
[1129]216         bool isChecked, computedWrittenIndex_;
[676]217         std::set<StdString> relFiles, relFilesCompressed;
[551]218         bool isClientChecked; // Verify whether all attributes of domain on the client side are good
[657]219         bool isClientAfterTransformationChecked;
[1236]220         std::map<int, CArray<int,1> > indGlob_;
[1337]221         std::map<int, map<int,int> > nbSenders; // Mapping of number of communicating client to a server
[1025]222
[1337]223/** Global index of each client sent to server: map<serverSize, map<serverRank, indexes>> */
[1542]224         std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_;
[1236]225         // std::map<CContextClient*, std::map<int, vector<int> > > indWrittenSrv_; // Global written index of each client sent to server
[676]226         std::vector<int> indexesToWrite;
[1236]227         std::vector<int> recvClientRanks_;
[1249]228         std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
229         std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer;     
[1337]230         std::map<int, std::map<int,size_t> > connectedDataSize_;
231         std::map<int, std::vector<int> > connectedServerRank_;
[1236]232
[2034]233//! True if and only if the data defined on the domain can be outputted in a compressed way
[676]234         bool isCompressible_;
[715]235         bool isRedistributed_;
[1025]236         TransMapTypes transformationMap_;         
[657]237         bool isUnstructed_;
[1542]238         std::unordered_map<size_t,size_t> globalLocalIndexMap_;
[1966]239
[2034]240//! True if tiled data is defined on the domain
[1966]241         bool isTiled_;
[2034]242//! True if ONLY tiled data is defined on the domain
243         bool isTiledOnly_;
[1966]244
[836]245       private:
246         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
247         static std::map<StdString, ETranformationType> transformationMapList_;
248         static bool _dummyTransformationMapList;
249
[540]250         DECLARE_REF_FUNC(Domain,domain)
251
[219]252   }; // class CDomain
253
254   ///--------------------------------------------------------------
255
256   // Declare/Define CDomainGroup and CDomainDefinition
257   DECLARE_GROUP(CDomain);
258
259   ///--------------------------------------------------------------
260
[335]261} // namespace xios
[219]262
[878]263#endif //__XIOS_CDomain__
Note: See TracBrowser for help on using the repository browser.