#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 } ; 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; int getNumberWrittenIndexes(MPI_Comm writtenCom); int getTotalNumberWrittenIndexes(MPI_Comm writtenCom); int getOffsetWrittenIndexes(MPI_Comm writtenCom); CArray& getCompressedIndexToWriteOnServer(MPI_Comm writtenCom); std::map getAttributesBufferSize(CContextClient* client); bool isEmpty(void) const; bool isDistributed(void) const; bool isCompressible(void) const; std::vector getNbGlob(); bool isEqual(CDomain* domain); static bool dispatchEvent(CEventServer& event); public: /// Mutateur /// void addRelFile(const StdString & filename); void addRelFileCompressed(const StdString& filename); void computeWrittenIndex(); void computeWrittenCompressedIndex(MPI_Comm); void AllgatherRectilinearLonLat(CArray& lon, CArray& lat, CArray& lon_g, CArray& lat_g); void fillInRectilinearBoundLonLat(CArray& lon, CArray& lat, CArray& boundsLon, CArray& boundsLat); void fillInLonLat(); bool distributionAttributesHaveValue() const; size_t getGlobalWrittenSize() ; /// Destructeur /// virtual ~CDomain(void); /// Accesseurs statiques /// static StdString GetName(void); static StdString GetDefName(void); static ENodeType GetType(void); public: CArray lonvalue, latvalue; CArray bounds_lonvalue, bounds_latvalue; CArray areavalue; CArray localIndexToWriteOnServer; CArray localMask; bool isCurvilinear ; bool hasBounds ; bool hasArea; bool hasLonLat; bool hasPole ; void computeLocalMask(void) ; 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 setTransformations(const TransMapTypes&); void computeNGlobDomain(); void sendAttributes(); void sendIndex(); void sendDistributionAttributes(); void sendMask(); void sendArea(); void sendLonLat(); void sendDataIndex(); void convertLonLatValue(); void fillInRectilinearLonLat(); void fillInCurvilinearLonLat(); void fillInUnstructuredLonLat(); static void recvDistributionAttributes(CEventServer& event); static void recvIndex(CEventServer& event); static void recvIndexZoom(CEventServer& event); static void recvMask(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 recvMask(std::map& rankBuffers); void recvLon(std::map& rankBuffers); void recvLat(std::map& rankBuffers); void recvArea(std::map& rankBuffers); void recvDataIndex(std::map& rankBuffers); void completeLonLatClient(void); void computeConnectedClients(); private: 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 > indGlob_; std::map > nbSenders; // Mapping of number of communicating client to a server std::map > > indSrv_; // 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_; std::map numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; std::map > compressedIndexToWriteOnServer; std::map > connectedDataSize_; std::map > connectedServerRank_; //! 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_; 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__