[219] | 1 | #include "domain.hpp" |
---|
| 2 | |
---|
[352] | 3 | #include "attribute_template.hpp" |
---|
| 4 | #include "object_template.hpp" |
---|
| 5 | #include "group_template.hpp" |
---|
[219] | 6 | |
---|
[591] | 7 | #include "xios_spl.hpp" |
---|
[300] | 8 | #include "event_client.hpp" |
---|
| 9 | #include "event_server.hpp" |
---|
| 10 | #include "buffer_in.hpp" |
---|
[352] | 11 | #include "message.hpp" |
---|
| 12 | #include "type.hpp" |
---|
| 13 | #include "context.hpp" |
---|
| 14 | #include "context_client.hpp" |
---|
[676] | 15 | #include "context_server.hpp" |
---|
[369] | 16 | #include "array_new.hpp" |
---|
[676] | 17 | #include "distribution_client.hpp" |
---|
[553] | 18 | #include "server_distribution_description.hpp" |
---|
[569] | 19 | #include "client_server_mapping_distributed.hpp" |
---|
[631] | 20 | #include "zoom_domain.hpp" |
---|
[689] | 21 | #include "interpolate_domain.hpp" |
---|
[687] | 22 | #include "generate_rectilinear_domain.hpp" |
---|
[274] | 23 | |
---|
[676] | 24 | #include <algorithm> |
---|
| 25 | |
---|
[335] | 26 | namespace xios { |
---|
[509] | 27 | |
---|
[1129] | 28 | /// ////////////////////// Dfinitions ////////////////////// /// |
---|
[219] | 29 | |
---|
| 30 | CDomain::CDomain(void) |
---|
| 31 | : CObjectTemplate<CDomain>(), CDomainAttributes() |
---|
[1129] | 32 | , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_(), connectedServerZoomRank_() |
---|
[1025] | 33 | , hasBounds(false), hasArea(false), isDistributed_(false), isCompressible_(false), isUnstructed_(false) |
---|
[665] | 34 | , isClientAfterTransformationChecked(false), hasLonLat(false) |
---|
[1099] | 35 | , isRedistributed_(false), hasPole(false), doZoomByIndex_(false) |
---|
| 36 | , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue() |
---|
[1129] | 37 | , globalLocalIndexMap_(), computedWrittenIndex_(false) |
---|
[878] | 38 | { |
---|
[924] | 39 | } |
---|
[219] | 40 | |
---|
| 41 | CDomain::CDomain(const StdString & id) |
---|
| 42 | : CObjectTemplate<CDomain>(id), CDomainAttributes() |
---|
[1129] | 43 | , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_(), connectedServerZoomRank_() |
---|
[1025] | 44 | , hasBounds(false), hasArea(false), isDistributed_(false), isCompressible_(false), isUnstructed_(false) |
---|
[665] | 45 | , isClientAfterTransformationChecked(false), hasLonLat(false) |
---|
[1099] | 46 | , isRedistributed_(false), hasPole(false), doZoomByIndex_(false) |
---|
| 47 | , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue() |
---|
[1129] | 48 | , globalLocalIndexMap_(), computedWrittenIndex_(false) |
---|
[878] | 49 | { |
---|
[924] | 50 | } |
---|
[219] | 51 | |
---|
| 52 | CDomain::~CDomain(void) |
---|
[509] | 53 | { |
---|
[219] | 54 | } |
---|
| 55 | |
---|
| 56 | ///--------------------------------------------------------------- |
---|
| 57 | |
---|
[924] | 58 | void CDomain::assignMesh(const StdString meshName, const int nvertex) |
---|
[881] | 59 | { |
---|
[924] | 60 | mesh = CMesh::getMesh(meshName, nvertex); |
---|
[881] | 61 | } |
---|
| 62 | |
---|
[622] | 63 | CDomain* CDomain::createDomain() |
---|
| 64 | { |
---|
| 65 | CDomain* domain = CDomainGroup::get("domain_definition")->createChild(); |
---|
| 66 | return domain; |
---|
| 67 | } |
---|
| 68 | |
---|
[836] | 69 | std::map<StdString, ETranformationType> CDomain::transformationMapList_ = std::map<StdString, ETranformationType>(); |
---|
| 70 | bool CDomain::_dummyTransformationMapList = CDomain::initializeTransformationMap(CDomain::transformationMapList_); |
---|
| 71 | |
---|
| 72 | bool CDomain::initializeTransformationMap(std::map<StdString, ETranformationType>& m) |
---|
| 73 | { |
---|
| 74 | m["zoom_domain"] = TRANS_ZOOM_DOMAIN; |
---|
| 75 | m["interpolate_domain"] = TRANS_INTERPOLATE_DOMAIN; |
---|
| 76 | m["generate_rectilinear_domain"] = TRANS_GENERATE_RECTILINEAR_DOMAIN; |
---|
[934] | 77 | m["compute_connectivity_domain"] = TRANS_COMPUTE_CONNECTIVITY_DOMAIN; |
---|
[935] | 78 | m["expand_domain"] = TRANS_EXPAND_DOMAIN; |
---|
[836] | 79 | } |
---|
| 80 | |
---|
[219] | 81 | const std::set<StdString> & CDomain::getRelFiles(void) const |
---|
| 82 | { |
---|
[509] | 83 | return (this->relFiles); |
---|
[219] | 84 | } |
---|
| 85 | |
---|
[895] | 86 | |
---|
[676] | 87 | const std::vector<int>& CDomain::getIndexesToWrite(void) const |
---|
| 88 | { |
---|
| 89 | return indexesToWrite; |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | /*! |
---|
| 93 | Returns the number of indexes written by each server. |
---|
| 94 | \return the number of indexes written by each server |
---|
| 95 | */ |
---|
| 96 | int CDomain::getNumberWrittenIndexes() const |
---|
| 97 | { |
---|
| 98 | return numberWrittenIndexes_; |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | /*! |
---|
| 102 | Returns the total number of indexes written by the servers. |
---|
| 103 | \return the total number of indexes written by the servers |
---|
| 104 | */ |
---|
| 105 | int CDomain::getTotalNumberWrittenIndexes() const |
---|
| 106 | { |
---|
| 107 | return totalNumberWrittenIndexes_; |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | /*! |
---|
| 111 | Returns the offset of indexes written by each server. |
---|
| 112 | \return the offset of indexes written by each server |
---|
| 113 | */ |
---|
| 114 | int CDomain::getOffsetWrittenIndexes() const |
---|
| 115 | { |
---|
| 116 | return offsetWrittenIndexes_; |
---|
| 117 | } |
---|
| 118 | |
---|
[1025] | 119 | /*! |
---|
| 120 | Returns the start of indexes written by each server. |
---|
| 121 | \return the start of indexes written by each server |
---|
| 122 | */ |
---|
| 123 | const std::vector<int>& CDomain::getStartWriteIndex() const |
---|
| 124 | { |
---|
| 125 | return start_write_index_; |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | /*! |
---|
| 129 | Returns the count of indexes written by each server. |
---|
| 130 | \return the count of indexes written by each server |
---|
| 131 | */ |
---|
| 132 | const std::vector<int>& CDomain::getCountWriteIndex() const |
---|
| 133 | { |
---|
| 134 | return count_write_index_; |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | /*! |
---|
| 138 | Returns the local data written by each server. |
---|
| 139 | */ |
---|
| 140 | const std::vector<int>& CDomain::getLocalWriteSize() const |
---|
| 141 | { |
---|
| 142 | return local_write_size_; |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | /*! |
---|
| 146 | Returns the global data written by all server. |
---|
| 147 | */ |
---|
| 148 | const std::vector<int>& CDomain::getGlobalWriteSize() const |
---|
| 149 | { |
---|
| 150 | return global_write_size_; |
---|
| 151 | } |
---|
| 152 | |
---|
[676] | 153 | //---------------------------------------------------------------- |
---|
| 154 | |
---|
[731] | 155 | /*! |
---|
| 156 | * Compute the minimum buffer size required to send the attributes to the server(s). |
---|
| 157 | * |
---|
| 158 | * \return A map associating the server rank with its minimum buffer size. |
---|
| 159 | */ |
---|
| 160 | std::map<int, StdSize> CDomain::getAttributesBufferSize() |
---|
| 161 | { |
---|
[1054] | 162 | CContext* context = CContext::getCurrent(); |
---|
| 163 | // For now the assumption is that secondary server pools consist of the same number of procs. |
---|
| 164 | // CHANGE the line below if the assumption changes. |
---|
| 165 | CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client; |
---|
[731] | 166 | |
---|
| 167 | std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(); |
---|
| 168 | |
---|
| 169 | if (client->isServerLeader()) |
---|
| 170 | { |
---|
[1025] | 171 | // size estimation for sendDistributionAttribut |
---|
[731] | 172 | size_t size = 11 * sizeof(size_t); |
---|
| 173 | |
---|
| 174 | const std::list<int>& ranks = client->getRanksServerLeader(); |
---|
| 175 | for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) |
---|
| 176 | { |
---|
| 177 | if (size > attributesSizes[*itRank]) |
---|
| 178 | attributesSizes[*itRank] = size; |
---|
| 179 | } |
---|
| 180 | } |
---|
| 181 | |
---|
[1025] | 182 | boost::unordered_map<int, vector<size_t> >::const_iterator itIndexEnd = indSrv_.end(); |
---|
[764] | 183 | std::map<int, std::vector<int> >::const_iterator itWrittenIndexEnd = indWrittenSrv_.end(); |
---|
| 184 | for (size_t k = 0; k < connectedServerRank_.size(); ++k) |
---|
[731] | 185 | { |
---|
[764] | 186 | int rank = connectedServerRank_[k]; |
---|
[1025] | 187 | boost::unordered_map<int, std::vector<size_t> >::const_iterator it = indSrv_.find(rank); |
---|
[764] | 188 | size_t idxCount = (it != itIndexEnd) ? it->second.size() : 0; |
---|
| 189 | |
---|
[731] | 190 | // size estimation for sendIndex (and sendArea which is always smaller or equal) |
---|
[764] | 191 | size_t sizeIndexEvent = 2 * sizeof(size_t) + 2 * CArray<int,1>::size(idxCount); |
---|
[731] | 192 | if (isCompressible_) |
---|
[764] | 193 | { |
---|
| 194 | std::map<int, std::vector<int> >::const_iterator itWritten = indWrittenSrv_.find(rank); |
---|
| 195 | size_t writtenIdxCount = (itWritten != itWrittenIndexEnd) ? itWritten->second.size() : 0; |
---|
| 196 | sizeIndexEvent += CArray<int,1>::size(writtenIdxCount); |
---|
| 197 | } |
---|
[731] | 198 | |
---|
| 199 | // size estimation for sendLonLat |
---|
[764] | 200 | size_t sizeLonLatEvent = CArray<double,1>::size(idxCount); |
---|
[731] | 201 | if (hasBounds) |
---|
[764] | 202 | sizeLonLatEvent += CArray<double,2>::size(nvertex * idxCount); |
---|
[731] | 203 | |
---|
| 204 | size_t size = CEventClient::headerSize + getId().size() + sizeof(size_t) + std::max(sizeIndexEvent, sizeLonLatEvent); |
---|
[764] | 205 | if (size > attributesSizes[rank]) |
---|
| 206 | attributesSizes[rank] = size; |
---|
[731] | 207 | } |
---|
| 208 | |
---|
| 209 | return attributesSizes; |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | //---------------------------------------------------------------- |
---|
| 213 | |
---|
[219] | 214 | bool CDomain::isEmpty(void) const |
---|
| 215 | { |
---|
[1025] | 216 | return ((this->zoom_i_index.isEmpty()) || (0 == this->zoom_i_index.numElements())); |
---|
| 217 | // return ((this->zoom_ni_srv == 0) || |
---|
| 218 | // (this->zoom_nj_srv == 0)); |
---|
[219] | 219 | } |
---|
| 220 | |
---|
| 221 | //---------------------------------------------------------------- |
---|
[676] | 222 | |
---|
[219] | 223 | bool CDomain::IsWritten(const StdString & filename) const |
---|
| 224 | { |
---|
| 225 | return (this->relFiles.find(filename) != this->relFiles.end()); |
---|
| 226 | } |
---|
| 227 | |
---|
[676] | 228 | bool CDomain::isWrittenCompressed(const StdString& filename) const |
---|
| 229 | { |
---|
| 230 | return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); |
---|
| 231 | } |
---|
| 232 | |
---|
[219] | 233 | //---------------------------------------------------------------- |
---|
[676] | 234 | |
---|
[594] | 235 | bool CDomain::isDistributed(void) const |
---|
| 236 | { |
---|
| 237 | return isDistributed_; |
---|
| 238 | } |
---|
| 239 | |
---|
| 240 | //---------------------------------------------------------------- |
---|
[676] | 241 | |
---|
| 242 | /*! |
---|
| 243 | * Test whether the data defined on the domain can be outputted in a compressed way. |
---|
[679] | 244 | * |
---|
[676] | 245 | * \return true if and only if a mask was defined for this domain |
---|
| 246 | */ |
---|
| 247 | bool CDomain::isCompressible(void) const |
---|
| 248 | { |
---|
| 249 | return isCompressible_; |
---|
| 250 | } |
---|
| 251 | |
---|
[219] | 252 | void CDomain::addRelFile(const StdString & filename) |
---|
| 253 | { |
---|
| 254 | this->relFiles.insert(filename); |
---|
| 255 | } |
---|
[895] | 256 | |
---|
[676] | 257 | void CDomain::addRelFileCompressed(const StdString& filename) |
---|
| 258 | { |
---|
| 259 | this->relFilesCompressed.insert(filename); |
---|
| 260 | } |
---|
[219] | 261 | |
---|
| 262 | StdString CDomain::GetName(void) { return (StdString("domain")); } |
---|
| 263 | StdString CDomain::GetDefName(void){ return (CDomain::GetName()); } |
---|
| 264 | ENodeType CDomain::GetType(void) { return (eDomain); } |
---|
| 265 | |
---|
| 266 | //---------------------------------------------------------------- |
---|
| 267 | |
---|
[687] | 268 | /*! |
---|
| 269 | Redistribute RECTILINEAR domain with a number of local domains. |
---|
| 270 | All attributes ni,nj,ibegin,jbegin (if defined) will be rewritten |
---|
| 271 | The optional attributes lonvalue, latvalue will be added. Because this function only serves (for now) |
---|
| 272 | for interpolation from unstructured domain to rectilinear one, range of latvalue is 0-360 and lonvalue is -90 - +90 |
---|
| 273 | \param [in] nbLocalDomain number of local domain on the domain destination |
---|
| 274 | */ |
---|
| 275 | void CDomain::redistribute(int nbLocalDomain) |
---|
| 276 | { |
---|
[715] | 277 | if (this->isRedistributed_) return; |
---|
[727] | 278 | |
---|
[783] | 279 | this->isRedistributed_ = true; |
---|
| 280 | CContext* context = CContext::getCurrent(); |
---|
[1054] | 281 | // For now the assumption is that secondary server pools consist of the same number of procs. |
---|
| 282 | // CHANGE the line below if the assumption changes. |
---|
| 283 | CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client; |
---|
[783] | 284 | int rankClient = client->clientRank; |
---|
| 285 | int rankOnDomain = rankClient%nbLocalDomain; |
---|
[687] | 286 | |
---|
[783] | 287 | if (ni_glo.isEmpty() || ni_glo <= 0 ) |
---|
| 288 | { |
---|
| 289 | ERROR("CDomain::redistribute(int nbLocalDomain)", |
---|
| 290 | << "[ Id = " << this->getId() << " ] " |
---|
| 291 | << "The global domain is badly defined," |
---|
| 292 | << " check the \'ni_glo\' value !") |
---|
| 293 | } |
---|
[687] | 294 | |
---|
[783] | 295 | if (nj_glo.isEmpty() || nj_glo <= 0 ) |
---|
| 296 | { |
---|
| 297 | ERROR("CDomain::redistribute(int nbLocalDomain)", |
---|
| 298 | << "[ Id = " << this->getId() << " ] " |
---|
| 299 | << "The global domain is badly defined," |
---|
| 300 | << " check the \'nj_glo\' value !") |
---|
| 301 | } |
---|
[687] | 302 | |
---|
[783] | 303 | if ((type_attr::rectilinear == type) || (type_attr::curvilinear == type)) |
---|
| 304 | { |
---|
[687] | 305 | int globalDomainSize = ni_glo * nj_glo; |
---|
| 306 | if (globalDomainSize <= nbLocalDomain) |
---|
| 307 | { |
---|
| 308 | for (int idx = 0; idx < nbLocalDomain; ++idx) |
---|
| 309 | { |
---|
| 310 | if (rankOnDomain < globalDomainSize) |
---|
| 311 | { |
---|
| 312 | int iIdx = rankOnDomain % ni_glo; |
---|
| 313 | int jIdx = rankOnDomain / ni_glo; |
---|
| 314 | ibegin.setValue(iIdx); jbegin.setValue(jIdx); |
---|
| 315 | ni.setValue(1); nj.setValue(1); |
---|
| 316 | } |
---|
| 317 | else |
---|
| 318 | { |
---|
| 319 | ibegin.setValue(0); jbegin.setValue(0); |
---|
| 320 | ni.setValue(0); nj.setValue(0); |
---|
| 321 | } |
---|
| 322 | } |
---|
| 323 | } |
---|
| 324 | else |
---|
| 325 | { |
---|
[688] | 326 | float njGlo = nj_glo.getValue(); |
---|
| 327 | float niGlo = ni_glo.getValue(); |
---|
| 328 | int nbProcOnX, nbProcOnY, range; |
---|
| 329 | |
---|
[687] | 330 | // Compute (approximately) number of segment on x and y axis |
---|
[688] | 331 | float yOverXRatio = njGlo/niGlo; |
---|
| 332 | |
---|
[687] | 333 | nbProcOnX = std::ceil(std::sqrt(nbLocalDomain/yOverXRatio)); |
---|
| 334 | nbProcOnY = std::ceil(((float)nbLocalDomain)/nbProcOnX); |
---|
| 335 | |
---|
| 336 | // Simple distribution: Sweep from top to bottom, left to right |
---|
| 337 | // Calculate local begin on x |
---|
| 338 | std::vector<int> ibeginVec(nbProcOnX,0), jbeginVec(nbProcOnY,0); |
---|
| 339 | std::vector<int> niVec(nbProcOnX), njVec(nbProcOnY); |
---|
| 340 | for (int i = 1; i < nbProcOnX; ++i) |
---|
| 341 | { |
---|
| 342 | range = ni_glo / nbProcOnX; |
---|
| 343 | if (i < (ni_glo%nbProcOnX)) ++range; |
---|
| 344 | niVec[i-1] = range; |
---|
| 345 | ibeginVec[i] = ibeginVec[i-1] + niVec[i-1]; |
---|
| 346 | } |
---|
| 347 | niVec[nbProcOnX-1] = ni_glo - ibeginVec[nbProcOnX-1]; |
---|
| 348 | |
---|
| 349 | // Calculate local begin on y |
---|
| 350 | for (int j = 1; j < nbProcOnY; ++j) |
---|
| 351 | { |
---|
| 352 | range = nj_glo / nbProcOnY; |
---|
| 353 | if (j < (nj_glo%nbProcOnY)) ++range; |
---|
| 354 | njVec[j-1] = range; |
---|
| 355 | jbeginVec[j] = jbeginVec[j-1] + njVec[j-1]; |
---|
| 356 | } |
---|
| 357 | njVec[nbProcOnY-1] = nj_glo - jbeginVec[nbProcOnY-1]; |
---|
| 358 | |
---|
| 359 | // Now assign value to ni, ibegin, nj, jbegin |
---|
| 360 | int iIdx = rankOnDomain % nbProcOnX; |
---|
| 361 | int jIdx = rankOnDomain / nbProcOnX; |
---|
| 362 | |
---|
| 363 | if (rankOnDomain != (nbLocalDomain-1)) |
---|
| 364 | { |
---|
| 365 | ibegin.setValue(ibeginVec[iIdx]); |
---|
| 366 | jbegin.setValue(jbeginVec[jIdx]); |
---|
| 367 | nj.setValue(njVec[jIdx]); |
---|
| 368 | ni.setValue(niVec[iIdx]); |
---|
| 369 | } |
---|
| 370 | else // just merge all the remaining rectangle into the last one |
---|
| 371 | { |
---|
| 372 | ibegin.setValue(ibeginVec[iIdx]); |
---|
| 373 | jbegin.setValue(jbeginVec[jIdx]); |
---|
| 374 | nj.setValue(njVec[jIdx]); |
---|
| 375 | ni.setValue(ni_glo - ibeginVec[iIdx]); |
---|
| 376 | } |
---|
| 377 | } |
---|
| 378 | |
---|
| 379 | // Now fill other attributes |
---|
[782] | 380 | if (type_attr::rectilinear == type) fillInRectilinearLonLat(); |
---|
[687] | 381 | } |
---|
[783] | 382 | else // unstructured domain |
---|
| 383 | { |
---|
[785] | 384 | if (this->i_index.isEmpty()) |
---|
| 385 | { |
---|
| 386 | int globalDomainSize = ni_glo * nj_glo; |
---|
| 387 | if (globalDomainSize <= nbLocalDomain) |
---|
[783] | 388 | { |
---|
[785] | 389 | for (int idx = 0; idx < nbLocalDomain; ++idx) |
---|
[783] | 390 | { |
---|
[785] | 391 | if (rankOnDomain < globalDomainSize) |
---|
| 392 | { |
---|
| 393 | int iIdx = rankOnDomain % ni_glo; |
---|
| 394 | int jIdx = rankOnDomain / ni_glo; |
---|
| 395 | ibegin.setValue(iIdx); jbegin.setValue(jIdx); |
---|
| 396 | ni.setValue(1); nj.setValue(1); |
---|
| 397 | } |
---|
| 398 | else |
---|
| 399 | { |
---|
| 400 | ibegin.setValue(0); jbegin.setValue(0); |
---|
| 401 | ni.setValue(0); nj.setValue(0); |
---|
| 402 | } |
---|
[783] | 403 | } |
---|
[785] | 404 | } |
---|
| 405 | else |
---|
| 406 | { |
---|
| 407 | float njGlo = nj_glo.getValue(); |
---|
| 408 | float niGlo = ni_glo.getValue(); |
---|
| 409 | std::vector<int> ibeginVec(nbLocalDomain,0); |
---|
| 410 | std::vector<int> niVec(nbLocalDomain); |
---|
| 411 | for (int i = 1; i < nbLocalDomain; ++i) |
---|
[783] | 412 | { |
---|
[785] | 413 | int range = ni_glo / nbLocalDomain; |
---|
| 414 | if (i < (ni_glo%nbLocalDomain)) ++range; |
---|
| 415 | niVec[i-1] = range; |
---|
| 416 | ibeginVec[i] = ibeginVec[i-1] + niVec[i-1]; |
---|
[783] | 417 | } |
---|
[785] | 418 | niVec[nbLocalDomain-1] = ni_glo - ibeginVec[nbLocalDomain-1]; |
---|
| 419 | |
---|
| 420 | int iIdx = rankOnDomain % nbLocalDomain; |
---|
| 421 | ibegin.setValue(ibeginVec[iIdx]); |
---|
| 422 | jbegin.setValue(0); |
---|
| 423 | ni.setValue(niVec[iIdx]); |
---|
| 424 | nj.setValue(1); |
---|
[783] | 425 | } |
---|
| 426 | } |
---|
| 427 | else |
---|
| 428 | { |
---|
[785] | 429 | ibegin.setValue(this->i_index(0)); |
---|
[783] | 430 | jbegin.setValue(0); |
---|
[785] | 431 | ni.setValue(this->i_index.numElements()); |
---|
[783] | 432 | nj.setValue(1); |
---|
| 433 | } |
---|
| 434 | } |
---|
[785] | 435 | |
---|
| 436 | checkDomain(); |
---|
[687] | 437 | } |
---|
| 438 | |
---|
| 439 | /*! |
---|
| 440 | Fill in the values for lonvalue_1d and latvalue_1d of rectilinear domain |
---|
| 441 | Range of longitude value from 0 - 360 |
---|
| 442 | Range of latitude value from -90 - +90 |
---|
| 443 | */ |
---|
| 444 | void CDomain::fillInRectilinearLonLat() |
---|
| 445 | { |
---|
[775] | 446 | if (!lonvalue_rectilinear_read_from_file.isEmpty()) |
---|
| 447 | { |
---|
| 448 | lonvalue_1d.resize(ni); |
---|
| 449 | for (int idx = 0; idx < ni; ++idx) |
---|
| 450 | lonvalue_1d(idx) = lonvalue_rectilinear_read_from_file(idx+ibegin); |
---|
| 451 | lon_start.setValue(lonvalue_rectilinear_read_from_file(0)); |
---|
| 452 | lon_end.setValue(lonvalue_rectilinear_read_from_file(ni_glo-1)); |
---|
| 453 | } |
---|
| 454 | else |
---|
| 455 | { |
---|
| 456 | if (!lonvalue_2d.isEmpty()) lonvalue_2d.free(); |
---|
| 457 | lonvalue_1d.resize(ni); |
---|
| 458 | double lonRange = lon_end - lon_start; |
---|
| 459 | double lonStep = (1 == ni_glo.getValue()) ? lonRange : lonRange/double(ni_glo.getValue()-1); |
---|
[688] | 460 | |
---|
[775] | 461 | // Assign lon value |
---|
| 462 | for (int i = 0; i < ni; ++i) |
---|
| 463 | { |
---|
| 464 | if (0 == (ibegin + i)) |
---|
| 465 | { |
---|
| 466 | lonvalue_1d(i) = lon_start; |
---|
| 467 | } |
---|
| 468 | else if (ni_glo == (ibegin + i + 1)) |
---|
| 469 | { |
---|
| 470 | lonvalue_1d(i) = lon_end; |
---|
| 471 | } |
---|
| 472 | else |
---|
| 473 | { |
---|
| 474 | lonvalue_1d(i) = (ibegin + i) * lonStep + lon_start; |
---|
| 475 | } |
---|
| 476 | } |
---|
| 477 | } |
---|
[687] | 478 | |
---|
[727] | 479 | |
---|
[775] | 480 | if (!latvalue_rectilinear_read_from_file.isEmpty()) |
---|
[687] | 481 | { |
---|
[775] | 482 | latvalue_1d.resize(nj); |
---|
| 483 | for (int idx = 0; idx < nj; ++idx) |
---|
| 484 | latvalue_1d(idx) = latvalue_rectilinear_read_from_file(idx+jbegin); |
---|
| 485 | lat_start.setValue(latvalue_rectilinear_read_from_file(0)); |
---|
| 486 | lat_end.setValue(latvalue_rectilinear_read_from_file(nj_glo-1)); |
---|
[687] | 487 | } |
---|
[775] | 488 | else |
---|
| 489 | { |
---|
| 490 | if (!latvalue_2d.isEmpty()) latvalue_1d.free(); |
---|
| 491 | latvalue_1d.resize(nj); |
---|
[687] | 492 | |
---|
[775] | 493 | double latRange = lat_end - lat_start; |
---|
| 494 | double latStep = (1 == nj_glo.getValue()) ? latRange : latRange/double(nj_glo.getValue()-1); |
---|
| 495 | |
---|
| 496 | for (int j = 0; j < nj; ++j) |
---|
[727] | 497 | { |
---|
[775] | 498 | if (0 == (jbegin + j)) |
---|
| 499 | { |
---|
| 500 | latvalue_1d(j) = lat_start; |
---|
| 501 | } |
---|
| 502 | else if (nj_glo == (jbegin + j + 1)) |
---|
| 503 | { |
---|
| 504 | latvalue_1d(j) = lat_end; |
---|
| 505 | } |
---|
| 506 | else |
---|
| 507 | { |
---|
| 508 | latvalue_1d(j) = (jbegin + j) * latStep + lat_start; |
---|
| 509 | } |
---|
[727] | 510 | } |
---|
[687] | 511 | } |
---|
| 512 | } |
---|
| 513 | |
---|
[809] | 514 | |
---|
| 515 | |
---|
| 516 | void CDomain::AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, CArray<double,1>& lon_g, CArray<double,1>& lat_g) |
---|
[688] | 517 | { |
---|
[809] | 518 | CContext* context = CContext::getCurrent(); |
---|
[1054] | 519 | // For now the assumption is that secondary server pools consist of the same number of procs. |
---|
| 520 | // CHANGE the line below if the assumption changes. |
---|
| 521 | CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client; |
---|
[809] | 522 | lon_g.resize(ni_glo) ; |
---|
| 523 | lat_g.resize(nj_glo) ; |
---|
[815] | 524 | |
---|
| 525 | |
---|
[809] | 526 | int* ibegin_g = new int[client->clientSize] ; |
---|
| 527 | int* jbegin_g = new int[client->clientSize] ; |
---|
| 528 | int* ni_g = new int[client->clientSize] ; |
---|
| 529 | int* nj_g = new int[client->clientSize] ; |
---|
| 530 | int v ; |
---|
| 531 | v=ibegin ; |
---|
| 532 | MPI_Allgather(&v,1,MPI_INT,ibegin_g,1,MPI_INT,client->intraComm) ; |
---|
| 533 | v=jbegin ; |
---|
| 534 | MPI_Allgather(&v,1,MPI_INT,jbegin_g,1,MPI_INT,client->intraComm) ; |
---|
| 535 | v=ni ; |
---|
| 536 | MPI_Allgather(&v,1,MPI_INT,ni_g,1,MPI_INT,client->intraComm) ; |
---|
| 537 | v=nj ; |
---|
| 538 | MPI_Allgather(&v,1,MPI_INT,nj_g,1,MPI_INT,client->intraComm) ; |
---|
[815] | 539 | |
---|
[809] | 540 | MPI_Allgatherv(lon.dataFirst(),ni,MPI_DOUBLE,lon_g.dataFirst(),ni_g, ibegin_g,MPI_DOUBLE,client->intraComm) ; |
---|
| 541 | MPI_Allgatherv(lat.dataFirst(),nj,MPI_DOUBLE,lat_g.dataFirst(),nj_g, jbegin_g,MPI_DOUBLE,client->intraComm) ; |
---|
[815] | 542 | |
---|
[809] | 543 | delete[] ibegin_g ; |
---|
| 544 | delete[] jbegin_g ; |
---|
| 545 | delete[] ni_g ; |
---|
| 546 | delete[] nj_g ; |
---|
| 547 | } |
---|
| 548 | |
---|
| 549 | void CDomain::fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat, |
---|
| 550 | CArray<double,2>& boundsLon, CArray<double,2>& boundsLat) |
---|
| 551 | { |
---|
[688] | 552 | int i,j,k; |
---|
[815] | 553 | |
---|
[688] | 554 | const int nvertexValue = 4; |
---|
[775] | 555 | boundsLon.resize(nvertexValue,ni*nj); |
---|
[688] | 556 | |
---|
[899] | 557 | if (ni_glo>1) |
---|
| 558 | { |
---|
| 559 | double lonStepStart = lon(1)-lon(0); |
---|
| 560 | bounds_lon_start=lon(0) - lonStepStart/2; |
---|
| 561 | double lonStepEnd = lon(ni_glo-1)-lon(ni_glo-2); |
---|
| 562 | bounds_lon_end=lon(ni_glo-1) + lonStepEnd/2; |
---|
| 563 | double errorBoundsLon = std::abs(360-std::abs(bounds_lon_end-bounds_lon_start)); |
---|
[810] | 564 | |
---|
[899] | 565 | // if errorBoundsLon is reasonably small (0.1 x cell size) consider it as closed in longitude |
---|
| 566 | if (errorBoundsLon < std::abs(lonStepStart)*1e-1 || errorBoundsLon < std::abs(lonStepEnd)*1e-1 ) |
---|
| 567 | { |
---|
| 568 | bounds_lon_start= (lon(0) + lon(ni_glo-1)-360)/2 ; |
---|
| 569 | bounds_lon_end= (lon(0) +360 + lon(ni_glo-1))/2 ; |
---|
| 570 | } |
---|
| 571 | } |
---|
| 572 | else |
---|
[810] | 573 | { |
---|
[899] | 574 | if (bounds_lon_start.isEmpty()) bounds_lon_start=-180. ; |
---|
| 575 | if (bounds_lon_end.isEmpty()) bounds_lon_end=180.-1e-8 ; |
---|
[810] | 576 | } |
---|
[906] | 577 | |
---|
[809] | 578 | for(j=0;j<nj;++j) |
---|
| 579 | for(i=0;i<ni;++i) |
---|
| 580 | { |
---|
| 581 | k=j*ni+i; |
---|
| 582 | boundsLon(0,k) = boundsLon(1,k) = (0 == (ibegin + i)) ? bounds_lon_start |
---|
| 583 | : (lon(ibegin + i)+lon(ibegin + i-1))/2; |
---|
| 584 | boundsLon(2,k) = boundsLon(3,k) = ((ibegin + i + 1) == ni_glo) ? bounds_lon_end |
---|
| 585 | : (lon(ibegin + i + 1)+lon(ibegin + i))/2; |
---|
| 586 | } |
---|
[727] | 587 | |
---|
[815] | 588 | |
---|
[809] | 589 | boundsLat.resize(nvertexValue,nj*ni); |
---|
[810] | 590 | bool isNorthPole=false ; |
---|
| 591 | bool isSouthPole=false ; |
---|
[809] | 592 | if (std::abs(90 - std::abs(lat(0))) < NumTraits<double>::epsilon()) isNorthPole = true; |
---|
| 593 | if (std::abs(90 - std::abs(lat(nj_glo-1))) < NumTraits<double>::epsilon()) isSouthPole = true; |
---|
[808] | 594 | |
---|
[810] | 595 | // lat boundaries beyond pole the assimilate it to pole |
---|
| 596 | // lat boundarie is relativelly close to pole (0.1 x cell size) assimilate it to pole |
---|
[899] | 597 | if (nj_glo>1) |
---|
[810] | 598 | { |
---|
[899] | 599 | double latStepStart = lat(1)-lat(0); |
---|
| 600 | if (isNorthPole) bounds_lat_start=lat(0); |
---|
| 601 | else |
---|
[810] | 602 | { |
---|
[899] | 603 | bounds_lat_start=lat(0)-latStepStart/2; |
---|
| 604 | if (bounds_lat_start >= 90 ) bounds_lat_start=90 ; |
---|
| 605 | else if (bounds_lat_start <= -90 ) bounds_lat_start=-90 ; |
---|
| 606 | else if (bounds_lat_start <= 90 && bounds_lat_start >= lat(0)) |
---|
| 607 | { |
---|
| 608 | if ( std::abs(90-bounds_lat_start) <= 0.1*std::abs(latStepStart)) bounds_lat_start=90 ; |
---|
| 609 | } |
---|
| 610 | else if (bounds_lat_start >= -90 && bounds_lat_start <= lat(0)) |
---|
| 611 | { |
---|
| 612 | if ( std::abs(-90 - bounds_lat_start) <= 0.1*std::abs(latStepStart)) bounds_lat_start=-90 ; |
---|
| 613 | } |
---|
[810] | 614 | } |
---|
[899] | 615 | |
---|
| 616 | double latStepEnd = lat(nj_glo-1)-lat(nj_glo-2); |
---|
| 617 | if (isSouthPole) bounds_lat_end=lat(nj_glo-1); |
---|
| 618 | else |
---|
[810] | 619 | { |
---|
[899] | 620 | bounds_lat_end=lat(nj_glo-1)+latStepEnd/2; |
---|
| 621 | |
---|
| 622 | if (bounds_lat_end >= 90 ) bounds_lat_end=90 ; |
---|
| 623 | else if (bounds_lat_end <= -90 ) bounds_lat_end=-90 ; |
---|
| 624 | else if (bounds_lat_end <= 90 && bounds_lat_end >= lat(nj_glo-1)) |
---|
| 625 | { |
---|
| 626 | if ( std::abs(90-bounds_lat_end) <= 0.1*std::abs(latStepEnd)) bounds_lat_end=90 ; |
---|
| 627 | } |
---|
| 628 | else if (bounds_lat_end >= -90 && bounds_lat_end <= lat(nj_glo-1)) |
---|
| 629 | { |
---|
| 630 | if ( std::abs(-90 - bounds_lat_end) <= 0.1*std::abs(latStepEnd)) bounds_lat_end=-90 ; |
---|
| 631 | } |
---|
[810] | 632 | } |
---|
| 633 | } |
---|
| 634 | else |
---|
| 635 | { |
---|
[899] | 636 | if (bounds_lat_start.isEmpty()) bounds_lon_start=-90. ; |
---|
| 637 | if (bounds_lat_end.isEmpty()) bounds_lat_end=90 ; |
---|
[815] | 638 | } |
---|
| 639 | |
---|
[809] | 640 | for(j=0;j<nj;++j) |
---|
| 641 | for(i=0;i<ni;++i) |
---|
| 642 | { |
---|
| 643 | k=j*ni+i; |
---|
| 644 | boundsLat(1,k) = boundsLat(2,k) = (0 == (jbegin + j)) ? bounds_lat_start |
---|
| 645 | : (lat(jbegin + j)+lat(jbegin + j-1))/2; |
---|
| 646 | boundsLat(0,k) = boundsLat(3,k) = ((jbegin + j +1) == nj_glo) ? bounds_lat_end |
---|
| 647 | : (lat(jbegin + j + 1)+lat(jbegin + j))/2; |
---|
| 648 | } |
---|
[688] | 649 | } |
---|
| 650 | |
---|
[467] | 651 | void CDomain::checkDomain(void) |
---|
[219] | 652 | { |
---|
[664] | 653 | if (type.isEmpty()) |
---|
| 654 | { |
---|
| 655 | ERROR("CDomain::checkDomain(void)", |
---|
[679] | 656 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 657 | << "The domain type is mandatory, " |
---|
| 658 | << "please define the 'type' attribute.") |
---|
[664] | 659 | } |
---|
[969] | 660 | |
---|
[953] | 661 | if (type == type_attr::gaussian) |
---|
| 662 | { |
---|
[969] | 663 | hasPole=true ; |
---|
| 664 | type.setValue(type_attr::unstructured) ; |
---|
| 665 | } |
---|
| 666 | else if (type == type_attr::rectilinear) hasPole=true ; |
---|
[953] | 667 | |
---|
[679] | 668 | if (type == type_attr::unstructured) |
---|
[664] | 669 | { |
---|
[679] | 670 | if (ni_glo.isEmpty()) |
---|
[664] | 671 | { |
---|
[679] | 672 | ERROR("CDomain::checkDomain(void)", |
---|
| 673 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 674 | << "The global domain is badly defined, " |
---|
| 675 | << "the mandatory 'ni_glo' attribute is missing.") |
---|
[664] | 676 | } |
---|
[679] | 677 | else if (ni_glo <= 0) |
---|
| 678 | { |
---|
| 679 | ERROR("CDomain::checkDomain(void)", |
---|
| 680 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 681 | << "The global domain is badly defined, " |
---|
| 682 | << "'ni_glo' attribute should be strictly positive so 'ni_glo = " << ni_glo.getValue() << "' is invalid.") |
---|
| 683 | } |
---|
[664] | 684 | isUnstructed_ = true; |
---|
| 685 | nj_glo = 1; |
---|
| 686 | nj = 1; |
---|
| 687 | jbegin = 0; |
---|
[942] | 688 | if (!i_index.isEmpty()) ni = i_index.numElements(); |
---|
[664] | 689 | j_index.resize(ni); |
---|
| 690 | for(int i=0;i<ni;++i) j_index(i)=0; |
---|
[611] | 691 | |
---|
[664] | 692 | if (!area.isEmpty()) |
---|
| 693 | area.transposeSelf(1, 0); |
---|
| 694 | } |
---|
[679] | 695 | |
---|
| 696 | if (ni_glo.isEmpty()) |
---|
[664] | 697 | { |
---|
[679] | 698 | ERROR("CDomain::checkDomain(void)", |
---|
| 699 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 700 | << "The global domain is badly defined, " |
---|
| 701 | << "the mandatory 'ni_glo' attribute is missing.") |
---|
[664] | 702 | } |
---|
[679] | 703 | else if (ni_glo <= 0) |
---|
| 704 | { |
---|
| 705 | ERROR("CDomain::checkDomain(void)", |
---|
| 706 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 707 | << "The global domain is badly defined, " |
---|
| 708 | << "'ni_glo' attribute should be strictly positive so 'ni_glo = " << ni_glo.getValue() << "' is invalid.") |
---|
| 709 | } |
---|
[509] | 710 | |
---|
[679] | 711 | if (nj_glo.isEmpty()) |
---|
| 712 | { |
---|
| 713 | ERROR("CDomain::checkDomain(void)", |
---|
| 714 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 715 | << "The global domain is badly defined, " |
---|
| 716 | << "the mandatory 'nj_glo' attribute is missing.") |
---|
| 717 | } |
---|
| 718 | else if (nj_glo <= 0) |
---|
| 719 | { |
---|
| 720 | ERROR("CDomain::checkDomain(void)", |
---|
| 721 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 722 | << "The global domain is badly defined, " |
---|
| 723 | << "'nj_glo' attribute should be strictly positive so 'nj_glo = " << nj_glo.getValue() << "' is invalid.") |
---|
| 724 | } |
---|
| 725 | |
---|
[664] | 726 | checkLocalIDomain(); |
---|
| 727 | checkLocalJDomain(); |
---|
[509] | 728 | |
---|
[664] | 729 | if (i_index.isEmpty()) |
---|
| 730 | { |
---|
| 731 | i_index.resize(ni*nj); |
---|
| 732 | for (int j = 0; j < nj; ++j) |
---|
| 733 | for (int i = 0; i < ni; ++i) i_index(i+j*ni) = i+ibegin; |
---|
| 734 | } |
---|
[594] | 735 | |
---|
[664] | 736 | if (j_index.isEmpty()) |
---|
| 737 | { |
---|
| 738 | j_index.resize(ni*nj); |
---|
| 739 | for (int j = 0; j < nj; ++j) |
---|
| 740 | for (int i = 0; i < ni; ++i) j_index(i+j*ni) = j+jbegin; |
---|
[1025] | 741 | } |
---|
[821] | 742 | checkZoom(); |
---|
[969] | 743 | |
---|
| 744 | isDistributed_ = !((!ni.isEmpty() && (ni == ni_glo) && !nj.isEmpty() && (nj == nj_glo)) || |
---|
| 745 | (!i_index.isEmpty() && i_index.numElements() == ni_glo*nj_glo)); |
---|
[821] | 746 | } |
---|
[663] | 747 | |
---|
[969] | 748 | // Check global zoom of a domain |
---|
| 749 | // If there is no zoom defined for the domain, zoom will have value of global doamin |
---|
[821] | 750 | void CDomain::checkZoom(void) |
---|
| 751 | { |
---|
| 752 | if (global_zoom_ibegin.isEmpty()) |
---|
| 753 | global_zoom_ibegin.setValue(0); |
---|
| 754 | if (global_zoom_ni.isEmpty()) |
---|
| 755 | global_zoom_ni.setValue(ni_glo); |
---|
| 756 | if (global_zoom_jbegin.isEmpty()) |
---|
| 757 | global_zoom_jbegin.setValue(0); |
---|
| 758 | if (global_zoom_nj.isEmpty()) |
---|
| 759 | global_zoom_nj.setValue(nj_glo); |
---|
[1025] | 760 | if (zoom_i_index.isEmpty()) zoom_i_index.setValue(i_index.getValue()); |
---|
| 761 | if (zoom_j_index.isEmpty()) zoom_j_index.setValue(j_index.getValue()); |
---|
[1099] | 762 | if (zoom_ibegin.isEmpty()) zoom_ibegin.setValue(ibegin); |
---|
| 763 | if (zoom_ni.isEmpty()) zoom_ni.setValue(ni); |
---|
| 764 | if (zoom_jbegin.isEmpty()) zoom_jbegin.setValue(jbegin); |
---|
| 765 | if (zoom_nj.isEmpty()) zoom_nj.setValue(nj); |
---|
[219] | 766 | } |
---|
| 767 | |
---|
| 768 | //---------------------------------------------------------------- |
---|
| 769 | |
---|
[969] | 770 | // Check validity of local domain on using the combination of 3 parameters: ibegin, ni and i_index |
---|
[219] | 771 | void CDomain::checkLocalIDomain(void) |
---|
| 772 | { |
---|
[969] | 773 | // If ibegin and ni are provided then we use them to check the validity of local domain |
---|
| 774 | if (i_index.isEmpty() && !ibegin.isEmpty() && !ni.isEmpty()) |
---|
[219] | 775 | { |
---|
[969] | 776 | if ((ni.getValue() < 0 || ibegin.getValue() < 0) || ((ibegin.getValue() + ni.getValue()) > ni_glo.getValue())) |
---|
| 777 | { |
---|
| 778 | ERROR("CDomain::checkLocalIDomain(void)", |
---|
| 779 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 780 | << "The local domain is wrongly defined," |
---|
| 781 | << " check the attributes 'ni_glo' (" << ni_glo.getValue() << "), 'ni' (" << ni.getValue() << ") and 'ibegin' (" << ibegin.getValue() << ")"); |
---|
| 782 | } |
---|
| 783 | } |
---|
| 784 | |
---|
| 785 | // i_index has higher priority than ibegin and ni |
---|
| 786 | if (!i_index.isEmpty()) |
---|
| 787 | { |
---|
[975] | 788 | int minIIndex = (0 < i_index.numElements()) ? i_index(0) : 0; |
---|
[969] | 789 | if (ni.isEmpty()) |
---|
| 790 | { |
---|
| 791 | // No information about ni |
---|
| 792 | int minIndex = ni_glo - 1; |
---|
| 793 | int maxIndex = 0; |
---|
| 794 | for (int idx = 0; idx < i_index.numElements(); ++idx) |
---|
| 795 | { |
---|
| 796 | if (i_index(idx) < minIndex) minIndex = i_index(idx); |
---|
| 797 | if (i_index(idx) > maxIndex) maxIndex = i_index(idx); |
---|
| 798 | } |
---|
| 799 | ni = maxIndex - minIndex + 1; |
---|
| 800 | minIIndex = minIIndex; |
---|
| 801 | } |
---|
| 802 | |
---|
| 803 | // It's not so correct but if ibegin is not the first value of i_index |
---|
| 804 | // then data on local domain has user-defined distribution. In this case, ibegin, ni have no meaning. |
---|
| 805 | if (ibegin.isEmpty()) ibegin = minIIndex; |
---|
| 806 | } |
---|
| 807 | else if (ibegin.isEmpty() && ni.isEmpty()) |
---|
| 808 | { |
---|
[594] | 809 | ibegin = 0; |
---|
| 810 | ni = ni_glo; |
---|
| 811 | } |
---|
[971] | 812 | else if ((!ibegin.isEmpty() && ni.isEmpty()) || (ibegin.isEmpty() && !ni.isEmpty())) |
---|
[219] | 813 | { |
---|
[969] | 814 | ERROR("CDomain::checkLocalIDomain(void)", |
---|
| 815 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
[971] | 816 | << "The local domain is wrongly defined," << endl |
---|
| 817 | << "i_index is empty and either 'ni' or 'ibegin' is not defined. " |
---|
| 818 | << "If 'ni' and 'ibegin' are used to define a domain, both of them must not be empty."); |
---|
[219] | 819 | } |
---|
[969] | 820 | |
---|
[219] | 821 | |
---|
[969] | 822 | if ((ni.getValue() < 0 || ibegin.getValue() < 0)) |
---|
[594] | 823 | { |
---|
| 824 | ERROR("CDomain::checkLocalIDomain(void)", |
---|
[679] | 825 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
[594] | 826 | << "The local domain is wrongly defined," |
---|
[679] | 827 | << " check the attributes 'ni_glo' (" << ni_glo.getValue() << "), 'ni' (" << ni.getValue() << ") and 'ibegin' (" << ibegin.getValue() << ")"); |
---|
[594] | 828 | } |
---|
[219] | 829 | } |
---|
| 830 | |
---|
[969] | 831 | // Check validity of local domain on using the combination of 3 parameters: jbegin, nj and j_index |
---|
[219] | 832 | void CDomain::checkLocalJDomain(void) |
---|
| 833 | { |
---|
[969] | 834 | // If jbegin and nj are provided then we use them to check the validity of local domain |
---|
| 835 | if (j_index.isEmpty() && !jbegin.isEmpty() && !nj.isEmpty()) |
---|
[657] | 836 | { |
---|
[969] | 837 | if ((nj.getValue() < 0 || jbegin.getValue() < 0) || (jbegin.getValue() + nj.getValue()) > nj_glo.getValue()) |
---|
| 838 | { |
---|
| 839 | ERROR("CDomain::checkLocalJDomain(void)", |
---|
| 840 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 841 | << "The local domain is wrongly defined," |
---|
| 842 | << " check the attributes 'nj_glo' (" << nj_glo.getValue() << "), 'nj' (" << nj.getValue() << ") and 'jbegin' (" << jbegin.getValue() << ")"); |
---|
| 843 | } |
---|
[657] | 844 | } |
---|
[969] | 845 | |
---|
| 846 | if (!j_index.isEmpty()) |
---|
[657] | 847 | { |
---|
[975] | 848 | int minJIndex = (0 < j_index.numElements()) ? j_index(0) : 0; |
---|
[969] | 849 | if (nj.isEmpty()) |
---|
| 850 | { |
---|
| 851 | // No information about nj |
---|
| 852 | int minIndex = nj_glo - 1; |
---|
| 853 | int maxIndex = 0; |
---|
| 854 | for (int idx = 0; idx < j_index.numElements(); ++idx) |
---|
| 855 | { |
---|
| 856 | if (j_index(idx) < minIndex) minIndex = j_index(idx); |
---|
| 857 | if (j_index(idx) > maxIndex) maxIndex = j_index(idx); |
---|
| 858 | } |
---|
| 859 | nj = maxIndex - minIndex + 1; |
---|
| 860 | minJIndex = minIndex; |
---|
| 861 | } |
---|
| 862 | // It's the same as checkLocalIDomain. It's not so correct but if jbegin is not the first value of j_index |
---|
| 863 | // then data on local domain has user-defined distribution. In this case, jbegin has no meaning. |
---|
| 864 | if (jbegin.isEmpty()) jbegin = minJIndex; |
---|
[657] | 865 | } |
---|
[969] | 866 | else if (jbegin.isEmpty() && nj.isEmpty()) |
---|
| 867 | { |
---|
| 868 | jbegin = 0; |
---|
| 869 | nj = nj_glo; |
---|
| 870 | } |
---|
[219] | 871 | |
---|
[969] | 872 | |
---|
| 873 | if ((nj.getValue() < 0 || jbegin.getValue() < 0)) |
---|
| 874 | { |
---|
| 875 | ERROR("CDomain::checkLocalJDomain(void)", |
---|
[679] | 876 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
[594] | 877 | << "The local domain is wrongly defined," |
---|
[679] | 878 | << " check the attributes 'nj_glo' (" << nj_glo.getValue() << "), 'nj' (" << nj.getValue() << ") and 'jbegin' (" << jbegin.getValue() << ")"); |
---|
[969] | 879 | } |
---|
[219] | 880 | } |
---|
| 881 | |
---|
| 882 | //---------------------------------------------------------------- |
---|
[679] | 883 | |
---|
[219] | 884 | void CDomain::checkMask(void) |
---|
| 885 | { |
---|
[664] | 886 | if (!mask_1d.isEmpty() && !mask_2d.isEmpty()) |
---|
[657] | 887 | ERROR("CDomain::checkMask(void)", |
---|
[679] | 888 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 889 | << "Both mask_1d and mask_2d are defined but only one can be used at the same time." << std::endl |
---|
| 890 | << "Please define only one mask: 'mask_1d' or 'mask_2d'."); |
---|
[657] | 891 | |
---|
[664] | 892 | if (!mask_1d.isEmpty() && mask_2d.isEmpty()) |
---|
[219] | 893 | { |
---|
[664] | 894 | if (mask_1d.numElements() != i_index.numElements()) |
---|
[657] | 895 | ERROR("CDomain::checkMask(void)", |
---|
[679] | 896 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 897 | << "'mask_1d' does not have the same size as the local domain." << std::endl |
---|
| 898 | << "Local size is " << i_index.numElements() << "." << std::endl |
---|
| 899 | << "Mask size is " << mask_1d.numElements() << "."); |
---|
[657] | 900 | } |
---|
[509] | 901 | |
---|
[664] | 902 | if (mask_1d.isEmpty() && !mask_2d.isEmpty()) |
---|
[657] | 903 | { |
---|
[679] | 904 | if (mask_2d.extent(0) != ni || mask_2d.extent(1) != nj) |
---|
| 905 | ERROR("CDomain::checkMask(void)", |
---|
| 906 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 907 | << "The mask does not have the same size as the local domain." << std::endl |
---|
| 908 | << "Local size is " << ni.getValue() << " x " << nj.getValue() << "." << std::endl |
---|
| 909 | << "Mask size is " << mask_2d.extent(0) << " x " << mask_2d.extent(1) << "."); |
---|
[657] | 910 | } |
---|
[509] | 911 | |
---|
[664] | 912 | if (!mask_2d.isEmpty()) |
---|
[657] | 913 | { |
---|
[664] | 914 | mask_1d.resize(mask_2d.extent(0) * mask_2d.extent(1)); |
---|
[657] | 915 | for (int j = 0; j < nj; ++j) |
---|
[664] | 916 | for (int i = 0; i < ni; ++i) mask_1d(i+j*ni) = mask_2d(i,j); |
---|
[813] | 917 | mask_2d.reset(); |
---|
[657] | 918 | } |
---|
[675] | 919 | else if (mask_1d.isEmpty()) |
---|
[657] | 920 | { |
---|
[664] | 921 | mask_1d.resize(i_index.numElements()); |
---|
| 922 | for (int i = 0; i < i_index.numElements(); ++i) mask_1d(i) = true; |
---|
[657] | 923 | } |
---|
[219] | 924 | } |
---|
| 925 | |
---|
[676] | 926 | //---------------------------------------------------------------- |
---|
[219] | 927 | |
---|
| 928 | void CDomain::checkDomainData(void) |
---|
[509] | 929 | { |
---|
[679] | 930 | if (data_dim.isEmpty()) |
---|
[219] | 931 | { |
---|
[679] | 932 | data_dim.setValue(1); |
---|
[219] | 933 | } |
---|
[679] | 934 | else if (!(data_dim.getValue() == 1 || data_dim.getValue() == 2)) |
---|
[219] | 935 | { |
---|
[679] | 936 | ERROR("CDomain::checkDomainData(void)", |
---|
| 937 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 938 | << "The data dimension is invalid, 'data_dim' must be 1 or 2 not << " << data_dim.getValue() << "."); |
---|
[219] | 939 | } |
---|
| 940 | |
---|
| 941 | if (data_ibegin.isEmpty()) |
---|
[679] | 942 | data_ibegin.setValue(0); |
---|
[660] | 943 | if (data_jbegin.isEmpty()) |
---|
[679] | 944 | data_jbegin.setValue(0); |
---|
[219] | 945 | |
---|
[679] | 946 | if (data_ni.isEmpty()) |
---|
[219] | 947 | { |
---|
[679] | 948 | data_ni.setValue((data_dim == 1) ? (ni.getValue() * nj.getValue()) : ni.getValue()); |
---|
[219] | 949 | } |
---|
[679] | 950 | else if (data_ni.getValue() < 0) |
---|
[219] | 951 | { |
---|
[679] | 952 | ERROR("CDomain::checkDomainData(void)", |
---|
| 953 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 954 | << "The data size cannot be negative ('data_ni' = " << data_ni.getValue() << ")."); |
---|
[219] | 955 | } |
---|
| 956 | |
---|
[679] | 957 | if (data_nj.isEmpty()) |
---|
[219] | 958 | { |
---|
[679] | 959 | data_nj.setValue((data_dim.getValue() == 1) ? (ni.getValue() * nj.getValue()) : nj.getValue()); |
---|
[219] | 960 | } |
---|
[679] | 961 | else if (data_nj.getValue() < 0) |
---|
| 962 | { |
---|
| 963 | ERROR("CDomain::checkDomainData(void)", |
---|
| 964 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 965 | << "The data size cannot be negative ('data_nj' = " << data_nj.getValue() << ")."); |
---|
| 966 | } |
---|
[219] | 967 | } |
---|
| 968 | |
---|
| 969 | //---------------------------------------------------------------- |
---|
[679] | 970 | |
---|
[219] | 971 | void CDomain::checkCompression(void) |
---|
| 972 | { |
---|
| 973 | if (!data_i_index.isEmpty()) |
---|
| 974 | { |
---|
[664] | 975 | if (!data_j_index.isEmpty() && |
---|
[678] | 976 | data_j_index.numElements() != data_i_index.numElements()) |
---|
[664] | 977 | { |
---|
[679] | 978 | ERROR("CDomain::checkCompression(void)", |
---|
| 979 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 980 | << "'data_i_index' and 'data_j_index' arrays must have the same size." << std::endl |
---|
| 981 | << "'data_i_index' size = " << data_i_index.numElements() << std::endl |
---|
| 982 | << "'data_j_index' size = " << data_j_index.numElements()); |
---|
[664] | 983 | } |
---|
| 984 | |
---|
[679] | 985 | if (2 == data_dim) |
---|
| 986 | { |
---|
[664] | 987 | if (data_j_index.isEmpty()) |
---|
[660] | 988 | { |
---|
[679] | 989 | ERROR("CDomain::checkCompression(void)", |
---|
| 990 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 991 | << "'data_j_index' must be defined when 'data_i_index' is set and 'data_dim' is 2."); |
---|
[660] | 992 | } |
---|
[679] | 993 | } |
---|
| 994 | else // (1 == data_dim) |
---|
| 995 | { |
---|
[664] | 996 | if (data_j_index.isEmpty()) |
---|
| 997 | { |
---|
[679] | 998 | data_j_index.resize(data_ni); |
---|
| 999 | for (int j = 0; j < data_ni; ++j) data_j_index(j) = 0; |
---|
[664] | 1000 | } |
---|
[679] | 1001 | } |
---|
[219] | 1002 | } |
---|
| 1003 | else |
---|
| 1004 | { |
---|
[679] | 1005 | if (data_dim == 2 && !data_j_index.isEmpty()) |
---|
| 1006 | ERROR("CDomain::checkCompression(void)", |
---|
| 1007 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1008 | << "'data_i_index' must be defined when 'data_j_index' is set and 'data_dim' is 2."); |
---|
[219] | 1009 | |
---|
[679] | 1010 | if (1 == data_dim) |
---|
| 1011 | { |
---|
| 1012 | data_i_index.resize(data_ni); |
---|
| 1013 | data_j_index.resize(data_ni); |
---|
[666] | 1014 | |
---|
[679] | 1015 | for (int i = 0; i < data_ni; ++i) |
---|
| 1016 | { |
---|
| 1017 | data_i_index(i) = i; |
---|
| 1018 | data_j_index(i) = 0; |
---|
| 1019 | } |
---|
| 1020 | } |
---|
| 1021 | else // (data_dim == 2) |
---|
| 1022 | { |
---|
| 1023 | const int dsize = data_ni * data_nj; |
---|
| 1024 | data_i_index.resize(dsize); |
---|
| 1025 | data_j_index.resize(dsize); |
---|
[509] | 1026 | |
---|
[679] | 1027 | for(int count = 0, j = 0; j < data_nj; ++j) |
---|
| 1028 | { |
---|
| 1029 | for(int i = 0; i < data_ni; ++i, ++count) |
---|
[219] | 1030 | { |
---|
[679] | 1031 | data_i_index(count) = i; |
---|
| 1032 | data_j_index(count) = j; |
---|
[219] | 1033 | } |
---|
[679] | 1034 | } |
---|
| 1035 | } |
---|
[219] | 1036 | } |
---|
| 1037 | } |
---|
| 1038 | |
---|
[666] | 1039 | //---------------------------------------------------------------- |
---|
[893] | 1040 | void CDomain::computeLocalMask(void) |
---|
| 1041 | { |
---|
| 1042 | localMask.resize(ni*nj) ; |
---|
| 1043 | localMask=false ; |
---|
[1025] | 1044 | size_t zoom_ibegin= global_zoom_ibegin ; |
---|
| 1045 | size_t zoom_iend= global_zoom_ibegin+global_zoom_ni-1 ; |
---|
| 1046 | size_t zoom_jbegin= global_zoom_jbegin ; |
---|
| 1047 | size_t zoom_jend= global_zoom_jbegin+global_zoom_nj-1 ; |
---|
[676] | 1048 | |
---|
[906] | 1049 | |
---|
[893] | 1050 | size_t dn=data_i_index.numElements() ; |
---|
| 1051 | int i,j ; |
---|
| 1052 | size_t k,ind ; |
---|
[906] | 1053 | |
---|
[893] | 1054 | for(k=0;k<dn;k++) |
---|
| 1055 | { |
---|
| 1056 | if (data_dim==2) |
---|
| 1057 | { |
---|
| 1058 | i=data_i_index(k)+data_ibegin ; |
---|
| 1059 | j=data_j_index(k)+data_jbegin ; |
---|
| 1060 | } |
---|
| 1061 | else |
---|
| 1062 | { |
---|
| 1063 | i=(data_i_index(k)+data_ibegin)%ni ; |
---|
[906] | 1064 | j=(data_i_index(k)+data_ibegin)/ni ; |
---|
[893] | 1065 | } |
---|
| 1066 | |
---|
| 1067 | if (i>=0 && i<ni && j>=0 && j<nj) |
---|
| 1068 | if (i+ibegin>=zoom_ibegin && i+ibegin<=zoom_iend && j+jbegin>=zoom_jbegin && j+jbegin<=zoom_jend) |
---|
| 1069 | { |
---|
| 1070 | ind=i+ni*j ; |
---|
| 1071 | localMask(ind)=mask_1d(ind) ; |
---|
| 1072 | } |
---|
| 1073 | } |
---|
| 1074 | } |
---|
| 1075 | |
---|
[676] | 1076 | void CDomain::checkEligibilityForCompressedOutput(void) |
---|
| 1077 | { |
---|
| 1078 | // We don't check if the mask or the indexes are valid here, just if they have been defined at this point. |
---|
| 1079 | isCompressible_ = !mask_1d.isEmpty() || !mask_2d.isEmpty() || !data_i_index.isEmpty(); |
---|
| 1080 | } |
---|
| 1081 | |
---|
| 1082 | //---------------------------------------------------------------- |
---|
| 1083 | |
---|
[1129] | 1084 | /* |
---|
| 1085 | Fill in longitude and latitude value from clients (or models) into internal values lonvalue, latvalue which |
---|
| 1086 | will be used by XIOS. |
---|
| 1087 | */ |
---|
[666] | 1088 | void CDomain::completeLonLatClient(void) |
---|
[219] | 1089 | { |
---|
[1099] | 1090 | bool lonlatValueExisted = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); |
---|
| 1091 | if (!lonvalue_2d.isEmpty() && !lonlatValueExisted) |
---|
[664] | 1092 | { |
---|
[1025] | 1093 | lonvalue.resize(ni * nj); |
---|
| 1094 | latvalue.resize(ni * nj); |
---|
[761] | 1095 | if (hasBounds) |
---|
| 1096 | { |
---|
[1025] | 1097 | bounds_lonvalue.resize(nvertex, ni * nj); |
---|
| 1098 | bounds_latvalue.resize(nvertex, ni * nj); |
---|
[761] | 1099 | } |
---|
| 1100 | |
---|
| 1101 | for (int j = 0; j < nj; ++j) |
---|
| 1102 | { |
---|
| 1103 | for (int i = 0; i < ni; ++i) |
---|
| 1104 | { |
---|
| 1105 | int k = j * ni + i; |
---|
| 1106 | |
---|
[1025] | 1107 | lonvalue(k) = lonvalue_2d(i,j); |
---|
| 1108 | latvalue(k) = latvalue_2d(i,j); |
---|
[761] | 1109 | |
---|
| 1110 | if (hasBounds) |
---|
| 1111 | { |
---|
| 1112 | for (int n = 0; n < nvertex; ++n) |
---|
| 1113 | { |
---|
[1025] | 1114 | bounds_lonvalue(n,k) = bounds_lon_2d(n,i,j); |
---|
| 1115 | bounds_latvalue(n,k) = bounds_lat_2d(n,i,j); |
---|
[761] | 1116 | } |
---|
| 1117 | } |
---|
| 1118 | } |
---|
| 1119 | } |
---|
[664] | 1120 | } |
---|
[1099] | 1121 | else if (!lonvalue_1d.isEmpty() && !lonlatValueExisted) |
---|
[664] | 1122 | { |
---|
| 1123 | if (type_attr::rectilinear == type) |
---|
| 1124 | { |
---|
[679] | 1125 | if (ni == lonvalue_1d.numElements() && nj == latvalue_1d.numElements()) |
---|
[664] | 1126 | { |
---|
[1025] | 1127 | lonvalue.resize(ni * nj); |
---|
| 1128 | latvalue.resize(ni * nj); |
---|
[761] | 1129 | if (hasBounds) |
---|
| 1130 | { |
---|
[1025] | 1131 | bounds_lonvalue.resize(nvertex, ni * nj); |
---|
| 1132 | bounds_latvalue.resize(nvertex, ni * nj); |
---|
[761] | 1133 | } |
---|
| 1134 | |
---|
| 1135 | for (int j = 0; j < nj; ++j) |
---|
| 1136 | { |
---|
| 1137 | for (int i = 0; i < ni; ++i) |
---|
[664] | 1138 | { |
---|
[761] | 1139 | int k = j * ni + i; |
---|
| 1140 | |
---|
[1025] | 1141 | lonvalue(k) = lonvalue_1d(i); |
---|
| 1142 | latvalue(k) = latvalue_1d(j); |
---|
[761] | 1143 | |
---|
[664] | 1144 | if (hasBounds) |
---|
| 1145 | { |
---|
[679] | 1146 | for (int n = 0; n < nvertex; ++n) |
---|
[666] | 1147 | { |
---|
[1025] | 1148 | bounds_lonvalue(n,k) = bounds_lon_1d(n,i); |
---|
| 1149 | bounds_latvalue(n,k) = bounds_lat_1d(n,j); |
---|
[666] | 1150 | } |
---|
[664] | 1151 | } |
---|
| 1152 | } |
---|
[761] | 1153 | } |
---|
| 1154 | } |
---|
[1099] | 1155 | else if (i_index.numElements() == lonvalue_1d.numElements() && j_index.numElements() == latvalue_1d.numElements() && !lonlatValueExisted) |
---|
[974] | 1156 | { |
---|
[1025] | 1157 | lonvalue.reference(lonvalue_1d); |
---|
| 1158 | latvalue.reference(latvalue_1d); |
---|
[974] | 1159 | if (hasBounds) |
---|
| 1160 | { |
---|
[1025] | 1161 | bounds_lonvalue.reference(bounds_lon_1d); |
---|
| 1162 | bounds_latvalue.reference(bounds_lat_1d); |
---|
[974] | 1163 | } |
---|
| 1164 | } |
---|
[761] | 1165 | else |
---|
| 1166 | ERROR("CDomain::completeLonClient(void)", |
---|
| 1167 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1168 | << "'lonvalue_1d' and 'latvalue_1d' does not have the same size as the local domain." << std::endl |
---|
[974] | 1169 | << "'lonvalue_1d' size is " << lonvalue_1d.numElements() |
---|
| 1170 | << " and 'latvalue_1d' size is " << latvalue_1d.numElements() << std::endl |
---|
| 1171 | << " They should be correspondingly " << ni.getValue() << " and " << nj.getValue() << " or " << std::endl |
---|
| 1172 | << i_index.numElements() << " and " << j_index.numElements() << "."); |
---|
[664] | 1173 | } |
---|
[1099] | 1174 | else if (type == type_attr::curvilinear || type == type_attr::unstructured && !lonlatValueExisted) |
---|
[664] | 1175 | { |
---|
[1025] | 1176 | lonvalue.reference(lonvalue_1d); |
---|
| 1177 | latvalue.reference(latvalue_1d); |
---|
[664] | 1178 | if (hasBounds) |
---|
| 1179 | { |
---|
[1025] | 1180 | bounds_lonvalue.reference(bounds_lon_1d); |
---|
| 1181 | bounds_latvalue.reference(bounds_lat_1d); |
---|
[664] | 1182 | } |
---|
| 1183 | } |
---|
| 1184 | } |
---|
| 1185 | } |
---|
| 1186 | |
---|
[1129] | 1187 | /* |
---|
| 1188 | Convert internal longitude latitude value used by XIOS to "lonvalue_*" which can be retrieved with Fortran interface |
---|
| 1189 | */ |
---|
| 1190 | void CDomain::convertLonLatValue(void) |
---|
| 1191 | { |
---|
| 1192 | bool lonlatValueExisted = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); |
---|
| 1193 | if (!lonvalue_2d.isEmpty() && lonlatValueExisted) |
---|
| 1194 | { |
---|
| 1195 | lonvalue_2d.resize(ni,nj); |
---|
| 1196 | latvalue_2d.resize(ni,nj); |
---|
| 1197 | if (hasBounds) |
---|
| 1198 | { |
---|
| 1199 | bounds_lon_2d.resize(nvertex, ni, nj); |
---|
| 1200 | bounds_lat_2d.resize(nvertex, ni, nj); |
---|
| 1201 | } |
---|
| 1202 | |
---|
| 1203 | for (int j = 0; j < nj; ++j) |
---|
| 1204 | { |
---|
| 1205 | for (int i = 0; i < ni; ++i) |
---|
| 1206 | { |
---|
| 1207 | int k = j * ni + i; |
---|
| 1208 | |
---|
| 1209 | lonvalue_2d(i,j) = lonvalue(k); |
---|
| 1210 | latvalue_2d(i,j) = latvalue(k); |
---|
| 1211 | |
---|
| 1212 | if (hasBounds) |
---|
| 1213 | { |
---|
| 1214 | for (int n = 0; n < nvertex; ++n) |
---|
| 1215 | { |
---|
| 1216 | bounds_lon_2d(n,i,j) = bounds_lonvalue(n,k); |
---|
| 1217 | bounds_lat_2d(n,i,j) = bounds_latvalue(n,k); |
---|
| 1218 | } |
---|
| 1219 | } |
---|
| 1220 | } |
---|
| 1221 | } |
---|
| 1222 | } |
---|
| 1223 | else if (!lonvalue_1d.isEmpty() && lonlatValueExisted) |
---|
| 1224 | { |
---|
| 1225 | if (type_attr::rectilinear == type) |
---|
| 1226 | { |
---|
| 1227 | if (ni == lonvalue_1d.numElements() && nj == latvalue_1d.numElements()) |
---|
| 1228 | { |
---|
| 1229 | lonvalue.resize(ni * nj); |
---|
| 1230 | latvalue.resize(ni * nj); |
---|
| 1231 | if (hasBounds) |
---|
| 1232 | { |
---|
| 1233 | bounds_lonvalue.resize(nvertex, ni * nj); |
---|
| 1234 | bounds_latvalue.resize(nvertex, ni * nj); |
---|
| 1235 | } |
---|
| 1236 | |
---|
| 1237 | for (int j = 0; j < nj; ++j) |
---|
| 1238 | { |
---|
| 1239 | for (int i = 0; i < ni; ++i) |
---|
| 1240 | { |
---|
| 1241 | int k = j * ni + i; |
---|
| 1242 | |
---|
| 1243 | lonvalue(k) = lonvalue_1d(i); |
---|
| 1244 | latvalue(k) = latvalue_1d(j); |
---|
| 1245 | |
---|
| 1246 | if (hasBounds) |
---|
| 1247 | { |
---|
| 1248 | for (int n = 0; n < nvertex; ++n) |
---|
| 1249 | { |
---|
| 1250 | bounds_lonvalue(n,k) = bounds_lon_1d(n,i); |
---|
| 1251 | bounds_latvalue(n,k) = bounds_lat_1d(n,j); |
---|
| 1252 | } |
---|
| 1253 | } |
---|
| 1254 | } |
---|
| 1255 | } |
---|
| 1256 | } |
---|
| 1257 | else if (i_index.numElements() == lonvalue_1d.numElements() && j_index.numElements() == latvalue_1d.numElements() && !lonlatValueExisted) |
---|
| 1258 | { |
---|
| 1259 | lonvalue.reference(lonvalue_1d); |
---|
| 1260 | latvalue.reference(latvalue_1d); |
---|
| 1261 | if (hasBounds) |
---|
| 1262 | { |
---|
| 1263 | bounds_lonvalue.reference(bounds_lon_1d); |
---|
| 1264 | bounds_latvalue.reference(bounds_lat_1d); |
---|
| 1265 | } |
---|
| 1266 | } |
---|
| 1267 | else |
---|
| 1268 | ERROR("CDomain::completeLonClient(void)", |
---|
| 1269 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1270 | << "'lonvalue_1d' and 'latvalue_1d' does not have the same size as the local domain." << std::endl |
---|
| 1271 | << "'lonvalue_1d' size is " << lonvalue_1d.numElements() |
---|
| 1272 | << " and 'latvalue_1d' size is " << latvalue_1d.numElements() << std::endl |
---|
| 1273 | << " They should be correspondingly " << ni.getValue() << " and " << nj.getValue() << " or " << std::endl |
---|
| 1274 | << i_index.numElements() << " and " << j_index.numElements() << "."); |
---|
| 1275 | } |
---|
| 1276 | else if (type == type_attr::curvilinear || type == type_attr::unstructured && !lonlatValueExisted) |
---|
| 1277 | { |
---|
| 1278 | lonvalue.reference(lonvalue_1d); |
---|
| 1279 | latvalue.reference(latvalue_1d); |
---|
| 1280 | if (hasBounds) |
---|
| 1281 | { |
---|
| 1282 | bounds_lonvalue.reference(bounds_lon_1d); |
---|
| 1283 | bounds_latvalue.reference(bounds_lat_1d); |
---|
| 1284 | } |
---|
| 1285 | } |
---|
| 1286 | } |
---|
| 1287 | } |
---|
| 1288 | |
---|
| 1289 | |
---|
[449] | 1290 | void CDomain::checkBounds(void) |
---|
| 1291 | { |
---|
[1099] | 1292 | bool hasBoundValues = (0 != bounds_lonvalue.numElements()) || (0 != bounds_latvalue.numElements()); |
---|
| 1293 | if (!nvertex.isEmpty() && nvertex > 0 && !hasBoundValues) |
---|
[449] | 1294 | { |
---|
[664] | 1295 | if (!bounds_lon_1d.isEmpty() && !bounds_lon_2d.isEmpty()) |
---|
| 1296 | ERROR("CDomain::checkBounds(void)", |
---|
[679] | 1297 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1298 | << "Only one longitude boundary attribute can be used but both 'bounds_lon_1d' and 'bounds_lon_2d' are defined." << std::endl |
---|
| 1299 | << "Define only one longitude boundary attribute: 'bounds_lon_1d' or 'bounds_lon_2d'."); |
---|
[664] | 1300 | |
---|
| 1301 | if (!bounds_lat_1d.isEmpty() && !bounds_lat_2d.isEmpty()) |
---|
| 1302 | ERROR("CDomain::checkBounds(void)", |
---|
[679] | 1303 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1304 | << "Only one latitude boundary attribute can be used but both 'bounds_lat_1d' and 'bounds_lat_2d' are defined." << std::endl |
---|
| 1305 | << "Define only one latitude boundary attribute: 'bounds_lat_1d' or 'bounds_lat_2d'."); |
---|
[664] | 1306 | |
---|
| 1307 | if ((!bounds_lon_1d.isEmpty() && bounds_lat_1d.isEmpty()) || (bounds_lon_1d.isEmpty() && !bounds_lat_1d.isEmpty())) |
---|
| 1308 | { |
---|
| 1309 | ERROR("CDomain::checkBounds(void)", |
---|
[679] | 1310 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1311 | << "Only 'bounds_lon_1d' or 'bounds_lat_1d' is defined." << std::endl |
---|
| 1312 | << "Please define either both attributes or none."); |
---|
[664] | 1313 | } |
---|
| 1314 | |
---|
| 1315 | if ((!bounds_lon_2d.isEmpty() && bounds_lat_2d.isEmpty()) || (bounds_lon_2d.isEmpty() && !bounds_lat_2d.isEmpty())) |
---|
| 1316 | { |
---|
| 1317 | ERROR("CDomain::checkBounds(void)", |
---|
[679] | 1318 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1319 | << "Only 'bounds_lon_2d' or 'bounds_lat_2d' is defined." << std::endl |
---|
| 1320 | << "Please define either both attributes or none."); |
---|
[664] | 1321 | } |
---|
| 1322 | |
---|
[691] | 1323 | if (!bounds_lon_1d.isEmpty() && nvertex.getValue() != bounds_lon_1d.extent(0)) |
---|
[679] | 1324 | ERROR("CDomain::checkBounds(void)", |
---|
| 1325 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1326 | << "'bounds_lon_1d' dimension is not compatible with 'nvertex'." << std::endl |
---|
| 1327 | << "'bounds_lon_1d' dimension is " << bounds_lon_1d.extent(1) |
---|
| 1328 | << " but nvertex is " << nvertex.getValue() << "."); |
---|
[664] | 1329 | |
---|
[691] | 1330 | if (!bounds_lon_2d.isEmpty() && nvertex.getValue() != bounds_lon_2d.extent(0)) |
---|
[679] | 1331 | ERROR("CDomain::checkBounds(void)", |
---|
| 1332 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1333 | << "'bounds_lon_2d' dimension is not compatible with 'nvertex'." << std::endl |
---|
| 1334 | << "'bounds_lon_2d' dimension is " << bounds_lon_2d.extent(2) |
---|
| 1335 | << " but nvertex is " << nvertex.getValue() << "."); |
---|
[664] | 1336 | |
---|
| 1337 | if (!bounds_lon_1d.isEmpty() && lonvalue_1d.isEmpty()) |
---|
[679] | 1338 | ERROR("CDomain::checkBounds(void)", |
---|
| 1339 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1340 | << "Since 'bounds_lon_1d' is defined, 'lonvalue_1d' must be defined too." << std::endl); |
---|
[664] | 1341 | |
---|
| 1342 | if (!bounds_lon_2d.isEmpty() && lonvalue_2d.isEmpty()) |
---|
[679] | 1343 | ERROR("CDomain::checkBounds(void)", |
---|
| 1344 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1345 | << "Since 'bounds_lon_2d' is defined, 'lonvalue_2d' must be defined too." << std::endl); |
---|
[664] | 1346 | |
---|
[691] | 1347 | if (!bounds_lat_1d.isEmpty() && nvertex.getValue() != bounds_lat_1d.extent(0)) |
---|
[679] | 1348 | ERROR("CDomain::checkBounds(void)", |
---|
| 1349 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1350 | << "'bounds_lat_1d' dimension is not compatible with 'nvertex'." << std::endl |
---|
| 1351 | << "'bounds_lat_1d' dimension is " << bounds_lat_1d.extent(1) |
---|
| 1352 | << " but nvertex is " << nvertex.getValue() << "."); |
---|
[664] | 1353 | |
---|
[691] | 1354 | if (!bounds_lat_2d.isEmpty() && nvertex.getValue() != bounds_lat_2d.extent(0)) |
---|
[679] | 1355 | ERROR("CDomain::checkBounds(void)", |
---|
| 1356 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1357 | << "'bounds_lat_2d' dimension is not compatible with 'nvertex'." << std::endl |
---|
| 1358 | << "'bounds_lat_2d' dimension is " << bounds_lat_2d.extent(2) |
---|
| 1359 | << " but nvertex is " << nvertex.getValue() << "."); |
---|
[664] | 1360 | |
---|
| 1361 | if (!bounds_lat_1d.isEmpty() && latvalue_1d.isEmpty()) |
---|
[679] | 1362 | ERROR("CDomain::checkBounds(void)", |
---|
| 1363 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1364 | << "Since 'bounds_lat_1d' is defined, 'latvalue_1d' must be defined too." << std::endl); |
---|
[664] | 1365 | |
---|
| 1366 | if (!bounds_lat_2d.isEmpty() && latvalue_2d.isEmpty()) |
---|
[679] | 1367 | ERROR("CDomain::checkBounds(void)", |
---|
| 1368 | << "Since 'bounds_lat_2d' is defined, 'latvalue_2d' must be defined too." << std::endl); |
---|
| 1369 | |
---|
| 1370 | hasBounds = true; |
---|
[449] | 1371 | } |
---|
[509] | 1372 | else |
---|
[449] | 1373 | { |
---|
[679] | 1374 | hasBounds = false; |
---|
| 1375 | nvertex = 0; |
---|
[449] | 1376 | } |
---|
| 1377 | } |
---|
[509] | 1378 | |
---|
[611] | 1379 | void CDomain::checkArea(void) |
---|
| 1380 | { |
---|
[1099] | 1381 | bool hasAreaValue = (0 != areavalue.numElements()); |
---|
[1025] | 1382 | hasArea = !area.isEmpty() || !areavalue.isEmpty(); |
---|
[611] | 1383 | if (hasArea) |
---|
| 1384 | { |
---|
| 1385 | if (area.extent(0) != ni || area.extent(1) != nj) |
---|
| 1386 | { |
---|
[679] | 1387 | ERROR("CDomain::checkArea(void)", |
---|
| 1388 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1389 | << "The area does not have the same size as the local domain." << std::endl |
---|
| 1390 | << "Local size is " << ni.getValue() << " x " << nj.getValue() << "." << std::endl |
---|
| 1391 | << "Area size is " << area.extent(0) << " x " << area.extent(1) << "."); |
---|
[611] | 1392 | } |
---|
[1025] | 1393 | if (areavalue.isEmpty()) |
---|
| 1394 | { |
---|
| 1395 | areavalue.resize(ni*nj); |
---|
| 1396 | for (int j = 0; j < nj; ++j) |
---|
| 1397 | { |
---|
| 1398 | for (int i = 0; i < ni; ++i) |
---|
| 1399 | { |
---|
| 1400 | int k = j * ni + i; |
---|
| 1401 | areavalue(k) = area(i,j); |
---|
| 1402 | } |
---|
| 1403 | } |
---|
| 1404 | } |
---|
[611] | 1405 | } |
---|
| 1406 | } |
---|
| 1407 | |
---|
[665] | 1408 | void CDomain::checkLonLat() |
---|
| 1409 | { |
---|
| 1410 | hasLonLat = (!latvalue_1d.isEmpty() && !lonvalue_1d.isEmpty()) || |
---|
| 1411 | (!latvalue_2d.isEmpty() && !lonvalue_2d.isEmpty()); |
---|
[1099] | 1412 | bool hasLonLatValue = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); |
---|
| 1413 | if (hasLonLat && !hasLonLatValue) |
---|
[666] | 1414 | { |
---|
| 1415 | if (!lonvalue_1d.isEmpty() && !lonvalue_2d.isEmpty()) |
---|
[762] | 1416 | ERROR("CDomain::checkLonLat()", |
---|
[679] | 1417 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1418 | << "Only one longitude attribute can be used but both 'lonvalue_1d' and 'lonvalue_2d' are defined." << std::endl |
---|
| 1419 | << "Define only one longitude attribute: 'lonvalue_1d' or 'lonvalue_2d'."); |
---|
[666] | 1420 | |
---|
| 1421 | if (!lonvalue_1d.isEmpty() && lonvalue_2d.isEmpty()) |
---|
| 1422 | { |
---|
[687] | 1423 | if ((type_attr::rectilinear != type) && (lonvalue_1d.numElements() != i_index.numElements())) |
---|
[762] | 1424 | ERROR("CDomain::checkLonLat()", |
---|
[679] | 1425 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1426 | << "'lonvalue_1d' does not have the same size as the local domain." << std::endl |
---|
| 1427 | << "Local size is " << i_index.numElements() << "." << std::endl |
---|
| 1428 | << "'lonvalue_1d' size is " << lonvalue_1d.numElements() << "."); |
---|
[666] | 1429 | } |
---|
| 1430 | |
---|
| 1431 | if (lonvalue_1d.isEmpty() && !lonvalue_2d.isEmpty()) |
---|
| 1432 | { |
---|
[679] | 1433 | if (lonvalue_2d.extent(0) != ni || lonvalue_2d.extent(1) != nj) |
---|
[762] | 1434 | ERROR("CDomain::checkLonLat()", |
---|
[679] | 1435 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1436 | << "'lonvalue_2d' does not have the same size as the local domain." << std::endl |
---|
| 1437 | << "Local size is " << ni.getValue() << " x " << nj.getValue() << "." << std::endl |
---|
| 1438 | << "'lonvalue_2d' size is " << lonvalue_2d.extent(0) << " x " << lonvalue_2d.extent(1) << "."); |
---|
[666] | 1439 | } |
---|
| 1440 | |
---|
| 1441 | if (!latvalue_1d.isEmpty() && !latvalue_2d.isEmpty()) |
---|
[762] | 1442 | ERROR("CDomain::checkLonLat()", |
---|
[679] | 1443 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1444 | << "Only one latitude attribute can be used but both 'latvalue_1d' and 'latvalue_2d' are defined." << std::endl |
---|
| 1445 | << "Define only one latitude attribute: 'latvalue_1d' or 'latvalue_2d'."); |
---|
[666] | 1446 | |
---|
| 1447 | if (!latvalue_1d.isEmpty() && latvalue_2d.isEmpty()) |
---|
| 1448 | { |
---|
[687] | 1449 | if ((type_attr::rectilinear != type) && (latvalue_1d.numElements() != i_index.numElements())) |
---|
[762] | 1450 | ERROR("CDomain::checkLonLat()", |
---|
[679] | 1451 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1452 | << "'latvalue_1d' does not have the same size as the local domain." << std::endl |
---|
| 1453 | << "Local size is " << i_index.numElements() << "." << std::endl |
---|
| 1454 | << "'latvalue_1d' size is " << latvalue_1d.numElements() << "."); |
---|
[666] | 1455 | } |
---|
| 1456 | |
---|
| 1457 | if (latvalue_1d.isEmpty() && !latvalue_2d.isEmpty()) |
---|
| 1458 | { |
---|
[679] | 1459 | if (latvalue_2d.extent(0) != ni || latvalue_2d.extent(1) != nj) |
---|
[762] | 1460 | ERROR("CDomain::checkLonLat()", |
---|
[679] | 1461 | << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " |
---|
| 1462 | << "'latvalue_2d' does not have the same size as the local domain." << std::endl |
---|
| 1463 | << "Local size is " << ni.getValue() << " x " << nj.getValue() << "." << std::endl |
---|
| 1464 | << "'latvalue_2d' size is " << latvalue_2d.extent(0) << " x " << latvalue_2d.extent(1) << "."); |
---|
[666] | 1465 | } |
---|
| 1466 | } |
---|
[665] | 1467 | } |
---|
| 1468 | |
---|
[657] | 1469 | void CDomain::checkAttributesOnClientAfterTransformation() |
---|
| 1470 | { |
---|
| 1471 | CContext* context=CContext::getCurrent() ; |
---|
| 1472 | |
---|
| 1473 | if (this->isClientAfterTransformationChecked) return; |
---|
| 1474 | if (context->hasClient) |
---|
| 1475 | { |
---|
[1025] | 1476 | // this->checkMask(); |
---|
| 1477 | this->computeConnectedClients(); |
---|
| 1478 | // if (hasLonLat || hasArea || isCompressible_) this->computeConnectedClients(); |
---|
[1054] | 1479 | if (hasLonLat) |
---|
| 1480 | if (!context->hasServer) |
---|
| 1481 | this->completeLonLatClient(); |
---|
[657] | 1482 | } |
---|
| 1483 | |
---|
| 1484 | this->isClientAfterTransformationChecked = true; |
---|
| 1485 | } |
---|
| 1486 | |
---|
[219] | 1487 | //---------------------------------------------------------------- |
---|
[667] | 1488 | // Divide function checkAttributes into 2 seperate ones |
---|
[509] | 1489 | // This function only checks all attributes of current domain |
---|
| 1490 | void CDomain::checkAttributesOnClient() |
---|
| 1491 | { |
---|
| 1492 | if (this->isClientChecked) return; |
---|
| 1493 | CContext* context=CContext::getCurrent(); |
---|
[219] | 1494 | |
---|
[1025] | 1495 | if (context->hasClient && !context->hasServer) |
---|
| 1496 | { |
---|
| 1497 | this->checkDomain(); |
---|
| 1498 | this->checkBounds(); |
---|
| 1499 | this->checkArea(); |
---|
| 1500 | this->checkLonLat(); |
---|
| 1501 | } |
---|
[509] | 1502 | |
---|
[1025] | 1503 | if (context->hasClient && !context->hasServer) |
---|
[1129] | 1504 | { // Ct client uniquement |
---|
[509] | 1505 | this->checkMask(); |
---|
| 1506 | this->checkDomainData(); |
---|
| 1507 | this->checkCompression(); |
---|
[893] | 1508 | this->computeLocalMask() ; |
---|
[509] | 1509 | } |
---|
| 1510 | else |
---|
[1129] | 1511 | { // Ct serveur uniquement |
---|
[509] | 1512 | } |
---|
| 1513 | |
---|
| 1514 | this->isClientChecked = true; |
---|
| 1515 | } |
---|
| 1516 | |
---|
| 1517 | // Send all checked attributes to server |
---|
| 1518 | void CDomain::sendCheckedAttributes() |
---|
| 1519 | { |
---|
| 1520 | if (!this->isClientChecked) checkAttributesOnClient(); |
---|
[657] | 1521 | if (!this->isClientAfterTransformationChecked) checkAttributesOnClientAfterTransformation(); |
---|
[509] | 1522 | CContext* context=CContext::getCurrent() ; |
---|
| 1523 | |
---|
| 1524 | if (this->isChecked) return; |
---|
| 1525 | if (context->hasClient) |
---|
| 1526 | { |
---|
[1054] | 1527 | // this->completeLonLatClient(); |
---|
[1025] | 1528 | sendAttributes(); |
---|
[509] | 1529 | } |
---|
| 1530 | this->isChecked = true; |
---|
| 1531 | } |
---|
| 1532 | |
---|
[219] | 1533 | void CDomain::checkAttributes(void) |
---|
| 1534 | { |
---|
| 1535 | if (this->isChecked) return; |
---|
[347] | 1536 | CContext* context=CContext::getCurrent() ; |
---|
[219] | 1537 | |
---|
[467] | 1538 | this->checkDomain(); |
---|
[665] | 1539 | this->checkLonLat(); |
---|
[449] | 1540 | this->checkBounds(); |
---|
[611] | 1541 | this->checkArea(); |
---|
[509] | 1542 | |
---|
[300] | 1543 | if (context->hasClient) |
---|
[1129] | 1544 | { // Ct client uniquement |
---|
[219] | 1545 | this->checkMask(); |
---|
| 1546 | this->checkDomainData(); |
---|
| 1547 | this->checkCompression(); |
---|
[893] | 1548 | this->computeLocalMask() ; |
---|
[666] | 1549 | |
---|
[219] | 1550 | } |
---|
| 1551 | else |
---|
[1129] | 1552 | { // Ct serveur uniquement |
---|
[219] | 1553 | } |
---|
[509] | 1554 | |
---|
[300] | 1555 | if (context->hasClient) |
---|
| 1556 | { |
---|
[1025] | 1557 | this->computeConnectedClients(); |
---|
[666] | 1558 | this->completeLonLatClient(); |
---|
[300] | 1559 | } |
---|
[509] | 1560 | |
---|
[219] | 1561 | this->isChecked = true; |
---|
| 1562 | } |
---|
[509] | 1563 | |
---|
[1054] | 1564 | |
---|
[1025] | 1565 | // void CDomain::computeConnectedClients(const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
| 1566 | // CServerDistributionDescription::ServerDistributionType distType) |
---|
| 1567 | /*! |
---|
| 1568 | Compute the connection of a client to other clients to determine which clients to send attributes to |
---|
| 1569 | */ |
---|
| 1570 | void CDomain::computeConnectedClients() |
---|
[657] | 1571 | { |
---|
[553] | 1572 | CContext* context=CContext::getCurrent() ; |
---|
[1099] | 1573 | |
---|
[1030] | 1574 | // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; |
---|
| 1575 | int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; |
---|
[1054] | 1576 | for (int p = 0; p < nbSrvPools; ++p) |
---|
[1027] | 1577 | { |
---|
[1054] | 1578 | CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client; |
---|
[1099] | 1579 | int nbServer = client->serverSize; |
---|
| 1580 | int rank = client->clientRank; |
---|
[1027] | 1581 | bool doComputeGlobalIndexServer = true; |
---|
[449] | 1582 | |
---|
[1027] | 1583 | int i,j,i_ind,j_ind, nbIndex, nbIndexZoom; |
---|
[1099] | 1584 | int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1; |
---|
| 1585 | int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1; |
---|
[509] | 1586 | |
---|
[1027] | 1587 | // Precompute number of index |
---|
| 1588 | int globalIndexCountZoom = 0; |
---|
| 1589 | nbIndex = i_index.numElements(); |
---|
[1099] | 1590 | |
---|
| 1591 | if (doZoomByIndex_) |
---|
| 1592 | { |
---|
| 1593 | globalIndexCountZoom = zoom_i_index.numElements(); |
---|
| 1594 | } |
---|
| 1595 | else |
---|
| 1596 | { |
---|
| 1597 | for (i = 0; i < nbIndex; ++i) |
---|
| 1598 | { |
---|
| 1599 | i_ind=i_index(i); |
---|
| 1600 | j_ind=j_index(i); |
---|
| 1601 | |
---|
| 1602 | if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) |
---|
| 1603 | { |
---|
| 1604 | ++globalIndexCountZoom; |
---|
| 1605 | } |
---|
| 1606 | } |
---|
| 1607 | } |
---|
| 1608 | |
---|
[1027] | 1609 | // for (i = 0; i < nbIndex; ++i) |
---|
| 1610 | // { |
---|
| 1611 | // i_ind=i_index(i); |
---|
| 1612 | // j_ind=j_index(i); |
---|
[657] | 1613 | |
---|
[1027] | 1614 | // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) |
---|
| 1615 | // { |
---|
| 1616 | // ++globalIndexCountZoom; |
---|
| 1617 | // } |
---|
| 1618 | // } |
---|
[467] | 1619 | |
---|
[1027] | 1620 | // int globalIndexWrittenCount = 0; |
---|
| 1621 | // if (isCompressible_) |
---|
| 1622 | // { |
---|
| 1623 | // for (i = 0; i < data_i_index.numElements(); ++i) |
---|
| 1624 | // { |
---|
| 1625 | // i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), |
---|
| 1626 | // data_ibegin, data_jbegin, data_dim, ni, |
---|
| 1627 | // j_ind); |
---|
| 1628 | // if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) |
---|
| 1629 | // { |
---|
| 1630 | // i_ind += ibegin; |
---|
| 1631 | // j_ind += jbegin; |
---|
| 1632 | // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) |
---|
| 1633 | // ++globalIndexWrittenCount; |
---|
| 1634 | // } |
---|
| 1635 | // } |
---|
| 1636 | // } |
---|
[676] | 1637 | |
---|
[1027] | 1638 | // Fill in index |
---|
[467] | 1639 | |
---|
[1099] | 1640 | CArray<size_t,1> globalIndexDomainZoom(globalIndexCountZoom); |
---|
[1027] | 1641 | CArray<size_t,1> localIndexDomainZoom(globalIndexCountZoom); |
---|
| 1642 | CArray<size_t,1> globalIndexDomain(nbIndex); |
---|
| 1643 | size_t globalIndex; |
---|
| 1644 | int globalIndexCount = 0; |
---|
[509] | 1645 | |
---|
[1027] | 1646 | for (i = 0; i < nbIndex; ++i) |
---|
| 1647 | { |
---|
| 1648 | i_ind=i_index(i); |
---|
| 1649 | j_ind=j_index(i); |
---|
| 1650 | globalIndex = i_ind + j_ind * ni_glo; |
---|
[1099] | 1651 | globalIndexDomain(i) = globalIndex; |
---|
[1027] | 1652 | } |
---|
| 1653 | |
---|
[1099] | 1654 | if (globalLocalIndexMap_.empty()) |
---|
| 1655 | { |
---|
| 1656 | for (i = 0; i < nbIndex; ++i) |
---|
| 1657 | globalLocalIndexMap_[globalIndexDomain(i)] = i; |
---|
| 1658 | } |
---|
| 1659 | |
---|
[1027] | 1660 | globalIndexCountZoom = 0; |
---|
[1099] | 1661 | if (doZoomByIndex_) |
---|
[1027] | 1662 | { |
---|
[1099] | 1663 | int nbIndexZoom = zoom_i_index.numElements(); |
---|
| 1664 | |
---|
| 1665 | for (i = 0; i < nbIndexZoom; ++i) |
---|
| 1666 | { |
---|
| 1667 | i_ind=zoom_i_index(i); |
---|
| 1668 | j_ind=zoom_j_index(i); |
---|
| 1669 | globalIndex = i_ind + j_ind * ni_glo; |
---|
| 1670 | globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; |
---|
| 1671 | ++globalIndexCountZoom; |
---|
| 1672 | // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) |
---|
| 1673 | // { |
---|
| 1674 | // globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; |
---|
| 1675 | // localIndexDomainZoom(globalIndexCountZoom) = i; |
---|
| 1676 | // ++globalIndexCountZoom; |
---|
| 1677 | // } |
---|
| 1678 | } |
---|
| 1679 | } |
---|
| 1680 | else |
---|
| 1681 | { |
---|
| 1682 | int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1; |
---|
| 1683 | int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1; |
---|
| 1684 | for (i = 0; i < nbIndex; ++i) |
---|
| 1685 | { |
---|
| 1686 | i_ind=i_index(i); |
---|
| 1687 | j_ind=j_index(i); |
---|
| 1688 | globalIndex = i_ind + j_ind * ni_glo; |
---|
| 1689 | if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) |
---|
| 1690 | { |
---|
| 1691 | globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; |
---|
| 1692 | ++globalIndexCountZoom; |
---|
| 1693 | } |
---|
| 1694 | } |
---|
[1027] | 1695 | |
---|
[1099] | 1696 | int iend = ibegin + ni -1; |
---|
| 1697 | int jend = jbegin + nj -1; |
---|
| 1698 | zoom_ibegin = global_zoom_ibegin > ibegin ? global_zoom_ibegin : ibegin; |
---|
| 1699 | int zoom_iend = global_zoom_iend < iend ? zoom_iend : iend ; |
---|
| 1700 | zoom_ni = zoom_iend-zoom_ibegin+1 ; |
---|
| 1701 | |
---|
| 1702 | zoom_jbegin = global_zoom_jbegin > jbegin ? global_zoom_jbegin : jbegin ; |
---|
| 1703 | int zoom_jend = global_zoom_jend < jend ? zoom_jend : jend; |
---|
| 1704 | zoom_nj = zoom_jend-zoom_jbegin+1; |
---|
[1027] | 1705 | } |
---|
| 1706 | |
---|
[1129] | 1707 | // if (globalLocalIndexZoomMap_.empty()) |
---|
| 1708 | // { |
---|
| 1709 | // int nbIndexZoom = globalIndexDomainZoom.numElements(); |
---|
| 1710 | // for (i = 0; i < nbIndex; ++i) |
---|
| 1711 | // globalLocalIndexZoomMap_[globalIndexDomainZoom(i)] = i; |
---|
| 1712 | // } |
---|
[1099] | 1713 | |
---|
[1129] | 1714 | |
---|
[1027] | 1715 | // CArray<int,1> globalIndexWrittenDomain(globalIndexWrittenCount); |
---|
| 1716 | // if (isCompressible_) |
---|
[1025] | 1717 | // { |
---|
[1027] | 1718 | // globalIndexWrittenCount = 0; |
---|
| 1719 | // for (i = 0; i < data_i_index.numElements(); ++i) |
---|
| 1720 | // { |
---|
| 1721 | // i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), |
---|
| 1722 | // data_ibegin, data_jbegin, data_dim, ni, |
---|
| 1723 | // j_ind); |
---|
| 1724 | // if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) |
---|
| 1725 | // { |
---|
| 1726 | // i_ind += ibegin; |
---|
| 1727 | // j_ind += jbegin; |
---|
| 1728 | // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) |
---|
| 1729 | // { |
---|
| 1730 | // globalIndexWrittenDomain(globalIndexWrittenCount) = i_ind + j_ind * ni_glo; |
---|
| 1731 | // ++globalIndexWrittenCount; |
---|
| 1732 | // } |
---|
| 1733 | // } |
---|
| 1734 | // } |
---|
[1025] | 1735 | // } |
---|
[569] | 1736 | |
---|
[1027] | 1737 | size_t globalSizeIndex = 1, indexBegin, indexEnd; |
---|
| 1738 | int range, clientSize = client->clientSize; |
---|
| 1739 | std::vector<int> nGlobDomain(2); |
---|
| 1740 | nGlobDomain[0] = this->ni_glo; |
---|
| 1741 | nGlobDomain[1] = this->nj_glo; |
---|
| 1742 | for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i]; |
---|
| 1743 | indexBegin = 0; |
---|
| 1744 | if (globalSizeIndex <= clientSize) |
---|
[906] | 1745 | { |
---|
[1027] | 1746 | indexBegin = rank%globalSizeIndex; |
---|
| 1747 | indexEnd = indexBegin; |
---|
[906] | 1748 | } |
---|
[1027] | 1749 | else |
---|
| 1750 | { |
---|
| 1751 | for (int i = 0; i < clientSize; ++i) |
---|
| 1752 | { |
---|
| 1753 | range = globalSizeIndex / clientSize; |
---|
| 1754 | if (i < (globalSizeIndex%clientSize)) ++range; |
---|
| 1755 | if (i == client->clientRank) break; |
---|
| 1756 | indexBegin += range; |
---|
| 1757 | } |
---|
| 1758 | indexEnd = indexBegin + range - 1; |
---|
| 1759 | } |
---|
[676] | 1760 | |
---|
[1027] | 1761 | CServerDistributionDescription serverDescription(nGlobDomain, nbServer); |
---|
| 1762 | if (isUnstructed_) serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0); |
---|
| 1763 | else serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 1); |
---|
[657] | 1764 | |
---|
[1027] | 1765 | CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), |
---|
| 1766 | client->intraComm); |
---|
| 1767 | clientServerMap->computeServerIndexMapping(globalIndexDomain); |
---|
| 1768 | CClientServerMapping::GlobalIndexMap& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); |
---|
[584] | 1769 | |
---|
[1027] | 1770 | CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexDomainOnServer.begin(), |
---|
| 1771 | ite = globalIndexDomainOnServer.end(); |
---|
| 1772 | // typedef XIOSBinarySearchWithIndex<size_t> BinarySearch; |
---|
| 1773 | // std::vector<int>::iterator itVec; |
---|
[668] | 1774 | |
---|
[1027] | 1775 | // indSrv_.clear(); |
---|
| 1776 | // indWrittenSrv_.clear(); |
---|
| 1777 | // for (; it != ite; ++it) |
---|
| 1778 | // { |
---|
| 1779 | // int rank = it->first; |
---|
| 1780 | // int indexSize = it->second.size(); |
---|
| 1781 | // std::vector<int> permutIndex(indexSize); |
---|
| 1782 | // XIOSAlgorithms::fillInIndex(indexSize, permutIndex); |
---|
| 1783 | // XIOSAlgorithms::sortWithIndex<size_t, CVectorStorage>(it->second, permutIndex); |
---|
| 1784 | // BinarySearch binSearch(it->second); |
---|
| 1785 | // int nb = globalIndexDomainZoom.numElements(); |
---|
| 1786 | // for (int i = 0; i < nb; ++i) |
---|
| 1787 | // { |
---|
| 1788 | // if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexDomainZoom(i), itVec)) |
---|
| 1789 | // { |
---|
| 1790 | // indSrv_[rank].push_back(localIndexDomainZoom(i)); |
---|
| 1791 | // } |
---|
| 1792 | // } |
---|
| 1793 | // for (int i = 0; i < globalIndexWrittenDomain.numElements(); ++i) |
---|
| 1794 | // { |
---|
| 1795 | // if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexWrittenDomain(i), itVec)) |
---|
| 1796 | // { |
---|
| 1797 | // indWrittenSrv_[rank].push_back(globalIndexWrittenDomain(i)); |
---|
| 1798 | // } |
---|
| 1799 | // } |
---|
| 1800 | // } |
---|
[584] | 1801 | |
---|
[1027] | 1802 | connectedServerRank_.clear(); |
---|
| 1803 | for (it = globalIndexDomainOnServer.begin(); it != ite; ++it) { |
---|
| 1804 | connectedServerRank_.push_back(it->first); |
---|
| 1805 | } |
---|
[584] | 1806 | |
---|
[1099] | 1807 | indSrv_.swap(globalIndexDomainOnServer); |
---|
[1027] | 1808 | nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); |
---|
[1025] | 1809 | |
---|
[1027] | 1810 | clientServerMap->computeServerIndexMapping(globalIndexDomainZoom); |
---|
| 1811 | CClientServerMapping::GlobalIndexMap& globalIndexDomainZoomOnServer = clientServerMap->getGlobalIndexOnServer(); |
---|
[1129] | 1812 | indZoomSrv_.swap(globalIndexDomainZoomOnServer); |
---|
| 1813 | |
---|
| 1814 | for (it = indZoomSrv_.begin(); it != indZoomSrv_.end(); ++it) |
---|
| 1815 | connectedServerZoomRank_.push_back(it->first); |
---|
[1027] | 1816 | |
---|
[1129] | 1817 | nbConnectedClientsZoom_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerZoomRank_); |
---|
| 1818 | |
---|
[1027] | 1819 | delete clientServerMap; |
---|
| 1820 | } |
---|
[300] | 1821 | } |
---|
[467] | 1822 | |
---|
[1025] | 1823 | const boost::unordered_map<int, vector<size_t> >& CDomain::getIndexServer() const |
---|
[657] | 1824 | { |
---|
| 1825 | return indSrv_; |
---|
| 1826 | } |
---|
| 1827 | |
---|
[1129] | 1828 | void CDomain::computeWrittenIndex() |
---|
| 1829 | { |
---|
| 1830 | if (computedWrittenIndex_) return; |
---|
| 1831 | computedWrittenIndex_ = true; |
---|
| 1832 | |
---|
| 1833 | CContext* context=CContext::getCurrent() ; |
---|
| 1834 | CContextClient* client = context->client; |
---|
| 1835 | |
---|
| 1836 | std::vector<int> nBegin(2), nSize(2), nBeginGlobal(2), nGlob(2); |
---|
| 1837 | nBegin[0] = zoom_ibegin; nBegin[1] = zoom_jbegin; |
---|
| 1838 | nSize[0] = zoom_ni; nSize[1] = zoom_nj; |
---|
| 1839 | nBeginGlobal[0] = 0; nBeginGlobal[1] = 0; |
---|
| 1840 | nGlob[0] = ni_glo; nGlob[1] = nj_glo; |
---|
| 1841 | CDistributionServer srvDist(client->clientSize, nBegin, nSize, nBeginGlobal, nGlob); |
---|
| 1842 | const CArray<size_t,1>& writtenGlobalIndex = srvDist.getGlobalIndex(); |
---|
| 1843 | |
---|
| 1844 | size_t nbWritten = 0, indGlo; |
---|
| 1845 | boost::unordered_map<size_t,size_t>::const_iterator itb = globalLocalIndexMap_.begin(), |
---|
| 1846 | ite = globalLocalIndexMap_.end(), it; |
---|
| 1847 | CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(), |
---|
| 1848 | itSrve = writtenGlobalIndex.end(), itSrv; |
---|
| 1849 | localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); |
---|
| 1850 | for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) |
---|
| 1851 | { |
---|
| 1852 | indGlo = *itSrv; |
---|
| 1853 | if (ite != globalLocalIndexMap_.find(indGlo)) |
---|
| 1854 | { |
---|
| 1855 | localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; |
---|
| 1856 | ++nbWritten; |
---|
| 1857 | } |
---|
| 1858 | } |
---|
| 1859 | } |
---|
| 1860 | |
---|
[667] | 1861 | /*! |
---|
[1025] | 1862 | Send all attributes from client to connected clients |
---|
| 1863 | The attributes will be rebuilt on receiving side |
---|
[667] | 1864 | */ |
---|
[1025] | 1865 | void CDomain::sendAttributes() |
---|
| 1866 | { |
---|
[1054] | 1867 | sendDistributionAttributes(); |
---|
[1129] | 1868 | sendIndex(); |
---|
| 1869 | // sendIndexZoom(); |
---|
[1025] | 1870 | sendMask(); |
---|
| 1871 | sendLonLat(); |
---|
| 1872 | sendArea(); |
---|
| 1873 | sendDataIndex(); |
---|
| 1874 | } |
---|
| 1875 | |
---|
| 1876 | /*! |
---|
| 1877 | Send global index and zoom index from client to connected client(s) |
---|
| 1878 | zoom index can be smaller than global index |
---|
| 1879 | */ |
---|
[665] | 1880 | void CDomain::sendIndex() |
---|
[300] | 1881 | { |
---|
[610] | 1882 | int ns, n, i, j, ind, nv, idx; |
---|
| 1883 | CContext* context = CContext::getCurrent(); |
---|
[1099] | 1884 | |
---|
[1030] | 1885 | // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; |
---|
| 1886 | int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; |
---|
[1054] | 1887 | for (int p = 0; p < nbSrvPools; ++p) |
---|
[1027] | 1888 | { |
---|
[1054] | 1889 | CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client; |
---|
[610] | 1890 | |
---|
[1027] | 1891 | CEventClient eventIndex(getType(), EVENT_ID_INDEX); |
---|
[665] | 1892 | |
---|
[1027] | 1893 | list<CMessage> list_msgsIndex; |
---|
| 1894 | list<CArray<int,1> > list_indZoom, list_writtenInd, list_indGlob; |
---|
[665] | 1895 | |
---|
[1129] | 1896 | boost::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex; |
---|
| 1897 | iteIndex = indSrv_.end(); |
---|
[1027] | 1898 | for (int k = 0; k < connectedServerRank_.size(); ++k) |
---|
| 1899 | { |
---|
| 1900 | int nbIndGlob = 0; |
---|
| 1901 | int rank = connectedServerRank_[k]; |
---|
| 1902 | itIndex = indSrv_.find(rank); |
---|
| 1903 | if (iteIndex != itIndex) |
---|
| 1904 | nbIndGlob = itIndex->second.size(); |
---|
[665] | 1905 | |
---|
[1129] | 1906 | list_indGlob.push_back(CArray<int,1>(nbIndGlob)); |
---|
[665] | 1907 | |
---|
[1027] | 1908 | CArray<int,1>& indGlob = list_indGlob.back(); |
---|
| 1909 | for (n = 0; n < nbIndGlob; ++n) |
---|
| 1910 | { |
---|
| 1911 | indGlob(n) = static_cast<int>(itIndex->second[n]); |
---|
| 1912 | } |
---|
[665] | 1913 | |
---|
[1027] | 1914 | list_msgsIndex.push_back(CMessage()); |
---|
| 1915 | list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix |
---|
| 1916 | list_msgsIndex.back() << isCurvilinear; |
---|
[1129] | 1917 | list_msgsIndex.back() << list_indGlob.back(); //list_indi.back() << list_indj.back(); |
---|
[1099] | 1918 | |
---|
[1027] | 1919 | // if (isCompressible_) |
---|
| 1920 | // { |
---|
| 1921 | // std::vector<int>& writtenIndSrc = indWrittenSrv_[rank]; |
---|
| 1922 | // list_writtenInd.push_back(CArray<int,1>(writtenIndSrc.size())); |
---|
| 1923 | // CArray<int,1>& writtenInd = list_writtenInd.back(); |
---|
[676] | 1924 | |
---|
[1027] | 1925 | // for (n = 0; n < writtenInd.numElements(); ++n) |
---|
| 1926 | // writtenInd(n) = writtenIndSrc[n]; |
---|
[676] | 1927 | |
---|
[1027] | 1928 | // list_msgsIndex.back() << writtenInd; |
---|
| 1929 | // } |
---|
[676] | 1930 | |
---|
[1027] | 1931 | eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); |
---|
| 1932 | } |
---|
| 1933 | |
---|
| 1934 | client->sendEvent(eventIndex); |
---|
[665] | 1935 | } |
---|
| 1936 | } |
---|
| 1937 | |
---|
[667] | 1938 | /*! |
---|
[1129] | 1939 | Send global index and zoom index from client to connected client(s) |
---|
| 1940 | zoom index can be smaller than global index |
---|
| 1941 | */ |
---|
| 1942 | void CDomain::sendIndexZoom() |
---|
| 1943 | { |
---|
| 1944 | int ns, n, i, j, ind, nv, idx; |
---|
| 1945 | CContext* context = CContext::getCurrent(); |
---|
| 1946 | |
---|
| 1947 | // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; |
---|
| 1948 | int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; |
---|
| 1949 | for (int p = 0; p < nbSrvPools; ++p) |
---|
| 1950 | { |
---|
| 1951 | CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client; |
---|
| 1952 | CEventClient eventIndexZoom(getType(), EVENT_ID_INDEX_ZOOM); |
---|
| 1953 | |
---|
| 1954 | list<CMessage> list_msgsIndex; |
---|
| 1955 | list<CArray<int,1> > list_indZoom; |
---|
| 1956 | |
---|
| 1957 | boost::unordered_map<int, vector<size_t> >::const_iterator itZoom, iteZoom; |
---|
| 1958 | iteZoom = indZoomSrv_.end(); |
---|
| 1959 | for (int k = 0; k < connectedServerZoomRank_.size(); ++k) |
---|
| 1960 | { |
---|
| 1961 | int nbIndGlob = 0; |
---|
| 1962 | int rank = connectedServerZoomRank_[k]; |
---|
| 1963 | int nbIndZoom = 0; |
---|
| 1964 | itZoom = indZoomSrv_.find(rank); |
---|
| 1965 | if (iteZoom != itZoom) |
---|
| 1966 | nbIndZoom = itZoom->second.size(); |
---|
| 1967 | |
---|
| 1968 | list_indZoom.push_back(CArray<int,1>(nbIndZoom)); |
---|
| 1969 | CArray<int,1>& indZoom = list_indZoom.back(); |
---|
| 1970 | for (n = 0; n < nbIndZoom; ++n) |
---|
| 1971 | { |
---|
| 1972 | indZoom(n) = static_cast<int>(itZoom->second[n]); |
---|
| 1973 | } |
---|
| 1974 | |
---|
| 1975 | list_msgsIndex.push_back(CMessage()); |
---|
| 1976 | list_msgsIndex.back() << this->getId(); // enum ne fonctionne pour les message => ToFix |
---|
| 1977 | list_msgsIndex.back() << list_indZoom.back() << doZoomByIndex_; //list_indi.back() << list_indj.back |
---|
| 1978 | |
---|
| 1979 | eventIndexZoom.push(rank, nbConnectedClientsZoom_[rank], list_msgsIndex.back()); |
---|
| 1980 | } |
---|
| 1981 | |
---|
| 1982 | client->sendEvent(eventIndexZoom); |
---|
| 1983 | } |
---|
| 1984 | } |
---|
| 1985 | |
---|
| 1986 | /*! |
---|
[1099] | 1987 | Send distribution from client to other clients |
---|
| 1988 | Because a client in a level knows correctly the grid distribution of client on the next level |
---|
| 1989 | it calculates this distribution then sends it to the corresponding clients on the next level |
---|
| 1990 | */ |
---|
| 1991 | void CDomain::sendDistributionAttributes(void) |
---|
| 1992 | { |
---|
| 1993 | CContext* context = CContext::getCurrent(); |
---|
| 1994 | // Use correct context client to send message |
---|
| 1995 | // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; |
---|
| 1996 | int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; |
---|
| 1997 | for (int i = 0; i < nbSrvPools; ++i) |
---|
| 1998 | { |
---|
| 1999 | CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i] |
---|
| 2000 | : context->client; |
---|
| 2001 | int nbServer = contextClientTmp->serverSize; |
---|
| 2002 | std::vector<int> nGlobDomain(2); |
---|
| 2003 | nGlobDomain[0] = this->ni_glo; |
---|
| 2004 | nGlobDomain[1] = this->nj_glo; |
---|
| 2005 | |
---|
| 2006 | CServerDistributionDescription serverDescription(nGlobDomain, nbServer); |
---|
| 2007 | if (isUnstructed_) serverDescription.computeServerDistribution(false, 0); |
---|
| 2008 | else serverDescription.computeServerDistribution(false, 1); |
---|
| 2009 | |
---|
| 2010 | std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); |
---|
| 2011 | std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); |
---|
| 2012 | |
---|
| 2013 | CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT); |
---|
| 2014 | if (contextClientTmp->isServerLeader()) |
---|
| 2015 | { |
---|
| 2016 | std::list<CMessage> msgs; |
---|
| 2017 | |
---|
| 2018 | const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); |
---|
| 2019 | for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) |
---|
| 2020 | { |
---|
| 2021 | // Use const int to ensure CMessage holds a copy of the value instead of just a reference |
---|
| 2022 | const int ibegin_srv = serverIndexBegin[*itRank][0]; |
---|
| 2023 | const int jbegin_srv = serverIndexBegin[*itRank][1]; |
---|
| 2024 | const int ni_srv = serverDimensionSizes[*itRank][0]; |
---|
| 2025 | const int nj_srv = serverDimensionSizes[*itRank][1]; |
---|
| 2026 | |
---|
| 2027 | msgs.push_back(CMessage()); |
---|
| 2028 | CMessage& msg = msgs.back(); |
---|
| 2029 | msg << this->getId() ; |
---|
| 2030 | msg << ni_srv << ibegin_srv << nj_srv << jbegin_srv; |
---|
| 2031 | msg << global_zoom_ni.getValue() << global_zoom_ibegin.getValue() << global_zoom_nj.getValue() << global_zoom_jbegin.getValue(); |
---|
| 2032 | msg << isCompressible_; |
---|
| 2033 | |
---|
| 2034 | event.push(*itRank,1,msg); |
---|
| 2035 | } |
---|
| 2036 | contextClientTmp->sendEvent(event); |
---|
| 2037 | } |
---|
| 2038 | else contextClientTmp->sendEvent(event); |
---|
| 2039 | } |
---|
| 2040 | } |
---|
| 2041 | |
---|
| 2042 | /*! |
---|
[1025] | 2043 | Send mask index from client to connected(s) |
---|
[667] | 2044 | */ |
---|
[1025] | 2045 | void CDomain::sendMask() |
---|
| 2046 | { |
---|
| 2047 | int ns, n, i, j, ind, nv, idx; |
---|
| 2048 | CContext* context = CContext::getCurrent(); |
---|
[1099] | 2049 | |
---|
[1030] | 2050 | // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; |
---|
| 2051 | int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; |
---|
[1054] | 2052 | for (int p = 0; p < nbSrvPools; ++p) |
---|
[1027] | 2053 | { |
---|
[1054] | 2054 | CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client; |
---|
[1025] | 2055 | |
---|
[1027] | 2056 | // send area for each connected server |
---|
| 2057 | CEventClient eventMask(getType(), EVENT_ID_MASK); |
---|
[1025] | 2058 | |
---|
[1027] | 2059 | list<CMessage> list_msgsMask; |
---|
| 2060 | list<CArray<bool,1> > list_mask; |
---|
[1025] | 2061 | |
---|
[1027] | 2062 | boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; |
---|
| 2063 | iteMap = indSrv_.end(); |
---|
| 2064 | for (int k = 0; k < connectedServerRank_.size(); ++k) |
---|
| 2065 | { |
---|
| 2066 | int nbData = 0; |
---|
| 2067 | int rank = connectedServerRank_[k]; |
---|
| 2068 | it = indSrv_.find(rank); |
---|
| 2069 | if (iteMap != it) |
---|
| 2070 | nbData = it->second.size(); |
---|
| 2071 | list_mask.push_back(CArray<bool,1>(nbData)); |
---|
[1025] | 2072 | |
---|
[1027] | 2073 | const std::vector<size_t>& temp = it->second; |
---|
| 2074 | for (n = 0; n < nbData; ++n) |
---|
| 2075 | { |
---|
| 2076 | idx = static_cast<int>(it->second[n]); |
---|
| 2077 | list_mask.back()(n) = mask_1d(globalLocalIndexMap_[idx]); |
---|
| 2078 | } |
---|
| 2079 | |
---|
| 2080 | list_msgsMask.push_back(CMessage()); |
---|
| 2081 | list_msgsMask.back() << this->getId() << list_mask.back(); |
---|
| 2082 | eventMask.push(rank, nbConnectedClients_[rank], list_msgsMask.back()); |
---|
[1025] | 2083 | } |
---|
[1027] | 2084 | client->sendEvent(eventMask); |
---|
[1025] | 2085 | } |
---|
| 2086 | } |
---|
| 2087 | |
---|
| 2088 | /*! |
---|
| 2089 | Send area from client to connected client(s) |
---|
| 2090 | */ |
---|
[665] | 2091 | void CDomain::sendArea() |
---|
| 2092 | { |
---|
| 2093 | if (!hasArea) return; |
---|
| 2094 | |
---|
| 2095 | int ns, n, i, j, ind, nv, idx; |
---|
| 2096 | CContext* context = CContext::getCurrent(); |
---|
[1099] | 2097 | |
---|
[1030] | 2098 | // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; |
---|
| 2099 | int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; |
---|
[1054] | 2100 | for (int p = 0; p < nbSrvPools; ++p) |
---|
[1027] | 2101 | { |
---|
[1054] | 2102 | CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client; |
---|
[665] | 2103 | |
---|
[1027] | 2104 | // send area for each connected server |
---|
| 2105 | CEventClient eventArea(getType(), EVENT_ID_AREA); |
---|
[665] | 2106 | |
---|
[1027] | 2107 | list<CMessage> list_msgsArea; |
---|
| 2108 | list<CArray<double,1> > list_area; |
---|
[665] | 2109 | |
---|
[1027] | 2110 | boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; |
---|
| 2111 | iteMap = indSrv_.end(); |
---|
| 2112 | for (int k = 0; k < connectedServerRank_.size(); ++k) |
---|
| 2113 | { |
---|
| 2114 | int nbData = 0; |
---|
| 2115 | int rank = connectedServerRank_[k]; |
---|
| 2116 | it = indSrv_.find(rank); |
---|
| 2117 | if (iteMap != it) |
---|
| 2118 | nbData = it->second.size(); |
---|
| 2119 | list_area.push_back(CArray<double,1>(nbData)); |
---|
[665] | 2120 | |
---|
[1027] | 2121 | const std::vector<size_t>& temp = it->second; |
---|
| 2122 | for (n = 0; n < nbData; ++n) |
---|
| 2123 | { |
---|
| 2124 | idx = static_cast<int>(it->second[n]); |
---|
| 2125 | list_area.back()(n) = areavalue(globalLocalIndexMap_[idx]); |
---|
| 2126 | } |
---|
| 2127 | |
---|
| 2128 | list_msgsArea.push_back(CMessage()); |
---|
| 2129 | list_msgsArea.back() << this->getId() << hasArea; |
---|
| 2130 | list_msgsArea.back() << list_area.back(); |
---|
| 2131 | eventArea.push(rank, nbConnectedClients_[rank], list_msgsArea.back()); |
---|
[665] | 2132 | } |
---|
[1027] | 2133 | client->sendEvent(eventArea); |
---|
[665] | 2134 | } |
---|
| 2135 | } |
---|
| 2136 | |
---|
[667] | 2137 | /*! |
---|
| 2138 | Send longitude and latitude from client to servers |
---|
| 2139 | Each client send long and lat information to corresponding connected server(s). |
---|
| 2140 | Because longitude and latitude are optional, this function only called if latitude and longitude exist |
---|
| 2141 | */ |
---|
[665] | 2142 | void CDomain::sendLonLat() |
---|
| 2143 | { |
---|
| 2144 | if (!hasLonLat) return; |
---|
| 2145 | |
---|
| 2146 | int ns, n, i, j, ind, nv, idx; |
---|
| 2147 | CContext* context = CContext::getCurrent(); |
---|
[1099] | 2148 | |
---|
[1030] | 2149 | // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; |
---|
| 2150 | int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; |
---|
[1054] | 2151 | for (int p = 0; p < nbSrvPools; ++p) |
---|
[300] | 2152 | { |
---|
[1054] | 2153 | CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client; |
---|
[584] | 2154 | |
---|
[1027] | 2155 | // send lon lat for each connected server |
---|
| 2156 | CEventClient eventLon(getType(), EVENT_ID_LON); |
---|
| 2157 | CEventClient eventLat(getType(), EVENT_ID_LAT); |
---|
[509] | 2158 | |
---|
[1027] | 2159 | list<CMessage> list_msgsLon, list_msgsLat; |
---|
| 2160 | list<CArray<double,1> > list_lon, list_lat; |
---|
| 2161 | list<CArray<double,2> > list_boundslon, list_boundslat; |
---|
[610] | 2162 | |
---|
[1027] | 2163 | boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; |
---|
| 2164 | iteMap = indSrv_.end(); |
---|
| 2165 | for (int k = 0; k < connectedServerRank_.size(); ++k) |
---|
[467] | 2166 | { |
---|
[1027] | 2167 | int nbData = 0; |
---|
| 2168 | int rank = connectedServerRank_[k]; |
---|
| 2169 | it = indSrv_.find(rank); |
---|
| 2170 | if (iteMap != it) |
---|
| 2171 | nbData = it->second.size(); |
---|
[509] | 2172 | |
---|
[1027] | 2173 | list_lon.push_back(CArray<double,1>(nbData)); |
---|
| 2174 | list_lat.push_back(CArray<double,1>(nbData)); |
---|
| 2175 | |
---|
[467] | 2176 | if (hasBounds) |
---|
[300] | 2177 | { |
---|
[1027] | 2178 | list_boundslon.push_back(CArray<double,2>(nvertex, nbData)); |
---|
| 2179 | list_boundslat.push_back(CArray<double,2>(nvertex, nbData)); |
---|
| 2180 | } |
---|
[610] | 2181 | |
---|
[1027] | 2182 | CArray<double,1>& lon = list_lon.back(); |
---|
| 2183 | CArray<double,1>& lat = list_lat.back(); |
---|
| 2184 | const std::vector<size_t>& temp = it->second; |
---|
| 2185 | for (n = 0; n < nbData; ++n) |
---|
| 2186 | { |
---|
| 2187 | idx = static_cast<int>(it->second[n]); |
---|
| 2188 | int localInd = globalLocalIndexMap_[idx]; |
---|
| 2189 | lon(n) = lonvalue(localInd); |
---|
| 2190 | lat(n) = latvalue(localInd); |
---|
| 2191 | |
---|
| 2192 | if (hasBounds) |
---|
[449] | 2193 | { |
---|
[1027] | 2194 | CArray<double,2>& boundslon = list_boundslon.back(); |
---|
| 2195 | CArray<double,2>& boundslat = list_boundslat.back(); |
---|
| 2196 | |
---|
| 2197 | for (nv = 0; nv < nvertex; ++nv) |
---|
| 2198 | { |
---|
| 2199 | boundslon(nv, n) = bounds_lonvalue(nv, localInd); |
---|
| 2200 | boundslat(nv, n) = bounds_latvalue(nv, localInd); |
---|
| 2201 | } |
---|
[449] | 2202 | } |
---|
[300] | 2203 | } |
---|
[509] | 2204 | |
---|
[1027] | 2205 | list_msgsLon.push_back(CMessage()); |
---|
| 2206 | list_msgsLat.push_back(CMessage()); |
---|
[518] | 2207 | |
---|
[1129] | 2208 | list_msgsLon.back() << this->getId() << hasLonLat; |
---|
| 2209 | if (hasLonLat) |
---|
| 2210 | list_msgsLon.back() << list_lon.back(); |
---|
| 2211 | list_msgsLon.back() << hasBounds; |
---|
[1027] | 2212 | if (hasBounds) |
---|
| 2213 | { |
---|
| 2214 | list_msgsLon.back() << list_boundslon.back(); |
---|
[1129] | 2215 | } |
---|
| 2216 | |
---|
| 2217 | list_msgsLat.back() << this->getId() << hasLonLat; |
---|
| 2218 | if (hasLonLat) |
---|
| 2219 | list_msgsLat.back() << list_lat.back(); |
---|
| 2220 | list_msgsLat.back() << hasBounds; |
---|
| 2221 | if (hasBounds) |
---|
| 2222 | { |
---|
[1027] | 2223 | list_msgsLat.back() << list_boundslat.back(); |
---|
| 2224 | } |
---|
| 2225 | |
---|
| 2226 | eventLon.push(rank, nbConnectedClients_[rank], list_msgsLon.back()); |
---|
| 2227 | eventLat.push(rank, nbConnectedClients_[rank], list_msgsLat.back()); |
---|
[518] | 2228 | } |
---|
[1027] | 2229 | client->sendEvent(eventLon); |
---|
| 2230 | client->sendEvent(eventLat); |
---|
[300] | 2231 | } |
---|
| 2232 | } |
---|
[509] | 2233 | |
---|
[667] | 2234 | /*! |
---|
[1025] | 2235 | Send data index to corresponding connected clients. |
---|
| 2236 | Data index can be compressed however, we always send decompressed data index |
---|
| 2237 | and they will be compressed on receiving. |
---|
[667] | 2238 | */ |
---|
[1025] | 2239 | void CDomain::sendDataIndex() |
---|
[665] | 2240 | { |
---|
[1025] | 2241 | int ns, n, i, j, ind, nv, idx; |
---|
| 2242 | CContext* context = CContext::getCurrent(); |
---|
[1099] | 2243 | |
---|
[1030] | 2244 | // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; |
---|
| 2245 | int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; |
---|
[1054] | 2246 | for (int p = 0; p < nbSrvPools; ++p) |
---|
[1027] | 2247 | { |
---|
[1054] | 2248 | CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client; |
---|
[1025] | 2249 | |
---|
[1027] | 2250 | // send area for each connected server |
---|
| 2251 | CEventClient eventDataIndex(getType(), EVENT_ID_DATA_INDEX); |
---|
[1025] | 2252 | |
---|
[1027] | 2253 | list<CMessage> list_msgsDataIndex; |
---|
| 2254 | list<CArray<int,1> > list_data_i_index, list_data_j_index; |
---|
[1025] | 2255 | |
---|
[1027] | 2256 | int nbIndex = i_index.numElements(); |
---|
[1129] | 2257 | int niByIndex = max(i_index) - min(i_index) + 1; |
---|
| 2258 | int njByIndex = max(j_index) - min(j_index) + 1; |
---|
| 2259 | int dataIindexBound = (1 == data_dim) ? (niByIndex * njByIndex) : niByIndex; |
---|
| 2260 | int dataJindexBound = (1 == data_dim) ? (niByIndex * njByIndex) : njByIndex; |
---|
| 2261 | |
---|
| 2262 | |
---|
[1027] | 2263 | CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); |
---|
[1129] | 2264 | dataIIndex = -1; |
---|
| 2265 | dataJIndex = -1; |
---|
| 2266 | ind = 0; |
---|
| 2267 | |
---|
[1027] | 2268 | for (idx = 0; idx < data_i_index.numElements(); ++idx) |
---|
[1025] | 2269 | { |
---|
[1129] | 2270 | int dataIidx = data_i_index(idx) + data_ibegin; |
---|
| 2271 | int dataJidx = data_j_index(idx) + data_jbegin; |
---|
| 2272 | if ((0 <= dataIidx) && (dataIidx < dataIindexBound) && |
---|
| 2273 | (0 <= dataJidx) && (dataJidx < dataJindexBound)) |
---|
[1027] | 2274 | { |
---|
[1129] | 2275 | dataIIndex((1 == data_dim) ? dataIidx : dataJidx * ni + dataIidx) = 1; //i_index(dataIidx);//dataIidx; |
---|
| 2276 | dataJIndex((1 == data_dim) ? dataIidx : dataJidx * ni + dataIidx) = 1; //j_index(dataJidx);// |
---|
[1027] | 2277 | } |
---|
[1025] | 2278 | } |
---|
| 2279 | |
---|
[1027] | 2280 | boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; |
---|
| 2281 | iteMap = indSrv_.end(); |
---|
| 2282 | for (int k = 0; k < connectedServerRank_.size(); ++k) |
---|
| 2283 | { |
---|
| 2284 | int nbData = 0; |
---|
| 2285 | int rank = connectedServerRank_[k]; |
---|
| 2286 | it = indSrv_.find(rank); |
---|
| 2287 | if (iteMap != it) |
---|
| 2288 | nbData = it->second.size(); |
---|
| 2289 | list_data_i_index.push_back(CArray<int,1>(nbData)); |
---|
| 2290 | list_data_j_index.push_back(CArray<int,1>(nbData)); |
---|
[1025] | 2291 | |
---|
[1027] | 2292 | const std::vector<size_t>& temp = it->second; |
---|
| 2293 | for (n = 0; n < nbData; ++n) |
---|
| 2294 | { |
---|
| 2295 | idx = static_cast<int>(it->second[n]); |
---|
| 2296 | i = globalLocalIndexMap_[idx]; |
---|
| 2297 | list_data_i_index.back()(n) = dataIIndex(i); |
---|
| 2298 | list_data_j_index.back()(n) = dataJIndex(i); |
---|
| 2299 | } |
---|
| 2300 | |
---|
| 2301 | list_msgsDataIndex.push_back(CMessage()); |
---|
| 2302 | list_msgsDataIndex.back() << this->getId(); |
---|
| 2303 | list_msgsDataIndex.back() << list_data_i_index.back() << list_data_j_index.back(); |
---|
| 2304 | eventDataIndex.push(rank, nbConnectedClients_[rank], list_msgsDataIndex.back()); |
---|
[1025] | 2305 | } |
---|
[1027] | 2306 | client->sendEvent(eventDataIndex); |
---|
[1025] | 2307 | } |
---|
[665] | 2308 | } |
---|
[1025] | 2309 | |
---|
[300] | 2310 | bool CDomain::dispatchEvent(CEventServer& event) |
---|
[610] | 2311 | { |
---|
| 2312 | if (SuperClass::dispatchEvent(event)) return true; |
---|
| 2313 | else |
---|
| 2314 | { |
---|
| 2315 | switch(event.type) |
---|
[300] | 2316 | { |
---|
[610] | 2317 | case EVENT_ID_SERVER_ATTRIBUT: |
---|
[1025] | 2318 | recvDistributionAttributes(event); |
---|
[610] | 2319 | return true; |
---|
| 2320 | break; |
---|
| 2321 | case EVENT_ID_INDEX: |
---|
| 2322 | recvIndex(event); |
---|
| 2323 | return true; |
---|
| 2324 | break; |
---|
[1129] | 2325 | case EVENT_ID_INDEX_ZOOM: |
---|
| 2326 | recvIndexZoom(event); |
---|
| 2327 | return true; |
---|
| 2328 | break; |
---|
[1025] | 2329 | case EVENT_ID_MASK: |
---|
| 2330 | recvMask(event); |
---|
| 2331 | return true; |
---|
| 2332 | break; |
---|
[610] | 2333 | case EVENT_ID_LON: |
---|
| 2334 | recvLon(event); |
---|
| 2335 | return true; |
---|
| 2336 | break; |
---|
| 2337 | case EVENT_ID_LAT: |
---|
| 2338 | recvLat(event); |
---|
| 2339 | return true; |
---|
| 2340 | break; |
---|
[611] | 2341 | case EVENT_ID_AREA: |
---|
| 2342 | recvArea(event); |
---|
| 2343 | return true; |
---|
[1025] | 2344 | break; |
---|
| 2345 | case EVENT_ID_DATA_INDEX: |
---|
| 2346 | recvDataIndex(event); |
---|
| 2347 | return true; |
---|
[611] | 2348 | break; |
---|
[610] | 2349 | default: |
---|
[762] | 2350 | ERROR("bool CDomain::dispatchEvent(CEventServer& event)", |
---|
[610] | 2351 | << "Unknown Event"); |
---|
| 2352 | return false; |
---|
| 2353 | } |
---|
| 2354 | } |
---|
| 2355 | } |
---|
[509] | 2356 | |
---|
[667] | 2357 | /*! |
---|
[1025] | 2358 | Receive index event from clients(s) |
---|
| 2359 | \param[in] event event contain info about rank and associated index |
---|
| 2360 | */ |
---|
| 2361 | void CDomain::recvIndex(CEventServer& event) |
---|
| 2362 | { |
---|
| 2363 | string domainId; |
---|
| 2364 | std::map<int, CBufferIn*> rankBuffers; |
---|
[821] | 2365 | |
---|
[1025] | 2366 | list<CEventServer::SSubEvent>::iterator it; |
---|
| 2367 | for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) |
---|
| 2368 | { |
---|
| 2369 | CBufferIn* buffer = it->buffer; |
---|
| 2370 | *buffer >> domainId; |
---|
| 2371 | rankBuffers[it->rank] = buffer; |
---|
| 2372 | } |
---|
| 2373 | get(domainId)->recvIndex(rankBuffers); |
---|
[509] | 2374 | |
---|
[1025] | 2375 | // if (domain->isCompressible_) |
---|
| 2376 | // { |
---|
| 2377 | // std::sort(domain->indexesToWrite.begin(), domain->indexesToWrite.end()); |
---|
[509] | 2378 | |
---|
[1025] | 2379 | // CContextServer* server = CContext::getCurrent()->server; |
---|
| 2380 | // domain->numberWrittenIndexes_ = domain->indexesToWrite.size(); |
---|
| 2381 | // MPI_Allreduce(&domain->numberWrittenIndexes_, &domain->totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); |
---|
| 2382 | // MPI_Scan(&domain->numberWrittenIndexes_, &domain->offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); |
---|
| 2383 | // domain->offsetWrittenIndexes_ -= domain->numberWrittenIndexes_; |
---|
| 2384 | // } |
---|
| 2385 | } |
---|
[300] | 2386 | |
---|
[1025] | 2387 | /*! |
---|
| 2388 | Receive index information from client(s) |
---|
| 2389 | \param[in] rankBuffers rank of sending client and the corresponding receive buffer |
---|
| 2390 | */ |
---|
| 2391 | void CDomain::recvIndex(std::map<int, CBufferIn*>& rankBuffers) |
---|
| 2392 | { |
---|
| 2393 | int nbReceived = rankBuffers.size(), i, ind, index, type_int; |
---|
[1129] | 2394 | recvClientRanks_.resize(nbReceived); |
---|
[1025] | 2395 | |
---|
| 2396 | std::map<int, CBufferIn*>::iterator it = rankBuffers.begin(), ite = rankBuffers.end(); |
---|
| 2397 | ind = 0; |
---|
| 2398 | for (ind = 0; it != ite; ++it, ++ind) |
---|
| 2399 | { |
---|
| 2400 | recvClientRanks_[ind] = it->first; |
---|
| 2401 | CBufferIn& buffer = *(it->second); |
---|
[1129] | 2402 | buffer >> type_int >> isCurvilinear >> indGlob_[it->first]; |
---|
[1025] | 2403 | type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix |
---|
| 2404 | } |
---|
| 2405 | int nbIndGlob = 0; |
---|
| 2406 | for (i = 0; i < nbReceived; ++i) |
---|
[300] | 2407 | { |
---|
[1025] | 2408 | nbIndGlob += indGlob_[recvClientRanks_[i]].numElements(); |
---|
[300] | 2409 | } |
---|
[1025] | 2410 | |
---|
| 2411 | i_index.resize(nbIndGlob); |
---|
| 2412 | j_index.resize(nbIndGlob); |
---|
| 2413 | |
---|
[1129] | 2414 | globalLocalIndexMap_.rehash(std::ceil(nbIndGlob/globalLocalIndexMap_.max_load_factor())); |
---|
[1025] | 2415 | nbIndGlob = 0; |
---|
| 2416 | for (i = 0; i < nbReceived; ++i) |
---|
[456] | 2417 | { |
---|
[1025] | 2418 | CArray<int,1>& tmp = indGlob_[recvClientRanks_[i]]; |
---|
| 2419 | for (ind = 0; ind < tmp.numElements(); ++ind) |
---|
| 2420 | { |
---|
| 2421 | index = tmp(ind); |
---|
[1030] | 2422 | i_index(nbIndGlob) = index % ni_glo; |
---|
| 2423 | j_index(nbIndGlob) = index / ni_glo; |
---|
[1129] | 2424 | globalLocalIndexMap_[index] = nbIndGlob; |
---|
[1025] | 2425 | ++nbIndGlob; |
---|
| 2426 | } |
---|
[1129] | 2427 | } |
---|
[1099] | 2428 | |
---|
| 2429 | // { |
---|
| 2430 | // CContextServer* server = CContext::getCurrent()->server; |
---|
| 2431 | // count_write_index_.resize(2); |
---|
| 2432 | // start_write_index_.resize(2); |
---|
| 2433 | // local_write_size_.resize(2); |
---|
| 2434 | // global_write_size_.resize(2); |
---|
| 2435 | // if ((this->type) == CDomain::type_attr::unstructured) |
---|
| 2436 | // { |
---|
| 2437 | // count_write_index_[0] = zoom_i_index.numElements(); |
---|
| 2438 | // count_write_index_[1] = 0; |
---|
| 2439 | // } |
---|
| 2440 | // else |
---|
| 2441 | // { |
---|
| 2442 | // int ni_zoom = zoom_i_index.numElements(), idx, nbIZoom = 0, nbJZoom = 0; |
---|
| 2443 | // for (idx =0; idx < ni_zoom; ++idx) |
---|
| 2444 | // { |
---|
| 2445 | // if ((ibegin <= zoom_i_index(idx)) && (zoom_i_index(idx) < ibegin+ni) && (nbIZoom < ni)) |
---|
| 2446 | // ++nbIZoom; |
---|
| 2447 | // if ((jbegin <= zoom_j_index(idx)) && (zoom_j_index(idx) < jbegin+nj) && (nbJZoom < nj)) |
---|
| 2448 | // ++nbJZoom; |
---|
| 2449 | // } |
---|
| 2450 | // count_write_index_[0] = nbIZoom; |
---|
| 2451 | // count_write_index_[1] = nbJZoom; |
---|
| 2452 | |
---|
| 2453 | // // Reoder the zoom_index |
---|
| 2454 | // for (int j = 0; j < nbJZoom; ++j) |
---|
| 2455 | // for (int i = 0; i < nbIZoom; ++i) |
---|
| 2456 | // { |
---|
| 2457 | // idx = nbIZoom * j + i; |
---|
| 2458 | // if (idx < ni_zoom) |
---|
| 2459 | // { |
---|
| 2460 | // zoom_i_index(idx) = ibegin + i; |
---|
| 2461 | // zoom_j_index(idx) = jbegin + j; |
---|
| 2462 | // } |
---|
| 2463 | // } |
---|
| 2464 | |
---|
| 2465 | // // Reorder the global index |
---|
| 2466 | // for (int j = 0; j < nj; ++j) |
---|
| 2467 | // for (int i = 0; i < ni; ++i) |
---|
| 2468 | // { |
---|
| 2469 | // idx = ni * j + i; |
---|
| 2470 | // if (idx < nbIndGlob) |
---|
| 2471 | // { |
---|
| 2472 | // i_index(idx) = ibegin + i; |
---|
| 2473 | // j_index(idx) = jbegin + j; |
---|
| 2474 | // } |
---|
| 2475 | // } |
---|
| 2476 | // } |
---|
| 2477 | |
---|
[1025] | 2478 | |
---|
[1099] | 2479 | // MPI_Scan(&count_write_index_[0], &start_write_index_[0], 2, MPI_INT, MPI_SUM, server->intraComm); |
---|
| 2480 | // start_write_index_[0] = 0; |
---|
| 2481 | // start_write_index_[1] -= count_write_index_[1]; |
---|
| 2482 | // local_write_size_[0] = count_write_index_[0]; |
---|
| 2483 | // local_write_size_[1] = count_write_index_[1]; |
---|
| 2484 | // MPI_Allreduce(&count_write_index_[0], &global_write_size_[0], 2, MPI_INT, MPI_SUM, server->intraComm); |
---|
| 2485 | // global_write_size_[0] = count_write_index_[0]; |
---|
| 2486 | // global_write_size_[1] = (global_write_size_[1] > nj_glo) ? nj_glo : global_write_size_[1]; |
---|
| 2487 | |
---|
[1025] | 2488 | |
---|
[1099] | 2489 | // } |
---|
| 2490 | |
---|
[1025] | 2491 | // int type_int; |
---|
| 2492 | // buffer >> type_int >> isCurvilinear >> indiSrv[rank] >> indjSrv[rank]; |
---|
| 2493 | // type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix |
---|
| 2494 | |
---|
| 2495 | // if (isCompressible_) |
---|
| 2496 | // { |
---|
| 2497 | // CArray<int, 1> writtenIndexes; |
---|
| 2498 | // buffer >> writtenIndexes; |
---|
| 2499 | // indexesToWrite.reserve(indexesToWrite.size() + writtenIndexes.numElements()); |
---|
| 2500 | // for (int i = 0; i < writtenIndexes.numElements(); ++i) |
---|
| 2501 | // indexesToWrite.push_back(writtenIndexes(i)); |
---|
| 2502 | // } |
---|
[300] | 2503 | } |
---|
[509] | 2504 | |
---|
[667] | 2505 | /*! |
---|
[1129] | 2506 | Receive index event from clients(s) |
---|
| 2507 | \param[in] event event contain info about rank and associated index |
---|
| 2508 | */ |
---|
| 2509 | void CDomain::recvIndexZoom(CEventServer& event) |
---|
| 2510 | { |
---|
| 2511 | string domainId; |
---|
| 2512 | std::map<int, CBufferIn*> rankBuffers; |
---|
| 2513 | |
---|
| 2514 | list<CEventServer::SSubEvent>::iterator it; |
---|
| 2515 | for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) |
---|
| 2516 | { |
---|
| 2517 | CBufferIn* buffer = it->buffer; |
---|
| 2518 | *buffer >> domainId; |
---|
| 2519 | rankBuffers[it->rank] = buffer; |
---|
| 2520 | } |
---|
| 2521 | get(domainId)->recvIndexZoom(rankBuffers); |
---|
| 2522 | } |
---|
| 2523 | |
---|
| 2524 | /*! |
---|
| 2525 | Receive index information from client(s) |
---|
| 2526 | \param[in] rankBuffers rank of sending client and the corresponding receive buffer |
---|
| 2527 | */ |
---|
| 2528 | void CDomain::recvIndexZoom(std::map<int, CBufferIn*>& rankBuffers) |
---|
| 2529 | { |
---|
| 2530 | int nbReceived = rankBuffers.size(), i, ind, index, type_int; |
---|
| 2531 | recvClientZoomRanks_.resize(nbReceived); |
---|
| 2532 | int ni_zoom_tmp, ibegin_zoom_tmp, nj_zoom_tmp, jbegin_zoom_tmp; |
---|
| 2533 | |
---|
| 2534 | std::map<int, CBufferIn*>::iterator it = rankBuffers.begin(), ite = rankBuffers.end(); |
---|
| 2535 | ind = 0; |
---|
| 2536 | for (ind = 0; it != ite; ++it, ++ind) |
---|
| 2537 | { |
---|
| 2538 | recvClientZoomRanks_[ind] = it->first; |
---|
| 2539 | CBufferIn& buffer = *(it->second); |
---|
| 2540 | buffer >> indGlobZoom_[it->first] >> doZoomByIndex_; |
---|
| 2541 | } |
---|
| 2542 | |
---|
| 2543 | int nbZoomInd = 0; |
---|
| 2544 | for (i = 0; i < nbReceived; ++i) |
---|
| 2545 | { |
---|
| 2546 | nbZoomInd += indGlobZoom_[recvClientZoomRanks_[i]].numElements(); |
---|
| 2547 | } |
---|
| 2548 | |
---|
| 2549 | if (doZoomByIndex_) |
---|
| 2550 | { |
---|
| 2551 | zoom_i_index.resize(nbZoomInd); |
---|
| 2552 | zoom_j_index.resize(nbZoomInd); |
---|
| 2553 | |
---|
| 2554 | nbZoomInd = 0; |
---|
| 2555 | for (i = 0; i < nbReceived; ++i) |
---|
| 2556 | { |
---|
| 2557 | CArray<int,1>& tmp = indGlobZoom_[recvClientRanks_[i]]; |
---|
| 2558 | for (ind = 0; ind < tmp.numElements(); ++ind) |
---|
| 2559 | { |
---|
| 2560 | index = tmp(ind); |
---|
| 2561 | zoom_i_index(nbZoomInd) = index % ni_glo; |
---|
| 2562 | zoom_j_index(nbZoomInd) = index / ni_glo; |
---|
| 2563 | ++nbZoomInd; |
---|
| 2564 | } |
---|
| 2565 | } |
---|
| 2566 | } |
---|
| 2567 | else |
---|
| 2568 | { |
---|
| 2569 | } |
---|
| 2570 | |
---|
| 2571 | // globalLocalIndexZoomMap_.rehash(std::ceil(nbZoomInd/globalLocalIndexZoomMap_.max_load_factor())); |
---|
| 2572 | // nbZoomInd = 0; |
---|
| 2573 | // for (int j = 0; j < zoom_nj; ++j) |
---|
| 2574 | // for (int i = 0; i < zoom_ni; ++i) |
---|
| 2575 | // { |
---|
| 2576 | // globalLocalIndexZoomMap_[(i + zoom_ibegin) + (j + zoom_jbegin) * ni_glo] = nbZoomInd; |
---|
| 2577 | // ++nbZoomInd; |
---|
| 2578 | // } |
---|
| 2579 | } |
---|
| 2580 | |
---|
| 2581 | /*! |
---|
[1099] | 2582 | Receive attributes event from clients(s) |
---|
| 2583 | \param[in] event event contain info about rank and associated attributes |
---|
| 2584 | */ |
---|
| 2585 | void CDomain::recvDistributionAttributes(CEventServer& event) |
---|
| 2586 | { |
---|
| 2587 | CBufferIn* buffer=event.subEvents.begin()->buffer; |
---|
| 2588 | string domainId ; |
---|
| 2589 | *buffer>>domainId ; |
---|
| 2590 | get(domainId)->recvDistributionAttributes(*buffer); |
---|
| 2591 | } |
---|
| 2592 | |
---|
| 2593 | /*! |
---|
| 2594 | Receive attributes from client(s): zoom info and begin and n of each server |
---|
| 2595 | \param[in] rank rank of client source |
---|
| 2596 | \param[in] buffer message containing attributes info |
---|
| 2597 | */ |
---|
| 2598 | void CDomain::recvDistributionAttributes(CBufferIn& buffer) |
---|
| 2599 | { |
---|
| 2600 | int ni_tmp, ibegin_tmp, nj_tmp, jbegin_tmp; |
---|
| 2601 | int global_zoom_ni_tmp, global_zoom_ibegin_tmp, global_zoom_nj_tmp, global_zoom_jbegin_tmp; |
---|
| 2602 | buffer >> ni_tmp >> ibegin_tmp >> nj_tmp >> jbegin_tmp |
---|
| 2603 | >> global_zoom_ni_tmp >> global_zoom_ibegin_tmp >> global_zoom_nj_tmp >> global_zoom_jbegin_tmp |
---|
| 2604 | >> isCompressible_; |
---|
| 2605 | ni.setValue(ni_tmp); |
---|
| 2606 | ibegin.setValue(ibegin_tmp); |
---|
| 2607 | nj.setValue(nj_tmp); |
---|
| 2608 | jbegin.setValue(jbegin_tmp); |
---|
| 2609 | |
---|
| 2610 | global_zoom_ni.setValue(global_zoom_ni_tmp); |
---|
| 2611 | global_zoom_ibegin.setValue(global_zoom_ibegin_tmp); |
---|
| 2612 | global_zoom_nj.setValue(global_zoom_nj_tmp); |
---|
| 2613 | global_zoom_jbegin.setValue(global_zoom_jbegin_tmp); |
---|
| 2614 | |
---|
| 2615 | int iend = ibegin + ni - 1; |
---|
| 2616 | int jend = jbegin + nj - 1; |
---|
| 2617 | int zoom_iend_glob = global_zoom_ibegin + global_zoom_ni - 1; |
---|
| 2618 | int zoom_jend_glob = global_zoom_jbegin + global_zoom_nj - 1; |
---|
| 2619 | |
---|
| 2620 | zoom_ibegin.setValue(global_zoom_ibegin > ibegin ? global_zoom_ibegin : ibegin); |
---|
| 2621 | int zoom_iend = zoom_iend_glob < iend ? zoom_iend_glob : iend ; |
---|
| 2622 | zoom_ni.setValue(zoom_iend-zoom_ibegin+1); |
---|
| 2623 | |
---|
| 2624 | zoom_jbegin.setValue(global_zoom_jbegin > jbegin ? global_zoom_jbegin : jbegin); |
---|
| 2625 | int zoom_jend = zoom_jend_glob < jend ? zoom_jend_glob : jend ; |
---|
| 2626 | zoom_nj.setValue(zoom_jend-zoom_jbegin+1); |
---|
| 2627 | |
---|
| 2628 | if (zoom_ni<=0 || zoom_nj<=0) |
---|
| 2629 | { |
---|
| 2630 | zoom_ibegin=0 ; zoom_iend=0 ; zoom_ni=0 ; |
---|
| 2631 | zoom_jbegin=0 ; zoom_jend=0 ; zoom_nj=0 ; |
---|
| 2632 | } |
---|
| 2633 | |
---|
| 2634 | } |
---|
| 2635 | |
---|
| 2636 | /*! |
---|
[1025] | 2637 | Receive area event from clients(s) |
---|
| 2638 | \param[in] event event contain info about rank and associated area |
---|
[667] | 2639 | */ |
---|
[1025] | 2640 | void CDomain::recvMask(CEventServer& event) |
---|
[610] | 2641 | { |
---|
[1025] | 2642 | string domainId; |
---|
| 2643 | std::map<int, CBufferIn*> rankBuffers; |
---|
[676] | 2644 | |
---|
[610] | 2645 | list<CEventServer::SSubEvent>::iterator it; |
---|
| 2646 | for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) |
---|
[1025] | 2647 | { |
---|
[610] | 2648 | CBufferIn* buffer = it->buffer; |
---|
| 2649 | *buffer >> domainId; |
---|
[1025] | 2650 | rankBuffers[it->rank] = buffer; |
---|
[610] | 2651 | } |
---|
[1025] | 2652 | get(domainId)->recvMask(rankBuffers); |
---|
| 2653 | } |
---|
[676] | 2654 | |
---|
| 2655 | |
---|
[667] | 2656 | /*! |
---|
[1025] | 2657 | Receive mask information from client(s) |
---|
| 2658 | \param[in] rankBuffers rank of sending client and the corresponding receive buffer |
---|
[667] | 2659 | */ |
---|
[1025] | 2660 | void CDomain::recvMask(std::map<int, CBufferIn*>& rankBuffers) |
---|
[610] | 2661 | { |
---|
[1025] | 2662 | int nbReceived = rankBuffers.size(), i, ind, index; |
---|
| 2663 | if (nbReceived != recvClientRanks_.size()) |
---|
| 2664 | ERROR("void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers)", |
---|
| 2665 | << "The number of sending clients is not correct." |
---|
| 2666 | << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); |
---|
[676] | 2667 | |
---|
[1025] | 2668 | vector<CArray<bool,1> > recvMaskValue(nbReceived); |
---|
| 2669 | for (i = 0; i < recvClientRanks_.size(); ++i) |
---|
[676] | 2670 | { |
---|
[1025] | 2671 | int rank = recvClientRanks_[i]; |
---|
| 2672 | CBufferIn& buffer = *(rankBuffers[rank]); |
---|
| 2673 | buffer >> recvMaskValue[i]; |
---|
[676] | 2674 | } |
---|
[1025] | 2675 | |
---|
| 2676 | int nbMaskInd = 0; |
---|
| 2677 | for (i = 0; i < nbReceived; ++i) |
---|
| 2678 | { |
---|
| 2679 | nbMaskInd += recvMaskValue[i].numElements(); |
---|
| 2680 | } |
---|
| 2681 | |
---|
| 2682 | mask_1d.resize(nbMaskInd); |
---|
| 2683 | nbMaskInd = 0; |
---|
| 2684 | for (i = 0; i < nbReceived; ++i) |
---|
| 2685 | { |
---|
| 2686 | CArray<bool,1>& tmp = recvMaskValue[i]; |
---|
| 2687 | for (ind = 0; ind < tmp.numElements(); ++ind) |
---|
| 2688 | { |
---|
| 2689 | mask_1d(nbMaskInd) = tmp(ind); |
---|
| 2690 | ++nbMaskInd; |
---|
| 2691 | } |
---|
| 2692 | } |
---|
[610] | 2693 | } |
---|
| 2694 | |
---|
[667] | 2695 | /*! |
---|
| 2696 | Receive longitude event from clients(s) |
---|
| 2697 | \param[in] event event contain info about rank and associated longitude |
---|
| 2698 | */ |
---|
[518] | 2699 | void CDomain::recvLon(CEventServer& event) |
---|
[300] | 2700 | { |
---|
[1025] | 2701 | string domainId; |
---|
| 2702 | std::map<int, CBufferIn*> rankBuffers; |
---|
| 2703 | |
---|
[610] | 2704 | list<CEventServer::SSubEvent>::iterator it; |
---|
| 2705 | for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) |
---|
[1025] | 2706 | { |
---|
[610] | 2707 | CBufferIn* buffer = it->buffer; |
---|
| 2708 | *buffer >> domainId; |
---|
[1025] | 2709 | rankBuffers[it->rank] = buffer; |
---|
[300] | 2710 | } |
---|
[1025] | 2711 | get(domainId)->recvLon(rankBuffers); |
---|
[300] | 2712 | } |
---|
[509] | 2713 | |
---|
[667] | 2714 | /*! |
---|
| 2715 | Receive longitude information from client(s) |
---|
[1025] | 2716 | \param[in] rankBuffers rank of sending client and the corresponding receive buffer |
---|
[667] | 2717 | */ |
---|
[1025] | 2718 | void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers) |
---|
[300] | 2719 | { |
---|
[1129] | 2720 | int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex, lInd; |
---|
[1025] | 2721 | if (nbReceived != recvClientRanks_.size()) |
---|
| 2722 | ERROR("void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers)", |
---|
| 2723 | << "The number of sending clients is not correct." |
---|
| 2724 | << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); |
---|
[518] | 2725 | |
---|
[1025] | 2726 | vector<CArray<double,1> > recvLonValue(nbReceived); |
---|
| 2727 | vector<CArray<double,2> > recvBoundsLonValue(nbReceived); |
---|
| 2728 | for (i = 0; i < recvClientRanks_.size(); ++i) |
---|
| 2729 | { |
---|
| 2730 | int rank = recvClientRanks_[i]; |
---|
| 2731 | CBufferIn& buffer = *(rankBuffers[rank]); |
---|
| 2732 | buffer >> hasLonLat; |
---|
[1129] | 2733 | if (hasLonLat) |
---|
| 2734 | buffer >> recvLonValue[i]; |
---|
[1025] | 2735 | buffer >> hasBounds; |
---|
| 2736 | if (hasBounds) |
---|
| 2737 | buffer >> recvBoundsLonValue[i]; |
---|
| 2738 | } |
---|
[924] | 2739 | |
---|
[1129] | 2740 | if (hasLonLat) |
---|
[518] | 2741 | { |
---|
[1129] | 2742 | int nbLonInd = 0; |
---|
| 2743 | for (i = 0; i < nbReceived; ++i) |
---|
| 2744 | { |
---|
| 2745 | nbLonInd += recvLonValue[i].numElements(); |
---|
| 2746 | } |
---|
[1099] | 2747 | |
---|
[1129] | 2748 | if (nbLonInd != globalLocalIndexMap_.size()) |
---|
| 2749 | info (0) << "Something wrong with longitude index "<< std::endl; |
---|
| 2750 | |
---|
| 2751 | lonvalue.resize(nbLonInd); |
---|
| 2752 | if (hasBounds) |
---|
[518] | 2753 | { |
---|
[1129] | 2754 | bounds_lonvalue.resize(nvertex,nbLonInd); |
---|
| 2755 | bounds_lonvalue = 0.; |
---|
[518] | 2756 | } |
---|
[1129] | 2757 | |
---|
| 2758 | nbLonInd = 0; |
---|
| 2759 | for (i = 0; i < nbReceived; ++i) |
---|
| 2760 | { |
---|
| 2761 | CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; |
---|
| 2762 | CArray<double,1>& tmp = recvLonValue[i]; |
---|
| 2763 | for (ind = 0; ind < tmp.numElements(); ++ind) |
---|
| 2764 | { |
---|
| 2765 | lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; |
---|
| 2766 | lonvalue(lInd) = tmp(ind); |
---|
| 2767 | if (hasBounds) |
---|
| 2768 | { |
---|
| 2769 | for (int nv = 0; nv < nvertex; ++nv) |
---|
| 2770 | bounds_lonvalue(nv, lInd) = recvBoundsLonValue[i](nv, ind); |
---|
| 2771 | } |
---|
| 2772 | } |
---|
| 2773 | } |
---|
[518] | 2774 | } |
---|
[1129] | 2775 | |
---|
| 2776 | |
---|
| 2777 | |
---|
| 2778 | // lonvalue.resize(zoom_ni*zoom_nj); |
---|
| 2779 | // lonvalue = 0; |
---|
| 2780 | |
---|
| 2781 | // if (hasBounds) |
---|
| 2782 | // { |
---|
| 2783 | // bounds_lonvalue.resize(nvertex,zoom_ni*zoom_nj); |
---|
| 2784 | // bounds_lonvalue = 0.; |
---|
| 2785 | // } |
---|
| 2786 | |
---|
| 2787 | // if (0 == lonvalue.numElements()) return; |
---|
| 2788 | |
---|
| 2789 | // for (i = 0; i < nbReceived; ++i) |
---|
| 2790 | // { |
---|
| 2791 | // int rank = recvClientRanks_[i]; |
---|
| 2792 | // CArray<int,1> &indi = indGlob_[rank], &indj = indGlob_[rank]; |
---|
| 2793 | // for (ind = 0; ind < indi.numElements(); ++ind) |
---|
| 2794 | // { |
---|
| 2795 | // iindex = indi(ind) % ni_glo; jindex = indj(ind) / ni_glo; |
---|
| 2796 | // index = (iindex - zoom_ibegin) + (jindex - zoom_jbegin) * zoom_ni; |
---|
| 2797 | // lonvalue(index) = recvLonValue[i](ind); |
---|
| 2798 | // if (hasBounds) |
---|
| 2799 | // { |
---|
| 2800 | // for (int nv = 0; nv < nvertex; ++nv) |
---|
| 2801 | // bounds_lonvalue(nv, index) = recvBoundsLonValue[i](nv, ind); |
---|
| 2802 | // } |
---|
| 2803 | // } |
---|
| 2804 | // } |
---|
[518] | 2805 | } |
---|
| 2806 | |
---|
[667] | 2807 | /*! |
---|
| 2808 | Receive latitude event from clients(s) |
---|
| 2809 | \param[in] event event contain info about rank and associated latitude |
---|
| 2810 | */ |
---|
[518] | 2811 | void CDomain::recvLat(CEventServer& event) |
---|
| 2812 | { |
---|
[1025] | 2813 | string domainId; |
---|
| 2814 | std::map<int, CBufferIn*> rankBuffers; |
---|
| 2815 | |
---|
[610] | 2816 | list<CEventServer::SSubEvent>::iterator it; |
---|
| 2817 | for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) |
---|
[1025] | 2818 | { |
---|
[610] | 2819 | CBufferIn* buffer = it->buffer; |
---|
| 2820 | *buffer >> domainId; |
---|
[1025] | 2821 | rankBuffers[it->rank] = buffer; |
---|
[518] | 2822 | } |
---|
[1025] | 2823 | get(domainId)->recvLat(rankBuffers); |
---|
[518] | 2824 | } |
---|
| 2825 | |
---|
[667] | 2826 | /*! |
---|
| 2827 | Receive latitude information from client(s) |
---|
[1025] | 2828 | \param[in] rankBuffers rank of sending client and the corresponding receive buffer |
---|
[667] | 2829 | */ |
---|
[1025] | 2830 | void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers) |
---|
[518] | 2831 | { |
---|
[1129] | 2832 | int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex, lInd; |
---|
[1025] | 2833 | if (nbReceived != recvClientRanks_.size()) |
---|
| 2834 | ERROR("void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers)", |
---|
| 2835 | << "The number of sending clients is not correct." |
---|
| 2836 | << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); |
---|
[509] | 2837 | |
---|
[1025] | 2838 | vector<CArray<double,1> > recvLatValue(nbReceived); |
---|
| 2839 | vector<CArray<double,2> > recvBoundsLatValue(nbReceived); |
---|
| 2840 | for (i = 0; i < recvClientRanks_.size(); ++i) |
---|
| 2841 | { |
---|
| 2842 | int rank = recvClientRanks_[i]; |
---|
| 2843 | CBufferIn& buffer = *(rankBuffers[rank]); |
---|
| 2844 | buffer >> hasLonLat; |
---|
[1129] | 2845 | if (hasLonLat) |
---|
| 2846 | buffer >> recvLatValue[i]; |
---|
[1025] | 2847 | buffer >> hasBounds; |
---|
| 2848 | if (hasBounds) |
---|
| 2849 | buffer >> recvBoundsLatValue[i]; |
---|
| 2850 | } |
---|
[610] | 2851 | |
---|
[1129] | 2852 | if (hasLonLat) |
---|
[1025] | 2853 | { |
---|
[1129] | 2854 | int nbLatInd = 0; |
---|
| 2855 | for (i = 0; i < nbReceived; ++i) |
---|
| 2856 | { |
---|
| 2857 | nbLatInd += recvLatValue[i].numElements(); |
---|
| 2858 | } |
---|
[1025] | 2859 | |
---|
[1129] | 2860 | if (nbLatInd != globalLocalIndexMap_.size()) |
---|
| 2861 | info (0) << "Something wrong with latitude index "<< std::endl; |
---|
| 2862 | |
---|
| 2863 | latvalue.resize(nbLatInd); |
---|
| 2864 | if (hasBounds) |
---|
[1099] | 2865 | { |
---|
[1129] | 2866 | bounds_latvalue.resize(nvertex,nbLatInd); |
---|
| 2867 | bounds_latvalue = 0. ; |
---|
[449] | 2868 | } |
---|
[1129] | 2869 | |
---|
| 2870 | nbLatInd = 0; |
---|
| 2871 | for (i = 0; i < nbReceived; ++i) |
---|
| 2872 | { |
---|
| 2873 | CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; |
---|
| 2874 | CArray<double,1>& tmp = recvLatValue[i]; |
---|
| 2875 | for (ind = 0; ind < tmp.numElements(); ++ind) |
---|
| 2876 | { |
---|
| 2877 | lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; |
---|
| 2878 | latvalue(lInd) = tmp(ind); |
---|
| 2879 | if (hasBounds) |
---|
| 2880 | { |
---|
| 2881 | CArray<double,2>& boundslat = recvBoundsLatValue[i]; |
---|
| 2882 | for (int nv = 0; nv < nvertex; ++nv) |
---|
| 2883 | bounds_latvalue(nv, lInd) = boundslat(nv, ind); |
---|
| 2884 | } |
---|
| 2885 | ++nbLatInd; |
---|
| 2886 | } |
---|
| 2887 | } |
---|
[300] | 2888 | } |
---|
| 2889 | } |
---|
[553] | 2890 | |
---|
[667] | 2891 | /*! |
---|
| 2892 | Receive area event from clients(s) |
---|
| 2893 | \param[in] event event contain info about rank and associated area |
---|
| 2894 | */ |
---|
[611] | 2895 | void CDomain::recvArea(CEventServer& event) |
---|
| 2896 | { |
---|
[1025] | 2897 | string domainId; |
---|
| 2898 | std::map<int, CBufferIn*> rankBuffers; |
---|
| 2899 | |
---|
[611] | 2900 | list<CEventServer::SSubEvent>::iterator it; |
---|
| 2901 | for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) |
---|
[1025] | 2902 | { |
---|
[611] | 2903 | CBufferIn* buffer = it->buffer; |
---|
| 2904 | *buffer >> domainId; |
---|
[1025] | 2905 | rankBuffers[it->rank] = buffer; |
---|
[611] | 2906 | } |
---|
[1025] | 2907 | get(domainId)->recvArea(rankBuffers); |
---|
[611] | 2908 | } |
---|
| 2909 | |
---|
[1025] | 2910 | |
---|
[667] | 2911 | /*! |
---|
| 2912 | Receive area information from client(s) |
---|
[1025] | 2913 | \param[in] rankBuffers rank of sending client and the corresponding receive buffer |
---|
[667] | 2914 | */ |
---|
[1025] | 2915 | void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers) |
---|
[611] | 2916 | { |
---|
[1129] | 2917 | int nbReceived = rankBuffers.size(), i, ind, index, lInd; |
---|
[1025] | 2918 | if (nbReceived != recvClientRanks_.size()) |
---|
| 2919 | ERROR("void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers)", |
---|
| 2920 | << "The number of sending clients is not correct." |
---|
| 2921 | << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); |
---|
[611] | 2922 | |
---|
[1025] | 2923 | vector<CArray<double,1> > recvAreaValue(nbReceived); |
---|
| 2924 | for (i = 0; i < recvClientRanks_.size(); ++i) |
---|
| 2925 | { |
---|
| 2926 | int rank = recvClientRanks_[i]; |
---|
| 2927 | CBufferIn& buffer = *(rankBuffers[rank]); |
---|
| 2928 | buffer >> hasArea; |
---|
| 2929 | if (hasArea) |
---|
| 2930 | buffer >> recvAreaValue[i]; |
---|
| 2931 | } |
---|
[611] | 2932 | |
---|
[1025] | 2933 | int nbAreaInd = 0; |
---|
| 2934 | for (i = 0; i < nbReceived; ++i) |
---|
[1129] | 2935 | { |
---|
| 2936 | nbAreaInd += recvAreaValue[i].numElements(); |
---|
[611] | 2937 | } |
---|
[1025] | 2938 | |
---|
[1129] | 2939 | if (nbAreaInd != globalLocalIndexMap_.size()) |
---|
| 2940 | info (0) << "Something wrong with latitude index "<< std::endl; |
---|
| 2941 | |
---|
[1025] | 2942 | if (hasArea) |
---|
| 2943 | { |
---|
[1129] | 2944 | areavalue.resize(nbAreaInd); |
---|
| 2945 | nbAreaInd = 0; |
---|
[1025] | 2946 | for (i = 0; i < nbReceived; ++i) |
---|
| 2947 | { |
---|
[1129] | 2948 | CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; |
---|
[1025] | 2949 | CArray<double,1>& tmp = recvAreaValue[i]; |
---|
| 2950 | for (ind = 0; ind < tmp.numElements(); ++ind) |
---|
| 2951 | { |
---|
[1129] | 2952 | lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; |
---|
| 2953 | areavalue(lInd) = tmp(ind); |
---|
[1025] | 2954 | } |
---|
| 2955 | } |
---|
[1129] | 2956 | |
---|
[1025] | 2957 | } |
---|
[611] | 2958 | } |
---|
| 2959 | |
---|
[1025] | 2960 | /*! |
---|
| 2961 | Receive data index event from clients(s) |
---|
| 2962 | \param[in] event event contain info about rank and associated index |
---|
| 2963 | */ |
---|
| 2964 | void CDomain::recvDataIndex(CEventServer& event) |
---|
| 2965 | { |
---|
| 2966 | string domainId; |
---|
| 2967 | std::map<int, CBufferIn*> rankBuffers; |
---|
| 2968 | |
---|
| 2969 | list<CEventServer::SSubEvent>::iterator it; |
---|
| 2970 | for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) |
---|
| 2971 | { |
---|
| 2972 | CBufferIn* buffer = it->buffer; |
---|
| 2973 | *buffer >> domainId; |
---|
| 2974 | rankBuffers[it->rank] = buffer; |
---|
| 2975 | } |
---|
| 2976 | get(domainId)->recvDataIndex(rankBuffers); |
---|
| 2977 | |
---|
| 2978 | // if (domain->isCompressible_) |
---|
| 2979 | // { |
---|
| 2980 | // std::sort(domain->indexesToWrite.begin(), domain->indexesToWrite.end()); |
---|
| 2981 | |
---|
| 2982 | // CContextServer* server = CContext::getCurrent()->server; |
---|
| 2983 | // domain->numberWrittenIndexes_ = domain->indexesToWrite.size(); |
---|
| 2984 | // MPI_Allreduce(&domain->numberWrittenIndexes_, &domain->totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); |
---|
| 2985 | // MPI_Scan(&domain->numberWrittenIndexes_, &domain->offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); |
---|
| 2986 | // domain->offsetWrittenIndexes_ -= domain->numberWrittenIndexes_; |
---|
| 2987 | // } |
---|
| 2988 | } |
---|
| 2989 | |
---|
| 2990 | /*! |
---|
| 2991 | Receive data index information from client(s) |
---|
| 2992 | A client receives data index from different clients to rebuild its own data index. |
---|
| 2993 | Because the data index is local, to rebuild data index of received client, we should use global index along with. |
---|
| 2994 | \param[in] rankBuffers rank of sending client and the corresponding receive buffer |
---|
| 2995 | */ |
---|
| 2996 | void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers) |
---|
| 2997 | { |
---|
[1129] | 2998 | int nbReceived = rankBuffers.size(), i, ind, index, indexI, indexJ, type_int, lInd; |
---|
[1025] | 2999 | if (nbReceived != recvClientRanks_.size()) |
---|
[1129] | 3000 | ERROR("void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers)", |
---|
[1025] | 3001 | << "The number of sending clients is not correct." |
---|
| 3002 | << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); |
---|
| 3003 | |
---|
| 3004 | vector<CArray<int,1> > recvDataIIndex(nbReceived),recvDataJIndex(nbReceived); |
---|
| 3005 | for (i = 0; i < recvClientRanks_.size(); ++i) |
---|
| 3006 | { |
---|
| 3007 | int rank = recvClientRanks_[i]; |
---|
| 3008 | CBufferIn& buffer = *(rankBuffers[rank]); |
---|
| 3009 | buffer >> recvDataIIndex[i]; |
---|
| 3010 | buffer >> recvDataJIndex[i]; |
---|
| 3011 | } |
---|
| 3012 | |
---|
[1129] | 3013 | int nbIndex = i_index.numElements(); |
---|
| 3014 | CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); |
---|
| 3015 | dataIIndex = -1; dataJIndex = -1; |
---|
| 3016 | |
---|
| 3017 | nbIndex = 0; |
---|
[1025] | 3018 | for (i = 0; i < nbReceived; ++i) |
---|
[1129] | 3019 | { |
---|
| 3020 | CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; |
---|
| 3021 | CArray<int,1>& tmpI = recvDataIIndex[i]; |
---|
| 3022 | CArray<int,1>& tmpJ = recvDataJIndex[i]; |
---|
| 3023 | if ((tmpI.numElements() != tmpInd.numElements()) || (tmpJ.numElements() != tmpInd.numElements())) |
---|
| 3024 | ERROR("void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers)", |
---|
| 3025 | << "The number of global received index is not coherent with the number of received data index." |
---|
| 3026 | << "Expected number of global index: " << tmpI.numElements() << " but received " << tmpInd.numElements()); |
---|
| 3027 | |
---|
| 3028 | for (ind = 0; ind < tmpI.numElements(); ++ind) |
---|
[1025] | 3029 | { |
---|
[1129] | 3030 | lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; |
---|
| 3031 | dataIIndex(lInd) = tmpI(ind); |
---|
| 3032 | dataJIndex(lInd) = tmpJ(ind); |
---|
| 3033 | } |
---|
[1025] | 3034 | } |
---|
| 3035 | |
---|
[1129] | 3036 | int nbCompressedData = 0; |
---|
| 3037 | for (ind = 0; ind < dataIIndex.numElements(); ++ind) |
---|
| 3038 | { |
---|
| 3039 | indexI = dataIIndex(ind); indexJ = dataJIndex(ind); |
---|
| 3040 | if ((0 <= indexI) && (0 <= indexJ)) |
---|
| 3041 | ++nbCompressedData; |
---|
| 3042 | } |
---|
| 3043 | |
---|
[1025] | 3044 | data_i_index.resize(nbCompressedData); |
---|
| 3045 | data_j_index.resize(nbCompressedData); |
---|
| 3046 | |
---|
[1129] | 3047 | nbCompressedData = 0; |
---|
| 3048 | for (ind = 0; ind < dataIIndex.numElements(); ++ind) |
---|
[1025] | 3049 | { |
---|
[1129] | 3050 | indexI = dataIIndex(ind); indexJ = dataJIndex(ind); |
---|
| 3051 | if ((0 <= indexI) && (0 <= indexJ)) |
---|
| 3052 | { |
---|
| 3053 | data_i_index(nbCompressedData) = (1 == data_dim) ? ind : i_index(ind) - i_index(0); |
---|
| 3054 | data_j_index(nbCompressedData) = (1 == data_dim) ? 0 : j_index(ind) - j_index(0); |
---|
| 3055 | ++nbCompressedData; |
---|
| 3056 | } |
---|
[1025] | 3057 | } |
---|
[1129] | 3058 | |
---|
| 3059 | // Reset data_ibegin, data_jbegin |
---|
| 3060 | data_ibegin.setValue(0); |
---|
| 3061 | data_jbegin.setValue(0); |
---|
[1025] | 3062 | } |
---|
| 3063 | |
---|
[836] | 3064 | CTransformation<CDomain>* CDomain::addTransformation(ETranformationType transType, const StdString& id) |
---|
| 3065 | { |
---|
| 3066 | transformationMap_.push_back(std::make_pair(transType, CTransformation<CDomain>::createTransformation(transType,id))); |
---|
| 3067 | return transformationMap_.back().second; |
---|
| 3068 | } |
---|
| 3069 | |
---|
[667] | 3070 | /*! |
---|
| 3071 | Check whether a domain has transformation |
---|
| 3072 | \return true if domain has transformation |
---|
| 3073 | */ |
---|
[631] | 3074 | bool CDomain::hasTransformation() |
---|
| 3075 | { |
---|
| 3076 | return (!transformationMap_.empty()); |
---|
| 3077 | } |
---|
| 3078 | |
---|
[667] | 3079 | /*! |
---|
| 3080 | Set transformation for current domain. It's the method to move transformation in hierarchy |
---|
| 3081 | \param [in] domTrans transformation on domain |
---|
| 3082 | */ |
---|
[631] | 3083 | void CDomain::setTransformations(const TransMapTypes& domTrans) |
---|
| 3084 | { |
---|
| 3085 | transformationMap_ = domTrans; |
---|
| 3086 | } |
---|
| 3087 | |
---|
[667] | 3088 | /*! |
---|
| 3089 | Get all transformation current domain has |
---|
| 3090 | \return all transformation |
---|
| 3091 | */ |
---|
[631] | 3092 | CDomain::TransMapTypes CDomain::getAllTransformations(void) |
---|
| 3093 | { |
---|
| 3094 | return transformationMap_; |
---|
| 3095 | } |
---|
| 3096 | |
---|
[823] | 3097 | void CDomain::duplicateTransformation(CDomain* src) |
---|
| 3098 | { |
---|
| 3099 | if (src->hasTransformation()) |
---|
| 3100 | { |
---|
| 3101 | this->setTransformations(src->getAllTransformations()); |
---|
| 3102 | } |
---|
| 3103 | } |
---|
| 3104 | |
---|
[667] | 3105 | /*! |
---|
[747] | 3106 | * Go through the hierarchy to find the domain from which the transformations must be inherited |
---|
| 3107 | */ |
---|
[631] | 3108 | void CDomain::solveInheritanceTransformation() |
---|
| 3109 | { |
---|
[747] | 3110 | if (hasTransformation() || !hasDirectDomainReference()) |
---|
| 3111 | return; |
---|
[631] | 3112 | |
---|
[747] | 3113 | CDomain* domain = this; |
---|
| 3114 | std::vector<CDomain*> refDomains; |
---|
| 3115 | while (!domain->hasTransformation() && domain->hasDirectDomainReference()) |
---|
[631] | 3116 | { |
---|
[747] | 3117 | refDomains.push_back(domain); |
---|
| 3118 | domain = domain->getDirectDomainReference(); |
---|
[631] | 3119 | } |
---|
| 3120 | |
---|
[747] | 3121 | if (domain->hasTransformation()) |
---|
| 3122 | for (size_t i = 0; i < refDomains.size(); ++i) |
---|
| 3123 | refDomains[i]->setTransformations(domain->getAllTransformations()); |
---|
[631] | 3124 | } |
---|
| 3125 | |
---|
[667] | 3126 | /*! |
---|
| 3127 | Parse children nodes of a domain in xml file. |
---|
| 3128 | Whenver there is a new transformation, its type and name should be added into this function |
---|
| 3129 | \param node child node to process |
---|
| 3130 | */ |
---|
[631] | 3131 | void CDomain::parse(xml::CXMLNode & node) |
---|
| 3132 | { |
---|
| 3133 | SuperClass::parse(node); |
---|
| 3134 | |
---|
| 3135 | if (node.goToChildElement()) |
---|
| 3136 | { |
---|
[836] | 3137 | StdString nodeElementName; |
---|
[631] | 3138 | do |
---|
| 3139 | { |
---|
[784] | 3140 | StdString nodeId(""); |
---|
| 3141 | if (node.getAttributes().end() != node.getAttributes().find("id")) |
---|
| 3142 | { nodeId = node.getAttributes()["id"]; } |
---|
| 3143 | |
---|
[836] | 3144 | nodeElementName = node.getElementName(); |
---|
| 3145 | std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_.end(), it; |
---|
| 3146 | it = transformationMapList_.find(nodeElementName); |
---|
| 3147 | if (ite != it) |
---|
[657] | 3148 | { |
---|
[836] | 3149 | transformationMap_.push_back(std::make_pair(it->second, CTransformation<CDomain>::createTransformation(it->second, |
---|
| 3150 | nodeId, |
---|
| 3151 | &node))); |
---|
[657] | 3152 | } |
---|
[968] | 3153 | else |
---|
| 3154 | { |
---|
| 3155 | ERROR("void CDomain::parse(xml::CXMLNode & node)", |
---|
| 3156 | << "The transformation " << nodeElementName << " has not been supported yet."); |
---|
| 3157 | } |
---|
[631] | 3158 | } while (node.goToNextElement()) ; |
---|
| 3159 | node.goToParentElement(); |
---|
| 3160 | } |
---|
| 3161 | } |
---|
[219] | 3162 | //---------------------------------------------------------------- |
---|
[509] | 3163 | |
---|
[540] | 3164 | DEFINE_REF_FUNC(Domain,domain) |
---|
[509] | 3165 | |
---|
[219] | 3166 | ///--------------------------------------------------------------- |
---|
| 3167 | |
---|
[335] | 3168 | } // namespace xios |
---|