#ifndef __XIOS_CDomain__ #define __XIOS_CDomain__ /// XIOS headers /// #include "xios_spl.hpp" #include "group_factory.hpp" #include "declare_group.hpp" #include "declare_ref_func.hpp" #include "event_client.hpp" #include "event_server.hpp" #include "buffer_in.hpp" #include "array_new.hpp" #include "attribute_array.hpp" #include "attribute_enum.hpp" #include "transformation.hpp" #include "transformation_enum.hpp" #include "server_distribution_description.hpp" #include "mesh.hpp" namespace xios { /// ////////////////////// DĂ©clarations ////////////////////// /// class CDomainGroup; class CDomainAttributes; class CDomain; class CFile; ///-------------------------------------------------------------- // Declare/Define CDomainAttribute BEGIN_DECLARE_ATTRIBUTE_MAP(CDomain) # include "domain_attribute.conf" # include "domain_attribute_private.conf" END_DECLARE_ATTRIBUTE_MAP(CDomain) ///-------------------------------------------------------------- class CDomain : public CObjectTemplate , public CDomainAttributes { /// typedef /// typedef CObjectTemplate SuperClass; typedef CDomainAttributes SuperClassAttribute; public : enum EEventId { EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT, EVENT_ID_AREA, EVENT_ID_MASK, EVENT_ID_DATA_INDEX, EVENT_ID_SERVER_ATTRIBUT, EVENT_ID_INDEX_ZOOM } ; public: typedef CDomainAttributes RelAttributes; typedef CDomainGroup RelGroup; typedef CTransformation::TransformationMapTypes TransMapTypes; /// Constructeurs /// CDomain(void); explicit CDomain(const StdString & id); CDomain(const CDomain & domain); // Not implemented yet. CDomain(const CDomain * const domain); // Not implemented yet. static CDomain* createDomain(); CMesh* mesh; void assignMesh(const StdString, const int); virtual void parse(xml::CXMLNode & node); /// VĂ©rifications /// void checkAttributes(void); void checkAttributesOnClient(); void checkAttributesOnClientAfterTransformation(); void checkEligibilityForCompressedOutput(void); void sendCheckedAttributes(); bool hasTransformation(); void solveInheritanceTransformation(); TransMapTypes getAllTransformations(); void redistribute(int nbLocalDomain); void duplicateTransformation(CDomain*); CTransformation* addTransformation(ETranformationType transType, const StdString& id=""); public: const std::set & getRelFiles(void) const; bool IsWritten(const StdString & filename) const; bool isWrittenCompressed(const StdString& filename) const; const std::vector& getIndexesToWrite(void) const; int getNumberWrittenIndexes() const; int getTotalNumberWrittenIndexes() const; int getOffsetWrittenIndexes() const; const std::vector& getStartWriteIndex() const; const std::vector& getCountWriteIndex() const; const std::vector& getLocalWriteSize() const; const std::vector& getGlobalWriteSize() const; std::map getAttributesBufferSize(); CArray localIndexToWriteOnServer; bool isEmpty(void) const; bool isDistributed(void) const; bool isCompressible(void) const; CArray lonvalue, latvalue; CArray bounds_lonvalue, bounds_latvalue; CArray areavalue; vector connectedServer ; // list of connected server vector nbSenders ; // for each communication with a server, number of communicating client vector nbDataSrv ; // size of data to send to each server vector< vector > i_indSrv ; // for each server, i global index to send vector< vector > j_indSrv ; // for each server, j global index to send public: /// Mutateur /// void addRelFile(const StdString & filename); void addRelFileCompressed(const StdString& filename); void completeLonLatClient(void); void computeConnectedClients(); void computeWrittenIndex(); void AllgatherRectilinearLonLat(CArray& lon, CArray& lat, CArray& lon_g, CArray& lat_g); void fillInRectilinearBoundLonLat(CArray& lon, CArray& lat, CArray& boundsLon, CArray& boundsLat); void fillInRectilinearLonLat(); static bool dispatchEvent(CEventServer& event); static void recvDistributionAttributes(CEventServer& event); static void recvIndex(CEventServer& event); static void recvIndexZoom(CEventServer& event); static void recvMask(CEventServer& event); static void recvZoom(CEventServer& event); static void recvLon(CEventServer& event); static void recvLat(CEventServer& event); static void recvArea(CEventServer& event); static void recvDataIndex(CEventServer& event); void recvDistributionAttributes(CBufferIn& buffer); void recvIndex(std::map& rankBuffers); void recvIndexZoom(std::map& rankBuffers); void recvMask(std::map& rankBuffers); void recvLon(std::map& rankBuffers); void recvLat(std::map& rankBuffers); void recvArea(std::map& rankBuffers); void recvDataIndex(std::map& rankBuffers); /// Destructeur /// virtual ~CDomain(void); /// Accesseurs statiques /// static StdString GetName(void); static StdString GetDefName(void); static ENodeType GetType(void); const boost::unordered_map >& getIndexServer() const; CArray localMask; bool isCurvilinear ; bool hasBounds ; bool hasArea; bool hasLonLat; bool hasPole ; private: void checkDomain(void); void checkLocalIDomain(void); void checkLocalJDomain(void); void checkMask(void); void checkDomainData(void); void checkCompression(void); void checkBounds(void); void checkArea(void); void checkLonLat(); void checkZoom(void); void computeLocalMask(void) ; void setTransformations(const TransMapTypes&); void sendAttributes(); void sendIndex(); void sendDistributionAttributes(); void sendMask(); void sendArea(); void sendLonLat(); void sendIndexZoom(); void sendDataIndex(); void convertLonLatValue(); private: std::vector start_write_index_; std::vector count_write_index_; std::vector local_write_size_; std::vector global_write_size_; bool doZoomByIndex_; bool isChecked, computedWrittenIndex_; std::set relFiles, relFilesCompressed; bool isClientChecked; // Verify whether all attributes of domain on the client side are good bool isClientAfterTransformationChecked; std::map > indiSrv, indjSrv, indGlob_, indGlobZoom_; std::map nbConnectedClients_, nbConnectedClientsZoom_; // Mapping of number of communicating client to a server boost::unordered_map > indSrv_; // Global index of each client sent to server boost::unordered_map > indZoomSrv_; // Global index of each client sent to server std::map > indWrittenSrv_; // Global written index of each client sent to server std::vector indexesToWrite; std::vector recvClientRanks_, recvClientZoomRanks_; int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; std::vector connectedServerRank_, connectedServerZoomRank_; bool isDistributed_; //! True if and only if the data defined on the domain can be outputted in a compressed way bool isCompressible_; bool isRedistributed_; TransMapTypes transformationMap_; bool isUnstructed_; boost::unordered_map globalLocalIndexMap_, globalLocalIndexZoomMap_; private: static bool initializeTransformationMap(std::map& m); static std::map transformationMapList_; static bool _dummyTransformationMapList; DECLARE_REF_FUNC(Domain,domain) }; // class CDomain ///-------------------------------------------------------------- // Declare/Define CDomainGroup and CDomainDefinition DECLARE_GROUP(CDomain); ///-------------------------------------------------------------- } // namespace xios #endif //__XIOS_CDomain__