[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" |
---|
[369] | 15 | #include "array_new.hpp" |
---|
[553] | 16 | #include "server_distribution_description.hpp" |
---|
[569] | 17 | #include "client_server_mapping_distributed.hpp" |
---|
[631] | 18 | #include "zoom_domain.hpp" |
---|
[657] | 19 | #include "interpolate_from_file_domain.hpp" |
---|
[274] | 20 | |
---|
[335] | 21 | namespace xios { |
---|
[509] | 22 | |
---|
[219] | 23 | /// ////////////////////// Définitions ////////////////////// /// |
---|
| 24 | |
---|
| 25 | CDomain::CDomain(void) |
---|
| 26 | : CObjectTemplate<CDomain>(), CDomainAttributes() |
---|
[584] | 27 | , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() |
---|
[657] | 28 | , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isUnstructed_(false) |
---|
[664] | 29 | , global_zoom_ni(0), global_zoom_ibegin(0), global_zoom_nj(0), global_zoom_jbegin(0) |
---|
[665] | 30 | , isClientAfterTransformationChecked(false), hasLonLat(false) |
---|
[664] | 31 | , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client() |
---|
[219] | 32 | { /* Ne rien faire de plus */ } |
---|
| 33 | |
---|
| 34 | CDomain::CDomain(const StdString & id) |
---|
| 35 | : CObjectTemplate<CDomain>(id), CDomainAttributes() |
---|
[584] | 36 | , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() |
---|
[657] | 37 | , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isUnstructed_(false) |
---|
[664] | 38 | , global_zoom_ni(0), global_zoom_ibegin(0), global_zoom_nj(0), global_zoom_jbegin(0) |
---|
[665] | 39 | , isClientAfterTransformationChecked(false), hasLonLat(false) |
---|
[664] | 40 | , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client() |
---|
[635] | 41 | { /* Ne rien faire de plus */ } |
---|
[219] | 42 | |
---|
| 43 | CDomain::~CDomain(void) |
---|
[509] | 44 | { |
---|
[219] | 45 | } |
---|
| 46 | |
---|
| 47 | ///--------------------------------------------------------------- |
---|
| 48 | |
---|
[622] | 49 | CDomain* CDomain::createDomain() |
---|
| 50 | { |
---|
| 51 | CDomain* domain = CDomainGroup::get("domain_definition")->createChild(); |
---|
| 52 | return domain; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | void CDomain::duplicateAttributes(CDomain* domain) |
---|
| 56 | { |
---|
| 57 | domain->setAttributes(this); |
---|
| 58 | } |
---|
| 59 | |
---|
[219] | 60 | const std::set<StdString> & CDomain::getRelFiles(void) const |
---|
| 61 | { |
---|
[509] | 62 | return (this->relFiles); |
---|
[219] | 63 | } |
---|
| 64 | |
---|
| 65 | //---------------------------------------------------------------- |
---|
| 66 | bool CDomain::isEmpty(void) const |
---|
| 67 | { |
---|
[509] | 68 | return ((this->zoom_ni_srv == 0) || |
---|
[300] | 69 | (this->zoom_nj_srv == 0)); |
---|
[219] | 70 | } |
---|
| 71 | |
---|
| 72 | //---------------------------------------------------------------- |
---|
| 73 | bool CDomain::IsWritten(const StdString & filename) const |
---|
| 74 | { |
---|
| 75 | return (this->relFiles.find(filename) != this->relFiles.end()); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | //---------------------------------------------------------------- |
---|
[594] | 79 | bool CDomain::isDistributed(void) const |
---|
| 80 | { |
---|
| 81 | return isDistributed_; |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | //---------------------------------------------------------------- |
---|
[219] | 85 | void CDomain::addRelFile(const StdString & filename) |
---|
| 86 | { |
---|
| 87 | this->relFiles.insert(filename); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | StdString CDomain::GetName(void) { return (StdString("domain")); } |
---|
| 92 | StdString CDomain::GetDefName(void){ return (CDomain::GetName()); } |
---|
| 93 | ENodeType CDomain::GetType(void) { return (eDomain); } |
---|
| 94 | |
---|
| 95 | //---------------------------------------------------------------- |
---|
| 96 | |
---|
[467] | 97 | void CDomain::checkDomain(void) |
---|
[219] | 98 | { |
---|
[664] | 99 | if (type.isEmpty()) |
---|
| 100 | { |
---|
| 101 | ERROR("CDomain::checkDomain(void)", |
---|
| 102 | << "[ Id = " << this->getId() << " ] " |
---|
| 103 | << "The domain type is not defined," |
---|
| 104 | << " check the 'type' value !") |
---|
| 105 | } |
---|
[467] | 106 | |
---|
[664] | 107 | if (type==type_attr::unstructured) |
---|
| 108 | { |
---|
| 109 | if (ni_glo.isEmpty() || ni_glo <= 0 ) |
---|
| 110 | { |
---|
| 111 | ERROR("CDomain::checkAttributes(void)", |
---|
| 112 | << "[ Id = " << this->getId() << " ] " |
---|
| 113 | << "The global domain is badly defined," |
---|
| 114 | << " check the \'ni_glo\' value !") |
---|
| 115 | } |
---|
| 116 | isUnstructed_ = true; |
---|
| 117 | nj_glo = 1; |
---|
| 118 | nj = 1; |
---|
| 119 | jbegin = 0; |
---|
| 120 | if (ni.isEmpty()) ni = i_index.numElements(); |
---|
| 121 | j_index.resize(ni); |
---|
| 122 | for(int i=0;i<ni;++i) j_index(i)=0; |
---|
[611] | 123 | |
---|
[664] | 124 | if (!area.isEmpty()) |
---|
| 125 | area.transposeSelf(1, 0); |
---|
| 126 | } |
---|
| 127 | else if ((ni_glo.isEmpty() || ni_glo.getValue() <= 0 ) || |
---|
| 128 | (nj_glo.isEmpty() || nj_glo.getValue() <= 0 )) |
---|
| 129 | { |
---|
| 130 | ERROR("CDomain::checkAttributes(void)", |
---|
| 131 | << "[ Id = " << this->getId() << " ] " |
---|
| 132 | << "The global domain is badly defined," |
---|
| 133 | << " check the \'ni_glo\' et \'nj_glo\' values !") |
---|
| 134 | } |
---|
[509] | 135 | |
---|
[664] | 136 | isDistributed_ = !ibegin.isEmpty() || !ni.isEmpty() || !jbegin.isEmpty() || !nj.isEmpty(); |
---|
[509] | 137 | |
---|
[664] | 138 | checkLocalIDomain(); |
---|
| 139 | checkLocalJDomain(); |
---|
[509] | 140 | |
---|
[664] | 141 | if (i_index.isEmpty()) |
---|
| 142 | { |
---|
| 143 | i_index.resize(ni*nj); |
---|
| 144 | for (int j = 0; j < nj; ++j) |
---|
| 145 | for (int i = 0; i < ni; ++i) i_index(i+j*ni) = i+ibegin; |
---|
| 146 | } |
---|
[594] | 147 | |
---|
[664] | 148 | if (j_index.isEmpty()) |
---|
| 149 | { |
---|
| 150 | j_index.resize(ni*nj); |
---|
| 151 | for (int j = 0; j < nj; ++j) |
---|
| 152 | for (int i = 0; i < ni; ++i) j_index(i+j*ni) = j+jbegin; |
---|
| 153 | } |
---|
| 154 | computeNGlobDomain(); |
---|
[663] | 155 | |
---|
[664] | 156 | if (0 == global_zoom_ni) global_zoom_ni = ni_glo; |
---|
| 157 | if (0 == global_zoom_nj) global_zoom_nj = nj_glo; |
---|
[219] | 158 | } |
---|
| 159 | |
---|
| 160 | //---------------------------------------------------------------- |
---|
| 161 | |
---|
| 162 | void CDomain::checkLocalIDomain(void) |
---|
| 163 | { |
---|
[657] | 164 | if (ibegin.isEmpty() && ni.isEmpty()) |
---|
[219] | 165 | { |
---|
[594] | 166 | ibegin = 0; |
---|
| 167 | ni = ni_glo; |
---|
| 168 | } |
---|
[657] | 169 | else if (!i_index.isEmpty()) |
---|
[219] | 170 | { |
---|
[657] | 171 | ibegin = i_index(0); |
---|
[219] | 172 | } |
---|
| 173 | |
---|
[657] | 174 | if (ni.getValue() < 0 || ibegin.getValue() < 0 || |
---|
| 175 | (ibegin.getValue() + ni.getValue()) > ni_glo.getValue()) |
---|
[594] | 176 | { |
---|
| 177 | ERROR("CDomain::checkLocalIDomain(void)", |
---|
| 178 | << "[ Id = " << this->getId() << " ] " |
---|
| 179 | << "The local domain is wrongly defined," |
---|
[657] | 180 | << " check the attributes 'ni_glo', 'ni' and 'ibegin'"); |
---|
[594] | 181 | } |
---|
[219] | 182 | } |
---|
| 183 | |
---|
| 184 | //---------------------------------------------------------------- |
---|
| 185 | void CDomain::checkLocalJDomain(void) |
---|
| 186 | { |
---|
[657] | 187 | if (jbegin.isEmpty() && nj.isEmpty()) |
---|
| 188 | { |
---|
| 189 | jbegin = 0; |
---|
| 190 | nj = nj_glo; |
---|
| 191 | } |
---|
| 192 | else if (!j_index.isEmpty()) |
---|
| 193 | { |
---|
| 194 | jbegin = j_index(0); |
---|
| 195 | } |
---|
[219] | 196 | |
---|
[657] | 197 | if (nj.getValue() < 0 || jbegin.getValue() < 0 || |
---|
| 198 | (jbegin.getValue() + nj.getValue()) > nj_glo.getValue()) |
---|
[594] | 199 | { |
---|
| 200 | ERROR("CDomain::checkLocalJDomain(void)", |
---|
| 201 | << "[ Id = " << this->getId() << " ] " |
---|
| 202 | << "The local domain is wrongly defined," |
---|
[657] | 203 | << " check the attributes 'nj_glo', 'nj' and 'jbegin'"); |
---|
[594] | 204 | } |
---|
[219] | 205 | } |
---|
| 206 | |
---|
| 207 | //---------------------------------------------------------------- |
---|
| 208 | void CDomain::checkMask(void) |
---|
| 209 | { |
---|
| 210 | using namespace std; |
---|
[509] | 211 | |
---|
[219] | 212 | int ibegin_mask = 0, |
---|
| 213 | jbegin_mask = 0, |
---|
[657] | 214 | iend_mask = ibegin.getValue() + ni.getValue() - 1, |
---|
| 215 | jend_mask = jbegin.getValue() + nj.getValue() - 1; |
---|
[509] | 216 | |
---|
[664] | 217 | if (!mask_1d.isEmpty() && !mask_2d.isEmpty()) |
---|
[657] | 218 | ERROR("CDomain::checkMask(void)", |
---|
[664] | 219 | <<"Only one mask is used but both mask_1d and mask_2d are defined! "<<endl |
---|
| 220 | <<"Define only one mask: mask_1d or mask_2d "); |
---|
[657] | 221 | |
---|
[664] | 222 | if (!mask_1d.isEmpty() && mask_2d.isEmpty()) |
---|
[219] | 223 | { |
---|
[664] | 224 | if (mask_1d.numElements() != i_index.numElements()) |
---|
[657] | 225 | ERROR("CDomain::checkMask(void)", |
---|
[664] | 226 | <<"the mask_1d has not the same size as the local domain"<<endl |
---|
[657] | 227 | <<"Local size is "<<i_index.numElements()<<endl |
---|
[664] | 228 | <<"Mask size is "<<mask_1d.numElements()); |
---|
[657] | 229 | } |
---|
[509] | 230 | |
---|
[664] | 231 | if (mask_1d.isEmpty() && !mask_2d.isEmpty()) |
---|
[657] | 232 | { |
---|
[664] | 233 | if ((mask_2d.extent(0) != ni) || |
---|
| 234 | (mask_2d.extent(1) != nj)) |
---|
[657] | 235 | ERROR("CDomain::checkMask(void)", |
---|
[664] | 236 | <<"the mask has not the same size as the local domain"<<endl |
---|
[657] | 237 | <<"Local size is "<<ni<<"x"<<nj<<endl |
---|
[664] | 238 | <<"Mask size is "<<mask_2d.extent(0)<<"x"<<mask_2d.extent(1)); |
---|
[657] | 239 | } |
---|
[509] | 240 | |
---|
[664] | 241 | if (!mask_2d.isEmpty()) |
---|
[657] | 242 | { |
---|
[664] | 243 | mask_1d.resize(mask_2d.extent(0) * mask_2d.extent(1)); |
---|
[657] | 244 | for (int j = 0; j < nj; ++j) |
---|
[664] | 245 | for (int i = 0; i < ni; ++i) mask_1d(i+j*ni) = mask_2d(i,j); |
---|
[657] | 246 | } |
---|
| 247 | else |
---|
| 248 | { |
---|
[664] | 249 | mask_1d.resize(i_index.numElements()); |
---|
| 250 | for (int i = 0; i < i_index.numElements(); ++i) mask_1d(i) = true; |
---|
[657] | 251 | } |
---|
[219] | 252 | } |
---|
| 253 | |
---|
| 254 | |
---|
| 255 | //---------------------------------------------------------------- |
---|
| 256 | void CDomain::checkDomainData(void) |
---|
[509] | 257 | { |
---|
[219] | 258 | if (!data_dim.isEmpty() && |
---|
| 259 | !(data_dim.getValue() == 1 || data_dim.getValue() == 2)) |
---|
| 260 | { |
---|
| 261 | ERROR("CDomain::checkAttributes(void)", |
---|
[421] | 262 | << "Data dimension incompatible (must be 1 or 2) !") ; |
---|
[219] | 263 | } |
---|
| 264 | else if (data_dim.isEmpty()) |
---|
| 265 | { |
---|
[660] | 266 | data_dim.setValue(1); |
---|
[219] | 267 | } |
---|
| 268 | |
---|
| 269 | if (data_ibegin.isEmpty()) |
---|
| 270 | data_ibegin.setValue(0) ; |
---|
[660] | 271 | if (data_jbegin.isEmpty()) |
---|
[219] | 272 | data_jbegin.setValue(0) ; |
---|
| 273 | |
---|
| 274 | if (!data_ni.isEmpty() && (data_ni.getValue() <= 0)) |
---|
| 275 | { |
---|
| 276 | ERROR("CDomain::checkAttributes(void)", |
---|
[421] | 277 | << "Data dimension is negative (data_ni).") ; |
---|
[219] | 278 | } |
---|
| 279 | else if (data_ni.isEmpty()) |
---|
| 280 | { |
---|
| 281 | data_ni.setValue((data_dim.getValue() == 1) |
---|
| 282 | ? (ni.getValue() * nj.getValue()) |
---|
| 283 | : ni.getValue()); |
---|
| 284 | } |
---|
| 285 | |
---|
[660] | 286 | if (!data_nj.isEmpty() && (data_nj.getValue() <= 0) ) |
---|
[219] | 287 | { |
---|
[660] | 288 | ERROR("CDomain::checkAttributes(void)", |
---|
| 289 | << "Data dimension is negative (data_nj).") ; |
---|
[219] | 290 | } |
---|
| 291 | |
---|
[660] | 292 | if (data_nj.isEmpty()) |
---|
| 293 | data_nj.setValue((data_dim.getValue() == 1) |
---|
| 294 | ? (ni.getValue() * nj.getValue()) |
---|
| 295 | : nj.getValue()); |
---|
| 296 | |
---|
[219] | 297 | } |
---|
| 298 | |
---|
| 299 | //---------------------------------------------------------------- |
---|
| 300 | void CDomain::checkCompression(void) |
---|
| 301 | { |
---|
| 302 | if (!data_i_index.isEmpty()) |
---|
| 303 | { |
---|
[664] | 304 | if (!data_j_index.isEmpty() && |
---|
| 305 | (data_j_index.numElements() != data_i_index.numElements())) |
---|
| 306 | { |
---|
| 307 | ERROR("CDomain::checkAttributes(void)", |
---|
| 308 | <<"Dimension data_j_index incompatible with data_i_index.") ; |
---|
| 309 | } |
---|
| 310 | |
---|
| 311 | if (2 == data_dim.getValue()) |
---|
| 312 | { |
---|
| 313 | if (data_j_index.isEmpty()) |
---|
[660] | 314 | { |
---|
| 315 | ERROR("CDomain::checkAttributes(void)", |
---|
[664] | 316 | <<"data_j_index must be defined !") ; |
---|
[660] | 317 | } |
---|
[664] | 318 | } |
---|
| 319 | else // (1 == data_dim.getValue()) |
---|
| 320 | { |
---|
| 321 | if (data_j_index.isEmpty()) |
---|
| 322 | { |
---|
| 323 | const int dni = data_ni.getValue(); |
---|
| 324 | data_j_index.resize(dni); |
---|
| 325 | for (int j = 0; j < dni; ++j) data_j_index(j) = 0; |
---|
| 326 | } |
---|
| 327 | } |
---|
[219] | 328 | } |
---|
| 329 | else |
---|
| 330 | { |
---|
[660] | 331 | if ((data_dim.getValue() == 2) && (!data_j_index.isEmpty())) |
---|
[421] | 332 | ERROR("CDomain::checkAttributes(void)", << "data_i_index undefined") ; |
---|
[219] | 333 | |
---|
[660] | 334 | if (1 == data_dim.getValue()) |
---|
[219] | 335 | { |
---|
| 336 | const int dni = data_ni.getValue(); |
---|
[369] | 337 | data_i_index.resize(dni) ; |
---|
[660] | 338 | data_j_index.resize(dni) ; |
---|
[666] | 339 | |
---|
[660] | 340 | for (int i = 0; i < dni; ++i) |
---|
| 341 | { |
---|
| 342 | data_i_index(i) = i; |
---|
| 343 | data_j_index(i) = 0; |
---|
| 344 | } |
---|
[219] | 345 | } |
---|
| 346 | else // (data_dim == 2) |
---|
| 347 | { |
---|
| 348 | const int dni = data_ni.getValue() * data_nj.getValue(); |
---|
[369] | 349 | data_i_index.resize(dni) ; |
---|
| 350 | data_j_index.resize(dni) ; |
---|
[509] | 351 | |
---|
[660] | 352 | for(int count = 0, j = 0; j < data_nj.getValue(); ++j) |
---|
[219] | 353 | { |
---|
[660] | 354 | for(int i = 0; i < data_ni.getValue(); ++i, ++count) |
---|
[219] | 355 | { |
---|
[660] | 356 | data_i_index(count) = i; |
---|
| 357 | data_j_index(count) = j; |
---|
[219] | 358 | } |
---|
| 359 | } |
---|
| 360 | } |
---|
| 361 | } |
---|
| 362 | } |
---|
| 363 | |
---|
[666] | 364 | //---------------------------------------------------------------- |
---|
| 365 | void CDomain::completeLonLatClient(void) |
---|
[219] | 366 | { |
---|
[664] | 367 | int i,j,k ; |
---|
| 368 | CArray<double,1> lonvalue_temp(ni*nj) ; |
---|
| 369 | CArray<double,2> bounds_lon_temp(nvertex,ni*nj); |
---|
[666] | 370 | CArray<double,1> latvalue_temp(ni*nj) ; |
---|
| 371 | CArray<double,2> bounds_lat_temp(nvertex,ni*nj); |
---|
[509] | 372 | |
---|
[664] | 373 | if (!lonvalue_2d.isEmpty()) |
---|
| 374 | { |
---|
| 375 | for (j = 0; j < nj; ++j) |
---|
| 376 | for (i = 0; i < ni; ++i) |
---|
[384] | 377 | { |
---|
[664] | 378 | lonvalue_temp(i+j*ni) = lonvalue_2d(i,j); |
---|
[666] | 379 | latvalue_temp(i+j*ni) = latvalue_2d(i,j); |
---|
[449] | 380 | if (hasBounds) |
---|
| 381 | { |
---|
[664] | 382 | k=j*ni+i; |
---|
[666] | 383 | for(int n=0;n<nvertex;++n) |
---|
| 384 | { |
---|
| 385 | bounds_lon_temp(n,k) = bounds_lon_2d(n,i,j); |
---|
| 386 | bounds_lat_temp(n,k) = bounds_lat_2d(n,i,j); |
---|
| 387 | } |
---|
[449] | 388 | } |
---|
[384] | 389 | } |
---|
[664] | 390 | } |
---|
[509] | 391 | |
---|
[664] | 392 | if (!lonvalue_1d.isEmpty()) |
---|
| 393 | { |
---|
| 394 | if (type_attr::rectilinear == type) |
---|
| 395 | { |
---|
[666] | 396 | if ((ni == lonvalue_1d.numElements()) && (nj == latvalue_1d.numElements())) |
---|
[664] | 397 | { |
---|
| 398 | for(j=0;j<nj;++j) |
---|
| 399 | for(i=0;i<ni;++i) |
---|
| 400 | { |
---|
| 401 | k=j*ni+i; |
---|
| 402 | lonvalue_temp(k) = lonvalue_1d(i); |
---|
[666] | 403 | latvalue_temp(k) = latvalue_1d(j); |
---|
[664] | 404 | if (hasBounds) |
---|
| 405 | { |
---|
[666] | 406 | for(int n=0;n<nvertex;++n) |
---|
| 407 | { |
---|
| 408 | bounds_lon_temp(n,k) = bounds_lon_1d(n,i); |
---|
| 409 | bounds_lat_temp(n,k) = bounds_lat_1d(n,j); |
---|
| 410 | } |
---|
[664] | 411 | } |
---|
| 412 | } |
---|
| 413 | } |
---|
| 414 | else |
---|
| 415 | ERROR("CDomain::completeLonClient(void)", |
---|
[666] | 416 | <<"lonvalue_1d and latvalue_1d has not the same size as the local domain"<<endl |
---|
| 417 | <<"Local size is "<<ni<<"x " << nj<< endl |
---|
| 418 | <<"lonvalue_1d size is "<<lonvalue_1d.numElements() |
---|
| 419 | <<"latvalue_1d size is "<<latvalue_1d.numElements()); |
---|
[664] | 420 | } |
---|
| 421 | else if (type==type_attr::curvilinear || type==type_attr::unstructured) |
---|
| 422 | { |
---|
| 423 | lonvalue_temp=lonvalue_1d; |
---|
[666] | 424 | latvalue_temp=latvalue_1d; |
---|
[664] | 425 | if (hasBounds) |
---|
| 426 | { |
---|
| 427 | bounds_lon_temp=bounds_lon_1d; |
---|
[666] | 428 | bounds_lat_temp=bounds_lat_1d; |
---|
[664] | 429 | } |
---|
| 430 | } |
---|
| 431 | } |
---|
[266] | 432 | |
---|
[666] | 433 | int i_ind,j_ind; |
---|
| 434 | int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1; |
---|
| 435 | int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1; |
---|
[664] | 436 | |
---|
[666] | 437 | int globalIndexCountZoom = 0; |
---|
| 438 | int nbIndex = i_index.numElements(); |
---|
| 439 | for (i = 0; i < nbIndex; ++i) |
---|
| 440 | { |
---|
| 441 | i_ind=i_index(i); |
---|
| 442 | j_ind=j_index(i); |
---|
[509] | 443 | |
---|
[666] | 444 | if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) |
---|
| 445 | { |
---|
| 446 | ++globalIndexCountZoom; |
---|
| 447 | } |
---|
| 448 | } |
---|
[584] | 449 | |
---|
[666] | 450 | // Make sure that this attribute is non-empty for every client. |
---|
| 451 | if (0 != globalIndexCountZoom) |
---|
[664] | 452 | { |
---|
[666] | 453 | lonvalue_client.resize(globalIndexCountZoom); |
---|
| 454 | latvalue_client.resize(globalIndexCountZoom); |
---|
| 455 | if (hasBounds) |
---|
[664] | 456 | { |
---|
[666] | 457 | bounds_lon_client.resize(nvertex,globalIndexCountZoom); |
---|
| 458 | bounds_lat_client.resize(nvertex,globalIndexCountZoom); |
---|
[664] | 459 | } |
---|
| 460 | } |
---|
| 461 | |
---|
[666] | 462 | int nCountZoom = 0; |
---|
| 463 | for (i = 0; i < nbIndex; ++i) |
---|
[664] | 464 | { |
---|
[666] | 465 | i_ind=i_index(i); |
---|
| 466 | j_ind=j_index(i); |
---|
[664] | 467 | |
---|
[666] | 468 | if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) |
---|
[664] | 469 | { |
---|
[666] | 470 | lonvalue_client(nCountZoom) = lonvalue_temp(i); |
---|
| 471 | latvalue_client(nCountZoom) = latvalue_temp(i); |
---|
[664] | 472 | if (hasBounds) |
---|
| 473 | { |
---|
[666] | 474 | for (int n = 0; n < nvertex; ++n) |
---|
[664] | 475 | { |
---|
[666] | 476 | bounds_lon_client(n,nCountZoom) = bounds_lon_temp(n,i); |
---|
| 477 | bounds_lat_client(n,nCountZoom) = bounds_lat_temp(n,i); |
---|
[664] | 478 | } |
---|
| 479 | } |
---|
[666] | 480 | ++nCountZoom; |
---|
[664] | 481 | } |
---|
| 482 | } |
---|
| 483 | } |
---|
| 484 | |
---|
[449] | 485 | void CDomain::checkBounds(void) |
---|
| 486 | { |
---|
[664] | 487 | if (!nvertex.isEmpty() && (0 != nvertex.getValue())) |
---|
[449] | 488 | { |
---|
[664] | 489 | if (!bounds_lon_1d.isEmpty() && !bounds_lon_2d.isEmpty()) |
---|
| 490 | ERROR("CDomain::checkBounds(void)", |
---|
| 491 | <<"Only one longitude boundary value can be used but both bounds_lon_1d and bounds_lon_2d are defined! "<<endl |
---|
| 492 | <<"Define only one longitude boundary value: lonvalue_1d or bounds_lon_2d "); |
---|
| 493 | |
---|
| 494 | if (!bounds_lat_1d.isEmpty() && !bounds_lat_2d.isEmpty()) |
---|
| 495 | ERROR("CDomain::checkBounds(void)", |
---|
| 496 | <<"Only one latitude boundary value can be used but both bounds_lat_1d and bounds_lat_2d are defined! "<<endl |
---|
| 497 | <<"Define only one latitude boundary value: bounds_lat_1d or bounds_lat_2d "); |
---|
| 498 | |
---|
| 499 | if ((!bounds_lon_1d.isEmpty() && bounds_lat_1d.isEmpty()) || (bounds_lon_1d.isEmpty() && !bounds_lat_1d.isEmpty())) |
---|
| 500 | { |
---|
| 501 | ERROR("CDomain::checkBounds(void)", |
---|
| 502 | <<"Only bounds_lon_1d or bounds_lat_1d is defined "<<endl |
---|
| 503 | <<"Both must be defined "); |
---|
| 504 | } |
---|
| 505 | |
---|
| 506 | if ((!bounds_lon_2d.isEmpty() && bounds_lat_2d.isEmpty()) || (bounds_lon_2d.isEmpty() && !bounds_lat_2d.isEmpty())) |
---|
| 507 | { |
---|
| 508 | ERROR("CDomain::checkBounds(void)", |
---|
| 509 | <<"Only bounds_lon_2d or bounds_lat_2d is defined "<<endl |
---|
| 510 | <<"Both must be defined "); |
---|
| 511 | } |
---|
| 512 | |
---|
| 513 | if (!bounds_lon_1d.isEmpty() && (nvertex.getValue() != bounds_lon_1d.extent(0))) |
---|
| 514 | ERROR("CDomain::checkBounds(void)", |
---|
| 515 | <<"Only bounds_lon_1d and nvertex are not compatible"<<endl |
---|
| 516 | <<"bounds_lon_1d dimension is " << bounds_lon_1d.extent(1) |
---|
| 517 | <<"but nvertex is " << nvertex.getValue()); |
---|
| 518 | |
---|
| 519 | if (!bounds_lon_2d.isEmpty() && (nvertex.getValue() != bounds_lon_2d.extent(0))) |
---|
| 520 | ERROR("CDomain::checkBounds(void)", |
---|
| 521 | <<"Only bounds_lon_2d and nvertex are not compatible"<<endl |
---|
| 522 | <<"bounds_lon_2d dimension is " << bounds_lon_1d.extent(2) |
---|
| 523 | <<"but nvertex is " << nvertex.getValue()); |
---|
| 524 | |
---|
| 525 | if (!bounds_lon_1d.isEmpty() && lonvalue_1d.isEmpty()) |
---|
| 526 | ERROR("CDomain::checkBounds(void)", |
---|
| 527 | <<"Both bounds_lon_1d and lonvalue_1d must be defined"<<endl); |
---|
| 528 | |
---|
| 529 | if (!bounds_lon_2d.isEmpty() && lonvalue_2d.isEmpty()) |
---|
| 530 | ERROR("CDomain::checkBounds(void)", |
---|
| 531 | <<"Both bounds_lon_1d and lonvalue_1d must be defined"<<endl); |
---|
| 532 | |
---|
| 533 | if (!bounds_lat_1d.isEmpty() && (nvertex.getValue() != bounds_lat_1d.extent(0))) |
---|
| 534 | ERROR("CDomain::checkBounds(void)", |
---|
| 535 | <<"Only bounds_lat_1d and nvertex are not compatible"<<endl |
---|
| 536 | <<"bounds_lat_1d dimension is " << bounds_lat_1d.extent(1) |
---|
| 537 | <<"but nvertex is " << nvertex.getValue()); |
---|
| 538 | |
---|
| 539 | if (!bounds_lat_2d.isEmpty() && (nvertex.getValue() != bounds_lat_2d.extent(0))) |
---|
| 540 | ERROR("CDomain::checkBounds(void)", |
---|
| 541 | <<"Only bounds_lat_2d and nvertex are not compatible"<<endl |
---|
| 542 | <<"bounds_lat_2d dimension is " << bounds_lat_1d.extent(2) |
---|
| 543 | <<"but nvertex is " << nvertex.getValue()); |
---|
| 544 | |
---|
| 545 | if (!bounds_lat_1d.isEmpty() && latvalue_1d.isEmpty()) |
---|
| 546 | ERROR("CDomain::checkBounds(void)", |
---|
| 547 | <<"Both bounds_lat_1d and latvalue_1d must be defined"<<endl); |
---|
| 548 | |
---|
| 549 | if (!bounds_lat_2d.isEmpty() && latvalue_2d.isEmpty()) |
---|
| 550 | ERROR("CDomain::checkBounds(void)", |
---|
| 551 | <<"Both bounds_lat_1d and latvalue_1d must be defined"<<endl); |
---|
[449] | 552 | hasBounds=true ; |
---|
| 553 | } |
---|
[509] | 554 | else |
---|
[449] | 555 | { |
---|
| 556 | hasBounds=false; |
---|
| 557 | nvertex=0 ; |
---|
| 558 | } |
---|
| 559 | } |
---|
[509] | 560 | |
---|
[611] | 561 | void CDomain::checkArea(void) |
---|
| 562 | { |
---|
| 563 | hasArea = !area.isEmpty(); |
---|
| 564 | if (hasArea) |
---|
| 565 | { |
---|
| 566 | if (area.extent(0) != ni || area.extent(1) != nj) |
---|
| 567 | { |
---|
| 568 | ERROR("void CDomain::checkArea(void)", |
---|
| 569 | "The area attribute must be of size ni x nj."); |
---|
| 570 | } |
---|
| 571 | } |
---|
| 572 | } |
---|
| 573 | |
---|
[665] | 574 | void CDomain::checkLonLat() |
---|
| 575 | { |
---|
| 576 | hasLonLat = (!latvalue_1d.isEmpty() && !lonvalue_1d.isEmpty()) || |
---|
| 577 | (!latvalue_2d.isEmpty() && !lonvalue_2d.isEmpty()); |
---|
[666] | 578 | if (hasLonLat) |
---|
| 579 | { |
---|
| 580 | if (!lonvalue_1d.isEmpty() && !lonvalue_2d.isEmpty()) |
---|
| 581 | ERROR("CDomain::completeLonLatClient(void)", |
---|
| 582 | <<"Only one longitude value can be used but both lonvalue_1d and lonvalue_2d are defined! "<<endl |
---|
| 583 | <<"Define only one longitude value: lonvalue_1d or lonvalue_2d "); |
---|
| 584 | |
---|
| 585 | if (!lonvalue_1d.isEmpty() && lonvalue_2d.isEmpty()) |
---|
| 586 | { |
---|
| 587 | if (lonvalue_1d.numElements() != i_index.numElements()) |
---|
| 588 | ERROR("CDomain::completeLonLatClient(void)", |
---|
| 589 | <<"lonvalue_1d has not the same size as the local domain"<<endl |
---|
| 590 | <<"Local size is "<<i_index.numElements()<<endl |
---|
| 591 | <<"lonvalue_1d size is "<<lonvalue_1d.numElements()); |
---|
| 592 | } |
---|
| 593 | |
---|
| 594 | if (lonvalue_1d.isEmpty() && !lonvalue_2d.isEmpty()) |
---|
| 595 | { |
---|
| 596 | if ((lonvalue_2d.extent(0) != ni) || |
---|
| 597 | (lonvalue_2d.extent(1) != nj)) |
---|
| 598 | ERROR("CDomain::completeLonLatClient(void)", |
---|
| 599 | <<"the lonvalue has not the same size as the local domain"<<endl |
---|
| 600 | <<"Local size is "<<ni<<"x"<<nj<<endl |
---|
| 601 | <<"Lonvalue size is "<<lonvalue_2d.extent(0)<<"x"<<lonvalue_2d.extent(1)); |
---|
| 602 | } |
---|
| 603 | |
---|
| 604 | if (!latvalue_1d.isEmpty() && !latvalue_2d.isEmpty()) |
---|
| 605 | ERROR("CDomain::completeLonLatClient(void)", |
---|
| 606 | <<"Only one longitude value can be used but both latvalue_1d and latvalue_2d are defined! "<<endl |
---|
| 607 | <<"Define only one longitude value: latvalue_1d or latvalue_2d "); |
---|
| 608 | |
---|
| 609 | if (!latvalue_1d.isEmpty() && latvalue_2d.isEmpty()) |
---|
| 610 | { |
---|
| 611 | if (latvalue_1d.numElements() != i_index.numElements()) |
---|
| 612 | ERROR("CDomain::completeLonLatClient(void)", |
---|
| 613 | <<"the latvalue_1d has not the same size as the local domain"<<endl |
---|
| 614 | <<"Local size is "<<i_index.numElements()<<endl |
---|
| 615 | <<"Mask size is "<<latvalue_1d.numElements()); |
---|
| 616 | } |
---|
| 617 | |
---|
| 618 | if (latvalue_1d.isEmpty() && !latvalue_2d.isEmpty()) |
---|
| 619 | { |
---|
| 620 | if ((latvalue_2d.extent(0) != ni) || |
---|
| 621 | (latvalue_2d.extent(1) != nj)) |
---|
| 622 | ERROR("CDomain::completeLonLatClient(void)", |
---|
| 623 | <<"the mask has not the same size as the local domain"<<endl |
---|
| 624 | <<"Local size is "<<ni<<"x"<<nj<<endl |
---|
| 625 | <<"Mask size is "<<latvalue_2d.extent(0)<<"x"<<latvalue_2d.extent(1)); |
---|
| 626 | } |
---|
| 627 | } |
---|
[665] | 628 | } |
---|
| 629 | |
---|
[657] | 630 | void CDomain::checkAttributesOnClientAfterTransformation() |
---|
| 631 | { |
---|
| 632 | CContext* context=CContext::getCurrent() ; |
---|
| 633 | |
---|
| 634 | if (this->isClientAfterTransformationChecked) return; |
---|
| 635 | if (context->hasClient) |
---|
| 636 | { |
---|
| 637 | this->checkMask(); |
---|
[665] | 638 | if (hasLonLat || hasArea) this->computeConnectedServer(); |
---|
| 639 | if (hasLonLat) this->completeLonLatClient(); |
---|
[657] | 640 | } |
---|
| 641 | |
---|
| 642 | this->isClientAfterTransformationChecked = true; |
---|
| 643 | } |
---|
| 644 | |
---|
[219] | 645 | //---------------------------------------------------------------- |
---|
[664] | 646 | // Divide function checkAttributes into 2 seperate onescheckBounds |
---|
[509] | 647 | // This function only checks all attributes of current domain |
---|
| 648 | void CDomain::checkAttributesOnClient() |
---|
| 649 | { |
---|
| 650 | if (this->isClientChecked) return; |
---|
| 651 | CContext* context=CContext::getCurrent(); |
---|
[219] | 652 | |
---|
[509] | 653 | this->checkDomain(); |
---|
| 654 | this->checkBounds(); |
---|
[611] | 655 | this->checkArea(); |
---|
[665] | 656 | this->checkLonLat(); |
---|
[509] | 657 | |
---|
| 658 | if (context->hasClient) |
---|
| 659 | { // CÎté client uniquement |
---|
| 660 | this->checkMask(); |
---|
| 661 | this->checkDomainData(); |
---|
| 662 | this->checkCompression(); |
---|
| 663 | } |
---|
| 664 | else |
---|
| 665 | { // CÎté serveur uniquement |
---|
| 666 | } |
---|
| 667 | |
---|
| 668 | this->isClientChecked = true; |
---|
| 669 | } |
---|
| 670 | |
---|
| 671 | // Send all checked attributes to server |
---|
| 672 | void CDomain::sendCheckedAttributes() |
---|
| 673 | { |
---|
| 674 | if (!this->isClientChecked) checkAttributesOnClient(); |
---|
[657] | 675 | if (!this->isClientAfterTransformationChecked) checkAttributesOnClientAfterTransformation(); |
---|
[509] | 676 | CContext* context=CContext::getCurrent() ; |
---|
| 677 | |
---|
| 678 | if (this->isChecked) return; |
---|
| 679 | if (context->hasClient) |
---|
| 680 | { |
---|
[665] | 681 | sendServerAttribut(); |
---|
| 682 | if (hasLonLat || hasArea) sendLonLatArea(); |
---|
[509] | 683 | } |
---|
| 684 | |
---|
| 685 | this->isChecked = true; |
---|
| 686 | } |
---|
| 687 | |
---|
[219] | 688 | void CDomain::checkAttributes(void) |
---|
| 689 | { |
---|
| 690 | if (this->isChecked) return; |
---|
[347] | 691 | CContext* context=CContext::getCurrent() ; |
---|
[219] | 692 | |
---|
[467] | 693 | this->checkDomain(); |
---|
[665] | 694 | this->checkLonLat(); |
---|
[449] | 695 | this->checkBounds(); |
---|
[611] | 696 | this->checkArea(); |
---|
[509] | 697 | |
---|
[300] | 698 | if (context->hasClient) |
---|
[219] | 699 | { // CÎté client uniquement |
---|
| 700 | this->checkMask(); |
---|
| 701 | this->checkDomainData(); |
---|
| 702 | this->checkCompression(); |
---|
[666] | 703 | |
---|
[219] | 704 | } |
---|
| 705 | else |
---|
| 706 | { // CÎté serveur uniquement |
---|
| 707 | } |
---|
[509] | 708 | |
---|
[300] | 709 | if (context->hasClient) |
---|
| 710 | { |
---|
[666] | 711 | this->computeConnectedServer(); |
---|
| 712 | this->completeLonLatClient(); |
---|
| 713 | this->sendServerAttribut(); |
---|
| 714 | this->sendLonLatArea(); |
---|
[300] | 715 | } |
---|
[509] | 716 | |
---|
[219] | 717 | this->isChecked = true; |
---|
| 718 | } |
---|
[509] | 719 | |
---|
[300] | 720 | void CDomain::sendServerAttribut(void) |
---|
| 721 | { |
---|
[657] | 722 | CServerDistributionDescription serverDescription(nGlobDomain_); |
---|
[553] | 723 | |
---|
[595] | 724 | CContext* context = CContext::getCurrent(); |
---|
| 725 | CContextClient* client = context->client; |
---|
| 726 | int nbServer = client->serverSize; |
---|
[509] | 727 | |
---|
[657] | 728 | if (isUnstructed_) serverDescription.computeServerDistribution(nbServer,0); |
---|
| 729 | else serverDescription.computeServerDistribution(nbServer,1); |
---|
| 730 | |
---|
[595] | 731 | std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); |
---|
| 732 | std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); |
---|
[509] | 733 | |
---|
[595] | 734 | CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT); |
---|
| 735 | if (client->isServerLeader()) |
---|
| 736 | { |
---|
| 737 | std::list<CMessage> msgs; |
---|
[509] | 738 | |
---|
[595] | 739 | const std::list<int>& ranks = client->getRanksServerLeader(); |
---|
| 740 | for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) |
---|
| 741 | { |
---|
| 742 | // Use const int to ensure CMessage holds a copy of the value instead of just a reference |
---|
| 743 | const int ibegin_srv = serverIndexBegin[*itRank][0]; |
---|
| 744 | const int jbegin_srv = serverIndexBegin[*itRank][1]; |
---|
| 745 | const int ni_srv = serverDimensionSizes[*itRank][0]; |
---|
| 746 | const int nj_srv = serverDimensionSizes[*itRank][1]; |
---|
| 747 | const int iend_srv = ibegin_srv + ni_srv - 1; |
---|
| 748 | const int jend_srv = jbegin_srv + nj_srv - 1; |
---|
[509] | 749 | |
---|
[595] | 750 | msgs.push_back(CMessage()); |
---|
| 751 | CMessage& msg = msgs.back(); |
---|
| 752 | msg << this->getId() ; |
---|
| 753 | msg << ni_srv << ibegin_srv << iend_srv << nj_srv << jbegin_srv << jend_srv; |
---|
[631] | 754 | msg << global_zoom_ni << global_zoom_ibegin << global_zoom_nj << global_zoom_jbegin; |
---|
[595] | 755 | |
---|
| 756 | event.push(*itRank,1,msg); |
---|
| 757 | } |
---|
| 758 | client->sendEvent(event); |
---|
| 759 | } |
---|
| 760 | else client->sendEvent(event); |
---|
[300] | 761 | } |
---|
[467] | 762 | |
---|
[657] | 763 | void CDomain::computeNGlobDomain() |
---|
| 764 | { |
---|
| 765 | nGlobDomain_.resize(2); |
---|
| 766 | nGlobDomain_[0] = ni_glo.getValue(); |
---|
| 767 | nGlobDomain_[1] = nj_glo.getValue(); |
---|
| 768 | } |
---|
| 769 | |
---|
[300] | 770 | void CDomain::computeConnectedServer(void) |
---|
| 771 | { |
---|
[553] | 772 | CContext* context=CContext::getCurrent() ; |
---|
[300] | 773 | CContextClient* client=context->client ; |
---|
[553] | 774 | int nbServer=client->serverSize; |
---|
| 775 | bool doComputeGlobalIndexServer = true; |
---|
[449] | 776 | |
---|
[657] | 777 | int i,j,i_ind,j_ind, nbIndex; |
---|
[666] | 778 | int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1 ; |
---|
| 779 | int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1 ; |
---|
[509] | 780 | |
---|
[553] | 781 | // Precompute number of index |
---|
[584] | 782 | int globalIndexCountZoom = 0; |
---|
[657] | 783 | nbIndex = i_index.numElements(); |
---|
| 784 | for (i = 0; i < nbIndex; ++i) |
---|
| 785 | { |
---|
| 786 | i_ind=i_index(i); |
---|
| 787 | j_ind=j_index(i); |
---|
| 788 | |
---|
[666] | 789 | if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) |
---|
[467] | 790 | { |
---|
[657] | 791 | ++globalIndexCountZoom; |
---|
[467] | 792 | } |
---|
[657] | 793 | } |
---|
[467] | 794 | |
---|
[553] | 795 | // Fill in index |
---|
[584] | 796 | CArray<size_t,1> globalIndexDomainZoom(globalIndexCountZoom); |
---|
[657] | 797 | CArray<size_t,1> localIndexDomainZoom(globalIndexCountZoom); |
---|
| 798 | CArray<size_t,1> globalIndexDomain(nbIndex); |
---|
[553] | 799 | size_t globalIndex; |
---|
[584] | 800 | int globalIndexCount = 0; |
---|
| 801 | globalIndexCountZoom = 0; |
---|
[467] | 802 | |
---|
[657] | 803 | for (i = 0; i < nbIndex; ++i) |
---|
| 804 | { |
---|
| 805 | i_ind=i_index(i); |
---|
| 806 | j_ind=j_index(i); |
---|
| 807 | globalIndex = i_ind + j_ind * ni_glo; |
---|
| 808 | globalIndexDomain(globalIndexCount) = globalIndex; |
---|
| 809 | ++globalIndexCount; |
---|
[666] | 810 | if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) |
---|
[467] | 811 | { |
---|
[657] | 812 | globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; |
---|
| 813 | localIndexDomainZoom(globalIndexCountZoom) = i; |
---|
| 814 | ++globalIndexCountZoom; |
---|
[300] | 815 | } |
---|
[657] | 816 | } |
---|
[509] | 817 | |
---|
[569] | 818 | size_t globalSizeIndex = 1, indexBegin, indexEnd; |
---|
| 819 | int range, clientSize = client->clientSize; |
---|
[657] | 820 | for (int i = 0; i < nGlobDomain_.size(); ++i) globalSizeIndex *= nGlobDomain_[i]; |
---|
[569] | 821 | indexBegin = 0; |
---|
| 822 | for (int i = 0; i < clientSize; ++i) |
---|
| 823 | { |
---|
| 824 | range = globalSizeIndex / clientSize; |
---|
| 825 | if (i < (globalSizeIndex%clientSize)) ++range; |
---|
| 826 | if (i == client->clientRank) break; |
---|
| 827 | indexBegin += range; |
---|
| 828 | } |
---|
| 829 | indexEnd = indexBegin + range - 1; |
---|
| 830 | |
---|
[657] | 831 | CServerDistributionDescription serverDescription(nGlobDomain_); |
---|
| 832 | if (isUnstructed_) serverDescription.computeServerGlobalIndexInRange(nbServer, std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0); |
---|
| 833 | else serverDescription.computeServerGlobalIndexInRange(nbServer, std::make_pair<size_t,size_t>(indexBegin, indexEnd), 1); |
---|
| 834 | |
---|
[569] | 835 | CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), |
---|
| 836 | client->intraComm); |
---|
| 837 | clientServerMap->computeServerIndexMapping(globalIndexDomain); |
---|
| 838 | const std::map<int, std::vector<size_t> >& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); |
---|
[584] | 839 | |
---|
| 840 | std::map<int, std::vector<size_t> >::const_iterator it = globalIndexDomainOnServer.begin(), |
---|
| 841 | ite = globalIndexDomainOnServer.end(); |
---|
| 842 | indSrv_.clear(); |
---|
| 843 | for (; it != ite; ++it) |
---|
| 844 | { |
---|
| 845 | int rank = it->first; |
---|
| 846 | std::vector<size_t>::const_iterator itbVec = (it->second).begin(), |
---|
| 847 | iteVec = (it->second).end(); |
---|
| 848 | int nb = globalIndexDomainZoom.numElements(); |
---|
| 849 | for (int i = 0; i < nb; ++i) |
---|
| 850 | { |
---|
[585] | 851 | if (iteVec != std::find(itbVec, iteVec, globalIndexDomainZoom(i))) |
---|
[584] | 852 | { |
---|
[657] | 853 | indSrv_[rank].push_back(localIndexDomainZoom(i)); |
---|
[584] | 854 | } |
---|
| 855 | } |
---|
[553] | 856 | } |
---|
[569] | 857 | |
---|
[584] | 858 | connectedServerRank_.clear(); |
---|
| 859 | for (it = globalIndexDomainOnServer.begin(); it != ite; ++it) { |
---|
| 860 | connectedServerRank_.push_back(it->first); |
---|
| 861 | } |
---|
| 862 | |
---|
| 863 | if (!indSrv_.empty()) |
---|
| 864 | { |
---|
| 865 | connectedServerRank_.clear(); |
---|
| 866 | for (it = indSrv_.begin(); it != indSrv_.end(); ++it) |
---|
| 867 | connectedServerRank_.push_back(it->first); |
---|
| 868 | } |
---|
| 869 | nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); |
---|
| 870 | |
---|
[569] | 871 | delete clientServerMap; |
---|
[300] | 872 | } |
---|
[467] | 873 | |
---|
[657] | 874 | const std::map<int, vector<size_t> >& CDomain::getIndexServer() const |
---|
| 875 | { |
---|
| 876 | return indSrv_; |
---|
| 877 | } |
---|
| 878 | |
---|
[665] | 879 | void CDomain::sendIndex() |
---|
[300] | 880 | { |
---|
[610] | 881 | int ns, n, i, j, ind, nv, idx; |
---|
| 882 | CContext* context = CContext::getCurrent(); |
---|
| 883 | CContextClient* client=context->client; |
---|
| 884 | |
---|
[665] | 885 | CEventClient eventIndex(getType(), EVENT_ID_INDEX); |
---|
| 886 | |
---|
| 887 | list<CMessage> list_msgsIndex; |
---|
| 888 | list<CArray<int,1> > list_indi, list_indj; |
---|
| 889 | |
---|
| 890 | std::map<int, std::vector<size_t> >::const_iterator it, iteMap; |
---|
| 891 | iteMap = indSrv_.end(); |
---|
| 892 | for (int k = 0; k < connectedServerRank_.size(); ++k) |
---|
| 893 | { |
---|
| 894 | int nbData = 0; |
---|
| 895 | int rank = connectedServerRank_[k]; |
---|
| 896 | it = indSrv_.find(rank); |
---|
| 897 | if (iteMap != it) |
---|
| 898 | nbData = it->second.size(); |
---|
| 899 | |
---|
| 900 | list_indi.push_back(CArray<int,1>(nbData)); |
---|
| 901 | list_indj.push_back(CArray<int,1>(nbData)); |
---|
| 902 | |
---|
| 903 | CArray<int,1>& indi = list_indi.back(); |
---|
| 904 | CArray<int,1>& indj = list_indj.back(); |
---|
| 905 | const std::vector<size_t>& temp = it->second; |
---|
| 906 | for (n = 0; n < nbData; ++n) |
---|
| 907 | { |
---|
| 908 | idx = static_cast<int>(it->second[n]); |
---|
| 909 | indi(n) = i_index(idx); |
---|
| 910 | indj(n) = j_index(idx); |
---|
| 911 | } |
---|
| 912 | |
---|
| 913 | list_msgsIndex.push_back(CMessage()); |
---|
| 914 | |
---|
| 915 | list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix |
---|
| 916 | list_msgsIndex.back() << isCurvilinear; |
---|
| 917 | list_msgsIndex.back() << list_indi.back() << list_indj.back(); |
---|
| 918 | |
---|
| 919 | eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); |
---|
| 920 | } |
---|
| 921 | |
---|
| 922 | client->sendEvent(eventIndex); |
---|
| 923 | } |
---|
| 924 | |
---|
| 925 | void CDomain::sendArea() |
---|
| 926 | { |
---|
| 927 | if (!hasArea) return; |
---|
| 928 | |
---|
| 929 | int ns, n, i, j, ind, nv, idx; |
---|
| 930 | CContext* context = CContext::getCurrent(); |
---|
| 931 | CContextClient* client=context->client; |
---|
| 932 | |
---|
| 933 | // send area for each connected server |
---|
| 934 | CEventClient eventArea(getType(), EVENT_ID_AREA); |
---|
| 935 | |
---|
| 936 | list<CMessage> list_msgsArea; |
---|
| 937 | list<CArray<double,1> > list_area; |
---|
| 938 | |
---|
| 939 | std::map<int, std::vector<size_t> >::const_iterator it, iteMap; |
---|
| 940 | iteMap = indSrv_.end(); |
---|
| 941 | for (int k = 0; k < connectedServerRank_.size(); ++k) |
---|
| 942 | { |
---|
| 943 | int nbData = 0; |
---|
| 944 | int rank = connectedServerRank_[k]; |
---|
| 945 | it = indSrv_.find(rank); |
---|
| 946 | if (iteMap != it) |
---|
| 947 | nbData = it->second.size(); |
---|
| 948 | list_area.push_back(CArray<double,1>(nbData)); |
---|
| 949 | |
---|
| 950 | const std::vector<size_t>& temp = it->second; |
---|
| 951 | for (n = 0; n < nbData; ++n) |
---|
| 952 | { |
---|
| 953 | idx = static_cast<int>(it->second[n]); |
---|
| 954 | i = i_index(idx); |
---|
| 955 | j = j_index(idx); |
---|
| 956 | if (hasArea) |
---|
| 957 | list_area.back()(n) = area(i - ibegin, j - jbegin); |
---|
| 958 | } |
---|
| 959 | |
---|
| 960 | list_msgsArea.push_back(CMessage()); |
---|
| 961 | list_msgsArea.back() << this->getId() << list_area.back(); |
---|
| 962 | eventArea.push(rank, nbConnectedClients_[rank], list_msgsArea.back()); |
---|
| 963 | } |
---|
| 964 | client->sendEvent(eventArea); |
---|
| 965 | } |
---|
| 966 | |
---|
| 967 | void CDomain::sendLonLat() |
---|
| 968 | { |
---|
| 969 | if (!hasLonLat) return; |
---|
| 970 | |
---|
| 971 | int ns, n, i, j, ind, nv, idx; |
---|
| 972 | CContext* context = CContext::getCurrent(); |
---|
| 973 | CContextClient* client=context->client; |
---|
| 974 | |
---|
[300] | 975 | // send lon lat for each connected server |
---|
[610] | 976 | CEventClient eventLon(getType(), EVENT_ID_LON); |
---|
| 977 | CEventClient eventLat(getType(), EVENT_ID_LAT); |
---|
[509] | 978 | |
---|
[665] | 979 | list<CMessage> list_msgsLon, list_msgsLat; |
---|
[610] | 980 | list<CArray<double,1> > list_lon, list_lat; |
---|
| 981 | list<CArray<double,2> > list_boundslon, list_boundslat; |
---|
[518] | 982 | |
---|
[610] | 983 | std::map<int, std::vector<size_t> >::const_iterator it, iteMap; |
---|
[553] | 984 | iteMap = indSrv_.end(); |
---|
[584] | 985 | for (int k = 0; k < connectedServerRank_.size(); ++k) |
---|
[300] | 986 | { |
---|
[584] | 987 | int nbData = 0; |
---|
| 988 | int rank = connectedServerRank_[k]; |
---|
| 989 | it = indSrv_.find(rank); |
---|
| 990 | if (iteMap != it) |
---|
[610] | 991 | nbData = it->second.size(); |
---|
[584] | 992 | |
---|
[610] | 993 | list_lon.push_back(CArray<double,1>(nbData)); |
---|
| 994 | list_lat.push_back(CArray<double,1>(nbData)); |
---|
[509] | 995 | |
---|
[610] | 996 | if (hasBounds) |
---|
| 997 | { |
---|
| 998 | list_boundslon.push_back(CArray<double,2>(nvertex, nbData)); |
---|
| 999 | list_boundslat.push_back(CArray<double,2>(nvertex, nbData)); |
---|
| 1000 | } |
---|
| 1001 | |
---|
| 1002 | CArray<double,1>& lon = list_lon.back(); |
---|
| 1003 | CArray<double,1>& lat = list_lat.back(); |
---|
[657] | 1004 | const std::vector<size_t>& temp = it->second; |
---|
[553] | 1005 | for (n = 0; n < nbData; ++n) |
---|
[467] | 1006 | { |
---|
[610] | 1007 | idx = static_cast<int>(it->second[n]); |
---|
[666] | 1008 | lon(n) = lonvalue_client(idx); |
---|
| 1009 | lat(n) = latvalue_client(idx); |
---|
[509] | 1010 | |
---|
[467] | 1011 | if (hasBounds) |
---|
[300] | 1012 | { |
---|
[610] | 1013 | CArray<double,2>& boundslon = list_boundslon.back(); |
---|
| 1014 | CArray<double,2>& boundslat = list_boundslat.back(); |
---|
| 1015 | |
---|
[666] | 1016 | for (nv = 0; nv < nvertex; ++nv) |
---|
[449] | 1017 | { |
---|
[666] | 1018 | boundslon(nv, n) = bounds_lon_client(nv, idx); |
---|
| 1019 | boundslat(nv, n) = bounds_lat_client(nv, idx); |
---|
[449] | 1020 | } |
---|
[300] | 1021 | } |
---|
[467] | 1022 | } |
---|
[509] | 1023 | |
---|
[610] | 1024 | list_msgsLon.push_back(CMessage()); |
---|
| 1025 | list_msgsLat.push_back(CMessage()); |
---|
[518] | 1026 | |
---|
[610] | 1027 | list_msgsLon.back() << this->getId() << list_lon.back(); |
---|
| 1028 | list_msgsLat.back() << this->getId() << list_lat.back(); |
---|
| 1029 | |
---|
[518] | 1030 | if (hasBounds) |
---|
| 1031 | { |
---|
[610] | 1032 | list_msgsLon.back() << list_boundslon.back(); |
---|
| 1033 | list_msgsLat.back() << list_boundslat.back(); |
---|
[518] | 1034 | } |
---|
[584] | 1035 | |
---|
[610] | 1036 | eventLon.push(rank, nbConnectedClients_[rank], list_msgsLon.back()); |
---|
| 1037 | eventLat.push(rank, nbConnectedClients_[rank], list_msgsLat.back()); |
---|
[300] | 1038 | } |
---|
| 1039 | |
---|
[610] | 1040 | client->sendEvent(eventLon); |
---|
| 1041 | client->sendEvent(eventLat); |
---|
[300] | 1042 | } |
---|
[509] | 1043 | |
---|
[665] | 1044 | |
---|
| 1045 | void CDomain::sendLonLatArea(void) |
---|
| 1046 | { |
---|
| 1047 | sendIndex(); |
---|
| 1048 | sendLonLat(); |
---|
| 1049 | sendArea(); |
---|
| 1050 | } |
---|
| 1051 | |
---|
[300] | 1052 | bool CDomain::dispatchEvent(CEventServer& event) |
---|
[610] | 1053 | { |
---|
| 1054 | if (SuperClass::dispatchEvent(event)) return true; |
---|
| 1055 | else |
---|
| 1056 | { |
---|
| 1057 | switch(event.type) |
---|
[300] | 1058 | { |
---|
[610] | 1059 | case EVENT_ID_SERVER_ATTRIBUT: |
---|
| 1060 | recvServerAttribut(event); |
---|
| 1061 | return true; |
---|
| 1062 | break; |
---|
| 1063 | case EVENT_ID_INDEX: |
---|
| 1064 | recvIndex(event); |
---|
| 1065 | return true; |
---|
| 1066 | break; |
---|
| 1067 | case EVENT_ID_LON: |
---|
| 1068 | recvLon(event); |
---|
| 1069 | return true; |
---|
| 1070 | break; |
---|
| 1071 | case EVENT_ID_LAT: |
---|
| 1072 | recvLat(event); |
---|
| 1073 | return true; |
---|
| 1074 | break; |
---|
[611] | 1075 | case EVENT_ID_AREA: |
---|
| 1076 | recvArea(event); |
---|
| 1077 | return true; |
---|
| 1078 | break; |
---|
[610] | 1079 | default: |
---|
| 1080 | ERROR("bool CContext::dispatchEvent(CEventServer& event)", |
---|
| 1081 | << "Unknown Event"); |
---|
| 1082 | return false; |
---|
| 1083 | } |
---|
| 1084 | } |
---|
| 1085 | } |
---|
[509] | 1086 | |
---|
[300] | 1087 | void CDomain::recvServerAttribut(CEventServer& event) |
---|
| 1088 | { |
---|
| 1089 | CBufferIn* buffer=event.subEvents.begin()->buffer; |
---|
| 1090 | string domainId ; |
---|
| 1091 | *buffer>>domainId ; |
---|
| 1092 | get(domainId)->recvServerAttribut(*buffer) ; |
---|
| 1093 | } |
---|
[509] | 1094 | |
---|
[300] | 1095 | void CDomain::recvServerAttribut(CBufferIn& buffer) |
---|
| 1096 | { |
---|
[631] | 1097 | buffer >> ni_srv >> ibegin_srv >> iend_srv >> nj_srv >> jbegin_srv >> jend_srv |
---|
| 1098 | >> global_zoom_ni >> global_zoom_ibegin >> global_zoom_nj >> global_zoom_jbegin; |
---|
[300] | 1099 | |
---|
[631] | 1100 | int zoom_iend = global_zoom_ibegin + global_zoom_ni - 1; |
---|
| 1101 | int zoom_jend = global_zoom_jbegin + global_zoom_nj - 1; |
---|
[509] | 1102 | |
---|
[631] | 1103 | zoom_ibegin_srv = global_zoom_ibegin > ibegin_srv ? global_zoom_ibegin : ibegin_srv ; |
---|
[300] | 1104 | zoom_iend_srv = zoom_iend < iend_srv ? zoom_iend : iend_srv ; |
---|
| 1105 | zoom_ni_srv=zoom_iend_srv-zoom_ibegin_srv+1 ; |
---|
[509] | 1106 | |
---|
[631] | 1107 | zoom_jbegin_srv = global_zoom_jbegin > jbegin_srv ? global_zoom_jbegin : jbegin_srv ; |
---|
[300] | 1108 | zoom_jend_srv = zoom_jend < jend_srv ? zoom_jend : jend_srv ; |
---|
| 1109 | zoom_nj_srv=zoom_jend_srv-zoom_jbegin_srv+1 ; |
---|
| 1110 | |
---|
[509] | 1111 | if (zoom_ni_srv<=0 || zoom_nj_srv<=0) |
---|
[300] | 1112 | { |
---|
[551] | 1113 | zoom_ibegin_srv=0 ; zoom_iend_srv=0 ; zoom_ni_srv=0 ; |
---|
| 1114 | zoom_jbegin_srv=0 ; zoom_jend_srv=0 ; zoom_nj_srv=0 ; |
---|
[300] | 1115 | } |
---|
[369] | 1116 | lonvalue_srv.resize(zoom_ni_srv*zoom_nj_srv) ; |
---|
[456] | 1117 | lonvalue_srv = 0. ; |
---|
[369] | 1118 | latvalue_srv.resize(zoom_ni_srv*zoom_nj_srv) ; |
---|
[456] | 1119 | latvalue_srv = 0. ; |
---|
[509] | 1120 | if (hasBounds) |
---|
[456] | 1121 | { |
---|
| 1122 | bounds_lon_srv.resize(nvertex,zoom_ni_srv*zoom_nj_srv) ; |
---|
| 1123 | bounds_lon_srv = 0. ; |
---|
| 1124 | bounds_lat_srv.resize(nvertex,zoom_ni_srv*zoom_nj_srv) ; |
---|
| 1125 | bounds_lat_srv = 0. ; |
---|
| 1126 | } |
---|
[611] | 1127 | |
---|
| 1128 | if (hasArea) |
---|
| 1129 | area_srv.resize(zoom_ni_srv * zoom_nj_srv); |
---|
[300] | 1130 | } |
---|
[509] | 1131 | |
---|
[610] | 1132 | void CDomain::recvIndex(CEventServer& event) |
---|
| 1133 | { |
---|
| 1134 | list<CEventServer::SSubEvent>::iterator it; |
---|
| 1135 | for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) |
---|
| 1136 | { |
---|
| 1137 | CBufferIn* buffer = it->buffer; |
---|
| 1138 | string domainId; |
---|
| 1139 | *buffer >> domainId; |
---|
| 1140 | get(domainId)->recvIndex(it->rank, *buffer); |
---|
| 1141 | } |
---|
| 1142 | } |
---|
| 1143 | |
---|
| 1144 | void CDomain::recvIndex(int rank, CBufferIn& buffer) |
---|
| 1145 | { |
---|
| 1146 | int type_int; |
---|
| 1147 | buffer >> type_int >> isCurvilinear >> indiSrv[rank] >> indjSrv[rank]; |
---|
| 1148 | type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix |
---|
| 1149 | } |
---|
| 1150 | |
---|
[518] | 1151 | void CDomain::recvLon(CEventServer& event) |
---|
[300] | 1152 | { |
---|
[610] | 1153 | list<CEventServer::SSubEvent>::iterator it; |
---|
| 1154 | for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) |
---|
[300] | 1155 | { |
---|
[610] | 1156 | CBufferIn* buffer = it->buffer; |
---|
| 1157 | string domainId; |
---|
| 1158 | *buffer >> domainId; |
---|
| 1159 | get(domainId)->recvLon(it->rank, *buffer); |
---|
[300] | 1160 | } |
---|
| 1161 | } |
---|
[509] | 1162 | |
---|
[610] | 1163 | void CDomain::recvLon(int rank, CBufferIn& buffer) |
---|
[300] | 1164 | { |
---|
[610] | 1165 | CArray<int,1> &indi = indiSrv[rank], &indj = indjSrv[rank]; |
---|
| 1166 | CArray<double,1> lon; |
---|
| 1167 | CArray<double,2> boundslon; |
---|
[518] | 1168 | |
---|
[610] | 1169 | buffer >> lon; |
---|
| 1170 | if (hasBounds) buffer >> boundslon; |
---|
[518] | 1171 | |
---|
[610] | 1172 | int i, j, ind_srv; |
---|
| 1173 | for (int ind = 0; ind < indi.numElements(); ind++) |
---|
[518] | 1174 | { |
---|
[610] | 1175 | i = indi(ind); j = indj(ind); |
---|
| 1176 | ind_srv = (i - zoom_ibegin_srv) + (j - zoom_jbegin_srv) * zoom_ni_srv; |
---|
| 1177 | lonvalue_srv(ind_srv) = lon(ind); |
---|
[518] | 1178 | if (hasBounds) |
---|
| 1179 | { |
---|
[666] | 1180 | for (int nv = 0; nv < nvertex; ++nv) |
---|
[610] | 1181 | bounds_lon_srv(nv, ind_srv) = boundslon(nv, ind); |
---|
[518] | 1182 | } |
---|
| 1183 | } |
---|
| 1184 | } |
---|
| 1185 | |
---|
| 1186 | void CDomain::recvLat(CEventServer& event) |
---|
| 1187 | { |
---|
[610] | 1188 | list<CEventServer::SSubEvent>::iterator it; |
---|
| 1189 | for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) |
---|
[518] | 1190 | { |
---|
[610] | 1191 | CBufferIn* buffer = it->buffer; |
---|
| 1192 | string domainId; |
---|
| 1193 | *buffer >> domainId; |
---|
| 1194 | get(domainId)->recvLat(it->rank, *buffer); |
---|
[518] | 1195 | } |
---|
| 1196 | } |
---|
| 1197 | |
---|
[610] | 1198 | void CDomain::recvLat(int rank, CBufferIn& buffer) |
---|
[518] | 1199 | { |
---|
[610] | 1200 | CArray<int,1> &indi = indiSrv[rank], &indj = indjSrv[rank]; |
---|
| 1201 | CArray<double,1> lat; |
---|
| 1202 | CArray<double,2> boundslat; |
---|
[509] | 1203 | |
---|
[610] | 1204 | buffer >> lat; |
---|
| 1205 | if (hasBounds) buffer >> boundslat; |
---|
| 1206 | |
---|
| 1207 | int i, j, ind_srv; |
---|
| 1208 | for (int ind = 0; ind < indi.numElements(); ind++) |
---|
[300] | 1209 | { |
---|
[610] | 1210 | i = indi(ind); j = indj(ind); |
---|
| 1211 | ind_srv = (i - zoom_ibegin_srv) + (j - zoom_jbegin_srv) * zoom_ni_srv; |
---|
| 1212 | latvalue_srv(ind_srv) = lat(ind); |
---|
[509] | 1213 | if (hasBounds) |
---|
[449] | 1214 | { |
---|
[610] | 1215 | for (int nv = 0; nv < nvertex; nv++) |
---|
| 1216 | bounds_lat_srv(nv, ind_srv) = boundslat(nv, ind); |
---|
[449] | 1217 | } |
---|
[300] | 1218 | } |
---|
| 1219 | } |
---|
[553] | 1220 | |
---|
[611] | 1221 | void CDomain::recvArea(CEventServer& event) |
---|
| 1222 | { |
---|
| 1223 | list<CEventServer::SSubEvent>::iterator it; |
---|
| 1224 | for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) |
---|
| 1225 | { |
---|
| 1226 | CBufferIn* buffer = it->buffer; |
---|
| 1227 | string domainId; |
---|
| 1228 | *buffer >> domainId; |
---|
| 1229 | get(domainId)->recvArea(it->rank, *buffer); |
---|
| 1230 | } |
---|
| 1231 | } |
---|
| 1232 | |
---|
| 1233 | void CDomain::recvArea(int rank, CBufferIn& buffer) |
---|
| 1234 | { |
---|
| 1235 | CArray<int,1> &indi = indiSrv[rank], &indj = indjSrv[rank]; |
---|
| 1236 | CArray<double,1> clientArea; |
---|
| 1237 | |
---|
| 1238 | buffer >> clientArea; |
---|
| 1239 | |
---|
| 1240 | int i, j, ind_srv; |
---|
| 1241 | for (int ind = 0; ind < indi.numElements(); ind++) |
---|
| 1242 | { |
---|
| 1243 | i = indi(ind); j = indj(ind); |
---|
| 1244 | ind_srv = (i - zoom_ibegin_srv) + (j - zoom_jbegin_srv) * zoom_ni_srv; |
---|
| 1245 | area_srv(ind_srv) = clientArea(ind); |
---|
| 1246 | } |
---|
| 1247 | } |
---|
| 1248 | |
---|
[631] | 1249 | bool CDomain::hasTransformation() |
---|
| 1250 | { |
---|
| 1251 | return (!transformationMap_.empty()); |
---|
| 1252 | } |
---|
| 1253 | |
---|
| 1254 | void CDomain::setTransformations(const TransMapTypes& domTrans) |
---|
| 1255 | { |
---|
| 1256 | transformationMap_ = domTrans; |
---|
| 1257 | } |
---|
| 1258 | |
---|
| 1259 | CDomain::TransMapTypes CDomain::getAllTransformations(void) |
---|
| 1260 | { |
---|
| 1261 | return transformationMap_; |
---|
| 1262 | } |
---|
| 1263 | |
---|
| 1264 | /*! |
---|
| 1265 | Check the validity of all transformations applied on domain |
---|
| 1266 | This functions is called AFTER all inherited attributes are solved |
---|
| 1267 | */ |
---|
| 1268 | void CDomain::checkTransformations() |
---|
| 1269 | { |
---|
| 1270 | TransMapTypes::const_iterator itb = transformationMap_.begin(), it, |
---|
| 1271 | ite = transformationMap_.end(); |
---|
| 1272 | for (it = itb; it != ite; ++it) |
---|
| 1273 | { |
---|
| 1274 | (it->second)->checkValid(this); |
---|
| 1275 | } |
---|
| 1276 | } |
---|
| 1277 | |
---|
| 1278 | void CDomain::solveInheritanceTransformation() |
---|
| 1279 | { |
---|
| 1280 | if (this->hasTransformation()) return; |
---|
| 1281 | |
---|
| 1282 | std::vector<CDomain*> refDomain; |
---|
| 1283 | CDomain* refer_sptr; |
---|
| 1284 | CDomain* refer_ptr = this; |
---|
| 1285 | while (refer_ptr->hasDirectDomainReference()) |
---|
| 1286 | { |
---|
| 1287 | refDomain.push_back(refer_ptr); |
---|
| 1288 | refer_sptr = refer_ptr->getDirectDomainReference(); |
---|
| 1289 | refer_ptr = refer_sptr; |
---|
| 1290 | if (refer_ptr->hasTransformation()) break; |
---|
| 1291 | } |
---|
| 1292 | |
---|
| 1293 | if (refer_ptr->hasTransformation()) |
---|
| 1294 | for (int idx = 0; idx < refDomain.size(); ++idx) |
---|
| 1295 | refDomain[idx]->setTransformations(refer_ptr->getAllTransformations()); |
---|
| 1296 | } |
---|
| 1297 | |
---|
| 1298 | void CDomain::parse(xml::CXMLNode & node) |
---|
| 1299 | { |
---|
| 1300 | SuperClass::parse(node); |
---|
| 1301 | |
---|
| 1302 | if (node.goToChildElement()) |
---|
| 1303 | { |
---|
| 1304 | StdString zoomDomainDefRoot("zoom_domain_definition"); |
---|
| 1305 | StdString zoom("zoom_domain"); |
---|
[657] | 1306 | StdString interpFromFileDomainDefRoot("interpolate_from_file_domain_definition"); |
---|
| 1307 | StdString interpFromFile("interpolate_from_file_domain"); |
---|
[631] | 1308 | do |
---|
| 1309 | { |
---|
| 1310 | if (node.getElementName() == zoom) { |
---|
| 1311 | CZoomDomain* tmp = (CZoomDomainGroup::get(zoomDomainDefRoot))->createChild(); |
---|
| 1312 | tmp->parse(node); |
---|
| 1313 | transformationMap_.push_back(std::make_pair(TRANS_ZOOM_DOMAIN,tmp)); |
---|
| 1314 | } |
---|
[657] | 1315 | else if (node.getElementName() == interpFromFile) |
---|
| 1316 | { |
---|
| 1317 | CInterpolateFromFileDomain* tmp = (CInterpolateFromFileDomainGroup::get(interpFromFileDomainDefRoot))->createChild(); |
---|
| 1318 | tmp->parse(node); |
---|
| 1319 | transformationMap_.push_back(std::make_pair(TRANS_INTERPOLATE_DOMAIN_FROM_FILE,tmp)); |
---|
| 1320 | } |
---|
[631] | 1321 | } while (node.goToNextElement()) ; |
---|
| 1322 | node.goToParentElement(); |
---|
| 1323 | } |
---|
| 1324 | } |
---|
[219] | 1325 | //---------------------------------------------------------------- |
---|
[509] | 1326 | |
---|
[540] | 1327 | DEFINE_REF_FUNC(Domain,domain) |
---|
[509] | 1328 | |
---|
[219] | 1329 | ///--------------------------------------------------------------- |
---|
| 1330 | |
---|
[335] | 1331 | } // namespace xios |
---|