[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] | 21 | namespace 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, |
---|
| 51 | EVENT_ID_AREA, EVENT_ID_MASK, |
---|
[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 | |
---|
[219] | 74 | /// Vérifications /// |
---|
| 75 | void checkAttributes(void); |
---|
[509] | 76 | void checkAttributesOnClient(); |
---|
[657] | 77 | void checkAttributesOnClientAfterTransformation(); |
---|
[676] | 78 | void checkEligibilityForCompressedOutput(void); |
---|
| 79 | |
---|
[509] | 80 | void sendCheckedAttributes(); |
---|
| 81 | |
---|
[631] | 82 | bool hasTransformation(); |
---|
| 83 | void solveInheritanceTransformation(); |
---|
| 84 | TransMapTypes getAllTransformations(); |
---|
[687] | 85 | void redistribute(int nbLocalDomain); |
---|
[823] | 86 | void duplicateTransformation(CDomain*); |
---|
[836] | 87 | CTransformation<CDomain>* addTransformation(ETranformationType transType, const StdString& id=""); |
---|
[631] | 88 | |
---|
[1158] | 89 | public: |
---|
| 90 | const std::set<StdString> & getRelFiles(void) const; |
---|
[219] | 91 | bool IsWritten(const StdString & filename) const; |
---|
[676] | 92 | bool isWrittenCompressed(const StdString& filename) const; |
---|
[1144] | 93 | |
---|
[1249] | 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); |
---|
[676] | 98 | |
---|
[1236] | 99 | std::map<int, StdSize> getAttributesBufferSize(CContextClient* client); |
---|
[731] | 100 | |
---|
[219] | 101 | bool isEmpty(void) const; |
---|
[594] | 102 | bool isDistributed(void) const; |
---|
[1025] | 103 | bool isCompressible(void) const; |
---|
| 104 | |
---|
[1158] | 105 | std::vector<int> getNbGlob(); |
---|
| 106 | bool isEqual(CDomain* domain); |
---|
[1236] | 107 | |
---|
| 108 | static bool dispatchEvent(CEventServer& event); |
---|
| 109 | |
---|
[676] | 110 | public: |
---|
[219] | 111 | /// Mutateur /// |
---|
| 112 | void addRelFile(const StdString & filename); |
---|
[1236] | 113 | void addRelFileCompressed(const StdString& filename); |
---|
| 114 | |
---|
[1129] | 115 | void computeWrittenIndex(); |
---|
[1249] | 116 | void computeWrittenCompressedIndex(MPI_Comm); |
---|
[821] | 117 | |
---|
| 118 | void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, |
---|
[809] | 119 | CArray<double,1>& lon_g, CArray<double,1>& lat_g); |
---|
[821] | 120 | |
---|
| 121 | void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat, |
---|
[809] | 122 | CArray<double,2>& boundsLon, CArray<double,2>& boundsLat); |
---|
[1158] | 123 | |
---|
| 124 | void fillInLonLat(); |
---|
| 125 | bool distributionAttributesHaveValue() const; |
---|
[611] | 126 | |
---|
[1215] | 127 | size_t getGlobalWrittenSize() ; |
---|
[219] | 128 | /// Destructeur /// |
---|
| 129 | virtual ~CDomain(void); |
---|
| 130 | |
---|
| 131 | /// Accesseurs statiques /// |
---|
| 132 | static StdString GetName(void); |
---|
| 133 | static StdString GetDefName(void); |
---|
[509] | 134 | |
---|
[1236] | 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 | |
---|
[1249] | 142 | CArray<size_t,1> localIndexToWriteOnServer; |
---|
[1236] | 143 | |
---|
[893] | 144 | CArray<bool, 1> localMask; |
---|
[384] | 145 | bool isCurvilinear ; |
---|
[449] | 146 | bool hasBounds ; |
---|
[611] | 147 | bool hasArea; |
---|
[665] | 148 | bool hasLonLat; |
---|
[953] | 149 | bool hasPole ; |
---|
| 150 | |
---|
[1291] | 151 | void computeLocalMask(void) ; |
---|
[631] | 152 | private: |
---|
[667] | 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(); |
---|
[821] | 164 | void checkZoom(void); |
---|
[667] | 165 | |
---|
[1025] | 166 | void setTransformations(const TransMapTypes&); |
---|
[1158] | 167 | void computeNGlobDomain(); |
---|
[1025] | 168 | void sendAttributes(); |
---|
[665] | 169 | void sendIndex(); |
---|
[1025] | 170 | void sendDistributionAttributes(); |
---|
| 171 | void sendMask(); |
---|
[665] | 172 | void sendArea(); |
---|
[1236] | 173 | void sendLonLat(); |
---|
[1025] | 174 | void sendDataIndex(); |
---|
[1129] | 175 | void convertLonLatValue(); |
---|
[1158] | 176 | void fillInRectilinearLonLat(); |
---|
| 177 | void fillInCurvilinearLonLat(); |
---|
| 178 | void fillInUnstructuredLonLat(); |
---|
[1236] | 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 | |
---|
[1025] | 199 | private: |
---|
[1099] | 200 | bool doZoomByIndex_; |
---|
[1129] | 201 | bool isChecked, computedWrittenIndex_; |
---|
[676] | 202 | std::set<StdString> relFiles, relFilesCompressed; |
---|
[551] | 203 | bool isClientChecked; // Verify whether all attributes of domain on the client side are good |
---|
[657] | 204 | bool isClientAfterTransformationChecked; |
---|
[1236] | 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 |
---|
[1025] | 207 | |
---|
[1236] | 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 |
---|
[676] | 210 | std::vector<int> indexesToWrite; |
---|
[1236] | 211 | std::vector<int> recvClientRanks_; |
---|
[1249] | 212 | std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; |
---|
| 213 | std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer; |
---|
[1236] | 214 | std::map<CContextClient*, std::map<int,size_t> > connectedDataSize_; |
---|
| 215 | std::map<CContextClient*, std::vector<int> > connectedServerRank_; |
---|
| 216 | |
---|
[676] | 217 | //! True if and only if the data defined on the domain can be outputted in a compressed way |
---|
| 218 | bool isCompressible_; |
---|
[715] | 219 | bool isRedistributed_; |
---|
[1025] | 220 | TransMapTypes transformationMap_; |
---|
[657] | 221 | bool isUnstructed_; |
---|
[1236] | 222 | boost::unordered_map<size_t,size_t> globalLocalIndexMap_; |
---|
[953] | 223 | |
---|
[836] | 224 | private: |
---|
| 225 | static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); |
---|
| 226 | static std::map<StdString, ETranformationType> transformationMapList_; |
---|
| 227 | static bool _dummyTransformationMapList; |
---|
| 228 | |
---|
[540] | 229 | DECLARE_REF_FUNC(Domain,domain) |
---|
| 230 | |
---|
[219] | 231 | }; // class CDomain |
---|
| 232 | |
---|
| 233 | ///-------------------------------------------------------------- |
---|
| 234 | |
---|
| 235 | // Declare/Define CDomainGroup and CDomainDefinition |
---|
| 236 | DECLARE_GROUP(CDomain); |
---|
| 237 | |
---|
| 238 | ///-------------------------------------------------------------- |
---|
| 239 | |
---|
[335] | 240 | } // namespace xios |
---|
[219] | 241 | |
---|
[878] | 242 | #endif //__XIOS_CDomain__ |
---|