Changeset 369 for XIOS/trunk/src/node/grid.cpp
- Timestamp:
- 10/16/12 13:04:44 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/grid.cpp
r352 r369 11 11 #include "context.hpp" 12 12 #include "context_client.hpp" 13 #include "array_new.hpp" 13 14 14 15 namespace xios { … … 32 33 // this->axis.reset() ; 33 34 // this->domain.reset() ; 34 35 for (StdSize i = 0; i < this->storeIndex.size(); i++) 36 { 37 this->storeIndex[i].reset(); 38 this->out_i_index[i].reset(); 39 this->out_j_index[i].reset(); 40 this->out_l_index[i].reset(); 41 } 35 deque< CArray<int, 1>* >::iterator it ; 36 37 for(deque< CArray<int,1>* >::iterator it=storeIndex.begin(); it!=storeIndex.end();it++) delete *it ; 38 for(deque< CArray<int,1>* >::iterator it=out_i_index.begin();it!=out_i_index.end();it++) delete *it ; 39 for(deque< CArray<int,1>* >::iterator it=out_j_index.begin();it!=out_j_index.end();it++) delete *it ; 40 for(deque< CArray<int,1>* >::iterator it=out_l_index.begin();it!=out_l_index.end();it++) delete *it ; 41 42 for(map<int,CArray<int,1>* >::iterator it=out_i_fromClient.begin();it!=out_i_fromClient.end();it++) delete it->second ; 43 for(map<int,CArray<int,1>* >::iterator it=out_j_fromClient.begin();it!=out_j_fromClient.end();it++) delete it->second ; 44 for(map<int,CArray<int,1>* >::iterator it=out_l_fromClient.begin();it!=out_l_fromClient.end();it++) delete it->second ; 45 42 46 } 43 47 … … 50 54 //---------------------------------------------------------------- 51 55 52 const std::deque< ARRAY(int, 1)> & CGrid::getStoreIndex(void) const56 const std::deque< CArray<int,1>* > & CGrid::getStoreIndex(void) const 53 57 { 54 58 return (this->storeIndex ); … … 57 61 //--------------------------------------------------------------- 58 62 59 const std::deque< ARRAY(int, 1)> & CGrid::getOutIIndex(void) const63 const std::deque< CArray<int,1>* > & CGrid::getOutIIndex(void) const 60 64 { 61 65 return (this->out_i_index ); … … 64 68 //--------------------------------------------------------------- 65 69 66 const std::deque< ARRAY(int, 1)> & CGrid::getOutJIndex(void) const70 const std::deque< CArray<int,1>* > & CGrid::getOutJIndex(void) const 67 71 { 68 72 return (this->out_j_index ); … … 71 75 //--------------------------------------------------------------- 72 76 73 const std::deque< ARRAY(int, 1)> & CGrid::getOutLIndex(void) const77 const std::deque< CArray<int,1>* > & CGrid::getOutLIndex(void) const 74 78 { 75 79 return (this->out_l_index ); … … 155 159 StdSize CGrid::getDataSize(void) const 156 160 { 157 StdSize retvalue ; 158 retvalue=domain->data_ni.getValue() ; 161 StdSize retvalue=domain->data_ni.getValue() ; 159 162 if (domain->data_dim.getValue()==2) retvalue*=domain->data_nj.getValue() ; 160 163 if (this->withAxis) retvalue*=this->axis->size.getValue() ; … … 177 180 178 181 this->computeIndex() ; 179 ARRAY_CREATE(storeIndex_ , int, 1, [0]); 180 ARRAY_CREATE(out_l_index_, int, 1, [0]); 181 ARRAY_CREATE(out_i_index_, int, 1, [0]); 182 ARRAY_CREATE(out_j_index_, int, 1, [0]); 183 184 this->storeIndex .push_front(storeIndex_); 185 this->out_i_index.push_front(out_i_index_); 186 this->out_j_index.push_front(out_j_index_); 187 this->out_l_index.push_front(out_l_index_); 182 183 this->storeIndex.push_front(new CArray<int,1>() ); 184 this->out_i_index.push_front(new CArray<int,1>()); 185 this->out_j_index.push_front(new CArray<int,1>()); 186 this->out_l_index.push_front(new CArray<int,1>()); 188 187 } 189 188 // this->computeIndexServer(); … … 245 244 ? domain->data_jbegin.getValue() : -1; 246 245 247 ARRAY(int, 1) data_i_index = domain->data_i_index.getValue() , 248 data_j_index = domain->data_j_index.getValue() ; 249 250 251 ARRAY(bool, 2) mask = domain->mask.getValue() ; 252 ARRAY(int, 2) local_mask = this->domain->getLocalMask(); 246 CArray<int,1> data_i_index = domain->data_i_index ; 247 CArray<int,1> data_j_index = domain->data_j_index ; 248 249 250 CArray<bool,2>& mask = domain->mask ; 251 CArray<int,2>& local_mask = domain->local_mask ; 252 253 253 254 254 int indexCount = 0; … … 258 258 for(int n = 0, i = 0, j = 0; n < data_n_index; n++) 259 259 { 260 int temp_i = (*data_i_index)[n]+ data_ibegin,260 int temp_i = data_i_index(n) + data_ibegin, 261 261 temp_j = (data_dim == 1) ? -1 262 : (*data_j_index)[n]+ data_jbegin;262 : data_j_index(n) + data_jbegin; 263 263 i = (data_dim == 1) ? (temp_i - 1) % ni 264 264 : (temp_i - 1) ; … … 268 268 if ((l >=lbegin && l<= lend) && 269 269 (i >= 0 && i < ni) && 270 (j >= 0 && j < nj) && (*mask)[i][j])270 (j >= 0 && j < nj) && mask(i,j)) 271 271 indexCount++ ; 272 272 } 273 273 } 274 274 275 ARRAY_ASSIGN(this->storeIndex[0] , int, 1, [indexCount]);276 ARRAY_ASSIGN(this->out_l_index[0], int, 1, [indexCount]);277 ARRAY_ASSIGN(this->out_i_index[0], int, 1, [indexCount]);278 ARRAY_ASSIGN(this->out_j_index[0], int, 1, [indexCount]);279 280 ARRAY_ASSIGN(storeIndex_client,int,1,[indexCount]);281 ARRAY_ASSIGN(out_i_client,int,1,[indexCount]);282 ARRAY_ASSIGN(out_j_client,int,1,[indexCount]);283 ARRAY_ASSIGN(out_l_client,int,1,[indexCount]);275 storeIndex[0] = new CArray<int,1>(indexCount) ; 276 out_i_index[0] = new CArray<int,1>(indexCount) ; 277 out_j_index[0] = new CArray<int,1>(indexCount) ; 278 out_l_index[0] = new CArray<int,1>(indexCount) ; 279 280 storeIndex_client.resize(indexCount) ; 281 out_i_client.resize(indexCount) ; 282 out_j_client.resize(indexCount) ; 283 out_l_client.resize(indexCount) ; 284 284 285 285 … … 288 288 for(int n = 0, i = 0, j = 0; n < data_n_index; n++, count++) 289 289 { 290 int temp_i = (*data_i_index)[n]+ data_ibegin,290 int temp_i = data_i_index(n) + data_ibegin, 291 291 temp_j = (data_dim == 1) ? -1 292 : (*data_j_index)[n]+ data_jbegin;292 : data_j_index(n) + data_jbegin; 293 293 i = (data_dim == 1) ? (temp_i - 1) % ni 294 294 : (temp_i - 1) ; … … 298 298 if ((l >= lbegin && l <= lend) && 299 299 (i >= 0 && i < ni) && 300 (j >= 0 && j < nj) && (*mask)[i][j])300 (j >= 0 && j < nj) && mask(i,j)) 301 301 { 302 (* this->storeIndex[0]) [indexCount]= count ;303 (* this->out_l_index[0])[indexCount]= l ;304 (* this->out_i_index[0])[indexCount]= i ;305 (* this->out_j_index[0])[indexCount]= j ;302 (*storeIndex[0])(indexCount) = count ; 303 (*out_l_index[0])(indexCount) = l ; 304 (*out_i_index[0])(indexCount) = i ; 305 (*out_j_index[0])(indexCount) = j ; 306 306 307 (*storeIndex_client)[indexCount]= count ;308 (*out_i_client)[indexCount]=i+domain->ibegin_client-1 ;309 (*out_j_client)[indexCount]=j+domain->jbegin_client-1 ;310 (*out_l_client)[indexCount]=l-lbegin ;307 storeIndex_client(indexCount) = count ; 308 out_i_client(indexCount)=i+domain->ibegin_client-1 ; 309 out_j_client(indexCount)=j+domain->jbegin_client-1 ; 310 out_l_client(indexCount)=l-lbegin ; 311 311 indexCount++ ; 312 312 } … … 340 340 //---------------------------------------------------------------- 341 341 342 void CGrid::outputField(int rank, const ARRAY(double, 1) stored, ARRAY(double, 3)field)343 { 344 ARRAY(int,1) out_i=out_i_fromClient[rank] ;345 ARRAY(int,1) out_j=out_j_fromClient[rank] ;346 ARRAY(int,1) out_l=out_l_fromClient[rank] ;347 348 for(StdSize n = 0; n < stored ->num_elements(); n++)349 (*field)[(*out_i)[n]][(*out_j)[n]][(*out_l)[n]] = (*stored)[n];350 } 351 352 void CGrid::outputField(int rank, const ARRAY(double, 1) stored, ARRAY(double, 2)field)353 { 354 ARRAY(int,1) out_i=out_i_fromClient[rank] ;355 ARRAY(int,1) out_j=out_j_fromClient[rank] ;356 357 for(StdSize n = 0; n < stored->num_elements(); n++)358 (*field)[(*out_i)[n]][(*out_j)[n]] = (*stored)[n] ;359 } 360 361 //--------------------------------------------------------------- 362 363 void CGrid::outputField(int rank,const ARRAY(double, 1) stored, ARRAY(double, 1) field)364 {365 ARRAY(int,1) out_i = out_i_fromClient[rank] ;366 for(StdSize n = 0; n < stored ->num_elements(); n++)367 (*field)[(*out_i)[n]] = (*stored)[n];342 void CGrid::outputField(int rank, const CArray<double, 1>& stored, CArray<double, 3>& field) 343 { 344 CArray<int,1>& out_i=*out_i_fromClient[rank] ; 345 CArray<int,1>& out_j=*out_j_fromClient[rank] ; 346 CArray<int,1>& out_l=*out_l_fromClient[rank] ; 347 348 for(StdSize n = 0; n < stored.numElements(); n++) 349 field(out_i(n), out_j(n), out_l(n)) = stored(n) ; 350 } 351 352 void CGrid::outputField(int rank, const CArray<double, 1>& stored, CArray<double, 2>& field) 353 { 354 CArray<int,1>& out_i=*out_i_fromClient[rank] ; 355 CArray<int,1>& out_j=*out_j_fromClient[rank] ; 356 357 for(StdSize n = 0; n < stored.numElements(); n++) 358 field(out_i(n), out_j(n)) = stored(n) ; } 359 360 //--------------------------------------------------------------- 361 362 void CGrid::outputField(int rank,const CArray<double, 1>& stored, CArray<double, 1>& field) 363 { 364 CArray<int,1>& out_i=*out_i_fromClient[rank] ; 365 366 for(StdSize n = 0; n < stored.numElements(); n++) 367 field(out_i(n)) = stored(n) ; 368 368 } 369 369 … … 372 372 373 373 void CGrid::storeField_arr 374 (const double * const data, ARRAY(double, 1) stored) const 375 { 376 const StdSize size = (this->storeIndex_client)->num_elements() ; 377 378 stored->resize(boost::extents[size]) ; 379 for(StdSize i = 0; i < size; i++) 380 (*stored)[i] = data[(*storeIndex_client)[i]] ; 374 (const double * const data, CArray<double, 1>& stored) const 375 { 376 const StdSize size = storeIndex_client.numElements() ; 377 378 stored.resize(size) ; 379 for(StdSize i = 0; i < size; i++) stored(i) = data[storeIndex_client(i)] ; 381 380 } 382 381 383 382 //--------------------------------------------------------------- 384 385 void CGrid::toBinary (StdOStream & os) const 386 { 387 SuperClass::toBinary(os); 388 389 os.write (reinterpret_cast<const char*>(&this->isChecked), sizeof(bool)); 390 391 if (this->isChecked) 392 { 393 this->storeIndex [0]->toBinary(os); 394 this->out_i_index[0]->toBinary(os); 395 this->out_j_index[0]->toBinary(os); 396 this->out_l_index[0]->toBinary(os); 397 } 398 } 399 400 //--------------------------------------------------------------- 401 402 void CGrid::fromBinary(StdIStream & is) 403 { 404 bool hasIndex = false; 405 SuperClass::fromBinary(is); 406 is.read (reinterpret_cast<char*>(&hasIndex), sizeof(bool)); 407 408 if (hasIndex) 409 { 410 ARRAY_CREATE(storeIndex_ , int, 1, [0]); 411 ARRAY_CREATE(out_l_index_, int, 1, [0]); 412 ARRAY_CREATE(out_i_index_, int, 1, [0]); 413 ARRAY_CREATE(out_j_index_, int, 1, [0]); 414 415 storeIndex_ ->fromBinary(is); 416 out_i_index_->fromBinary(is); 417 out_j_index_->fromBinary(is); 418 out_l_index_->fromBinary(is); 419 420 this->storeIndex .push_back(storeIndex_); 421 this->out_i_index.push_back(out_i_index_); 422 this->out_j_index.push_back(out_j_index_); 423 this->out_l_index.push_back(out_l_index_); 424 } 425 } 426 427 //--------------------------------------------------------------- 383 428 384 void CGrid::sendIndex(void) 429 385 { … … 434 390 int rank ; 435 391 list<shared_ptr<CMessage> > list_msg ; 436 list< ARRAY(int,1)> list_out_i,list_out_j,list_out_l ;392 list< CArray<int,1>* > list_out_i,list_out_j,list_out_l ; 437 393 438 394 for(int ns=0;ns<domain->connectedServer.size();ns++) … … 446 402 int i,j ; 447 403 int nb=0 ; 448 for(int k=0;k<storeIndex_client ->num_elements();k++)404 for(int k=0;k<storeIndex_client.numElements();k++) 449 405 { 450 i= (*out_i_client)[k];451 j= (*out_j_client)[k];406 i=out_i_client(k) ; 407 j=out_j_client(k) ; 452 408 if (i>=ib-1 && i<=ie-1 && j>=jb-1 && j<=je-1) nb++ ; 453 409 } 454 410 455 ARRAY_CREATE(storeIndex,int,1,[nb]) ; 456 ARRAY_CREATE(out_i,int,1,[nb]) ; 457 ARRAY_CREATE(out_j,int,1,[nb]) ; 458 ARRAY_CREATE(out_l,int,1,[nb]) ; 411 CArray<int,1> storeIndex(nb) ; 412 CArray<int,1> out_i(nb) ; 413 CArray<int,1> out_j(nb) ; 414 CArray<int,1> out_l(nb) ; 415 459 416 460 417 nb=0 ; 461 for(int k=0;k<storeIndex_client ->num_elements();k++)418 for(int k=0;k<storeIndex_client.numElements();k++) 462 419 { 463 i= (*out_i_client)[k];464 j= (*out_j_client)[k];420 i=out_i_client(k) ; 421 j=out_j_client(k) ; 465 422 if (i>=ib-1 && i<=ie-1 && j>=jb-1 && j<=je-1) 466 423 { 467 (*storeIndex)[nb]=k ;468 (*out_i)[nb]=(*out_i_client)[k];469 (*out_j)[nb]=(*out_j_client)[k];470 (*out_l)[nb]=(*out_l_client)[k];424 storeIndex(nb)=k ; 425 out_i(nb)=out_i_client(k) ; 426 out_j(nb)=out_j_client(k) ; 427 out_l(nb)=out_l_client(k) ; 471 428 nb++ ; 472 429 } 473 430 } 474 431 475 storeIndex_toSrv.insert( pair<int,ARRAY(int,1) >(rank,storeIndex)) ;432 storeIndex_toSrv.insert( pair<int,CArray<int,1>* >(rank,new CArray<int,1>(storeIndex) )) ; 476 433 nbSenders.insert(pair<int,int>(rank,domain->nbSenders[ns])) ; 477 434 list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ; 478 list_out_i.push_back( out_i) ;479 list_out_j.push_back( out_j) ;480 list_out_l.push_back( out_l) ;481 482 *list_msg.back()<<getId()<< list_out_i.back()<<list_out_j.back()<<list_out_l.back() ;435 list_out_i.push_back(new CArray<int,1>(out_i)) ; 436 list_out_j.push_back(new CArray<int,1>(out_j)) ; 437 list_out_l.push_back(new CArray<int,1>(out_l)) ; 438 439 *list_msg.back()<<getId()<<*list_out_i.back()<<*list_out_j.back()<<*list_out_l.back() ; 483 440 event.push(rank,domain->nbSenders[ns],*list_msg.back()) ; 484 441 } 485 442 client->sendEvent(event) ; 443 444 for(list<CArray<int,1>* >::iterator it=list_out_i.begin();it!=list_out_i.end();it++) delete *it ; 445 for(list<CArray<int,1>* >::iterator it=list_out_j.begin();it!=list_out_j.end();it++) delete *it ; 446 for(list<CArray<int,1>* >::iterator it=list_out_l.begin();it!=list_out_l.end();it++) delete *it ; 447 486 448 } 487 449 … … 501 463 void CGrid::recvIndex(int rank, CBufferIn& buffer) 502 464 { 503 ARRAY_CREATE(out_i,int,1,[0]);504 ARRAY_CREATE(out_j,int,1,[0]);505 ARRAY_CREATE(out_l,int,1,[0]);465 CArray<int,1> out_i ; 466 CArray<int,1> out_j ; 467 CArray<int,1> out_l ; 506 468 507 469 buffer>>out_i>>out_j>>out_l ; 508 int offset ;509 470 510 o ffset=domain->zoom_ibegin_srv-1 ;511 for(int k=0;k<out_i->num_elements();k++) (*out_i)[k]=(*out_i)[k]-offset;471 out_i -= domain->zoom_ibegin_srv-1 ; 472 out_j -= domain->zoom_jbegin_srv-1 ; 512 473 513 offset=domain->zoom_jbegin_srv-1 ; 514 for(int k=0;k<out_i->num_elements();k++) (*out_j)[k]=(*out_j)[k]-offset ; 515 516 out_i_fromClient.insert(pair< int,ARRAY(int,1) >(rank,out_i)) ; 517 out_j_fromClient.insert(pair< int,ARRAY(int,1) >(rank,out_j)) ; 518 out_l_fromClient.insert(pair< int,ARRAY(int,1) >(rank,out_l)) ; 474 out_i_fromClient.insert(pair< int,CArray<int,1>* >(rank,new CArray<int,1>(out_i) )) ; 475 out_j_fromClient.insert(pair< int,CArray<int,1>* >(rank,new CArray<int,1>(out_j) )) ; 476 out_l_fromClient.insert(pair< int,CArray<int,1>* >(rank,new CArray<int,1>(out_l) )) ; 519 477 } 520 478 … … 540 498 } 541 499 542 543 /* 544 void CGrid::computeIndexServer(void) 545 { 546 ARRAY(int, 2) local_mask = this->domain->getLocalMask(); 547 548 const std::vector<int> & ibegin = this->domain->getIBeginSub(); 549 const std::vector<int> & jbegin = this->domain->getJBeginSub(); 550 const std::vector<int> & iend = this->domain->getIEndSub(); 551 const std::vector<int> & jend = this->domain->getJEndSub(); 552 const std::vector<int> & ibegin_zoom = this->domain->getIBeginZoomSub(); 553 const std::vector<int> & jbegin_zoom = this->domain->getJBeginZoomSub(); 554 const std::vector<int> & ni_zoom = this->domain->getNiZoomSub(); 555 const std::vector<int> & nj_zoom = this->domain->getNjZoomSub(); 556 557 const int ibegin_srv = this->domain->ibegin.getValue(); 558 const int jbegin_srv = this->domain->jbegin.getValue(); 559 const int iend_srv = this->domain->iend.getValue(); 560 const int jend_srv = this->domain->jend.getValue(); 561 const int zoom_ni_srv = this->domain->zoom_ni_loc.getValue(); 562 const int zoom_nj_srv = this->domain->zoom_nj_loc.getValue(); 563 564 const int ibegin_zoom_srv = this->domain->zoom_ibegin_loc.getValue(); 565 const int jbegin_zoom_srv = this->domain->zoom_jbegin_loc.getValue(); 566 const int iend_zoom_srv = ibegin_zoom_srv + zoom_ni_srv-1 ; 567 const int jend_zoom_srv = jbegin_zoom_srv + zoom_nj_srv-1 ; 568 569 StdSize dn = 0; 570 for (StdSize j = 1; j < this->out_i_index.size(); j++) 571 dn += this->out_i_index[j]->size(); 572 573 ARRAY_CREATE(storeIndex_srv , int, 1, [dn]); 574 ARRAY_CREATE(out_i_index_srv, int, 1, [dn]); 575 ARRAY_CREATE(out_j_index_srv, int, 1, [dn]); 576 ARRAY_CREATE(out_l_index_srv, int, 1, [dn]); 577 578 for (StdSize i = 0, dn = 0; i < ibegin.size(); i++) 579 { 580 ARRAY(int, 1) storeIndex_cl = this->storeIndex [i + 1]; 581 ARRAY(int, 1) out_i_index_cl = this->out_i_index[i + 1]; 582 ARRAY(int, 1) out_j_index_cl = this->out_j_index[i + 1]; 583 ARRAY(int, 1) out_l_index_cl = this->out_l_index[i + 1]; 584 585 int ibegin_zoom_cl = ibegin[i]; //ibegin_zoom[i]; 586 int jbegin_zoom_cl = jbegin[i]; //jbegin_zoom[i]; 587 int iend_zoom_cl = iend[i]; //ibegin_zoom[i]; 588 int jend_zoom_cl = jend[i]; //jbegin_zoom[i]; 589 590 int ibegin_cl = ibegin[i]; //ibegin[i]; 591 int jbegin_cl = jbegin[i]; //jbegin[i]; 592 int iend_cl = iend[i]; //ibegin[i]; 593 int jend_cl = jend[i]; //jbegin[i]; 594 595 if (ibegin_zoom.size() != 0) 596 { 597 ibegin_zoom_cl = ibegin_zoom[i]; 598 jbegin_zoom_cl = jbegin_zoom[i]; 599 iend_zoom_cl = ibegin_zoom[i]+ni_zoom[i]-1; 600 jend_zoom_cl = jbegin_zoom[i]+nj_zoom[i]-1; 601 } 602 603 604 if (comm::CMPIManager::IsClient()) 605 { 606 for (StdSize n = dn, m = 0; n < (dn + storeIndex_cl->size()); n++, m++) 607 { 608 (*storeIndex_srv)[n] = (*storeIndex_cl)[m]; // Faux mais inutile dans le cas serveur. 609 610 (*out_i_index_srv)[n] = (*out_i_index_cl)[m] + ibegin_cl - 1 - (ibegin_srv + ibegin_zoom_srv - 1) + 1 ; 611 (*out_j_index_srv)[n] = (*out_j_index_cl)[m] + jbegin_cl - 1 - (jbegin_srv + jbegin_zoom_srv - 1) + 1 ; 612 (*out_l_index_srv)[n] = (*out_l_index_cl)[m]; 613 } 614 } 615 else 616 { 617 for (StdSize n = dn, m = 0; n < (dn + storeIndex_cl->size()); n++, m++) 618 { 619 (*storeIndex_srv)[n] = (*storeIndex_cl)[m]; // Faux mais inutile dans le cas serveur. 620 (*out_i_index_srv)[n] = (*out_i_index_cl)[m] 621 + (ibegin_cl - 1) - (ibegin_srv - 1) + (ibegin_zoom_cl - 1) - (ibegin_zoom_srv - 1); 622 (*out_j_index_srv)[n] = (*out_j_index_cl)[m] 623 + (jbegin_cl - 1) - (jbegin_srv - 1) + (jbegin_zoom_cl - 1) - (jbegin_zoom_srv - 1); 624 (*out_l_index_srv)[n] = (*out_l_index_cl)[m]; 625 } 626 627 } 628 629 dn += storeIndex_cl->size(); 630 } 631 632 if (storeIndex_srv->size() != 0) 633 { 634 const int ibegin_t = 635 *std::min_element(out_i_index_srv->begin(), out_i_index_srv->end()); 636 const int iend_t = 637 *std::max_element(out_i_index_srv->begin(), out_i_index_srv->end()); 638 const int jbegin_t = 639 *std::min_element(out_j_index_srv->begin(), out_j_index_srv->end()); 640 const int jend_t = 641 *std::max_element(out_j_index_srv->begin(), out_j_index_srv->end()); 642 643 644 if ((ibegin_t < 0) || (jbegin_t < 0) || 645 (iend_t >= zoom_ni_srv) || (jend_t >= zoom_nj_srv)) 646 { 647 ERROR("CGrid::computeIndexServer(void)", 648 << "[ grille = " << this->getId() 649 << ", ibegin_t = " << ibegin_t 650 << ", jbegin_t = " << jbegin_t 651 << ", iend_t = " << iend_t 652 << ", jend_t = " << jend_t 653 << ", zoom_ni_srv = " << zoom_ni_srv 654 << ", zoom_nj_srv = " << zoom_nj_srv 655 << ", nb subdomain = " << out_i_index.size()-1 656 <<" ] Erreur d'indexation de la grille au niveau du serveur") ; 657 } 658 } 659 660 if (storeIndex_srv->size() != 0) 661 for (StdSize u = 0; u < storeIndex_srv->size(); u++) 662 (*local_mask)[(*out_i_index_srv)[u]][(*out_j_index_srv)[u]] = 1; 663 664 // StdOFStream ofs(("log_server_"+this->getId()).c_str()); 665 // for (StdSize h = 0; h < storeIndex_srv->size(); h++) 666 // { 667 // ofs << "(" << (*storeIndex_srv)[h] << ";" 668 // << (*out_i_index_srv)[h] << "," 669 // << (*out_j_index_srv)[h] << "," 670 // << (*out_l_index_srv)[h] << ")" << std::endl; 671 // } 672 // ofs.close(); 673 674 this->storeIndex [0] = storeIndex_srv ; 675 this->out_i_index[0] = out_i_index_srv; 676 this->out_j_index[0] = out_j_index_srv; 677 this->out_l_index[0] = out_l_index_srv; 678 } 679 */ 680 681 void CGrid::inputFieldServer 682 (const std::deque<ARRAY(double, 1)> storedClient, 683 ARRAY(double, 1) storedServer) const 500 void CGrid::inputFieldServer(const std::deque< CArray<double, 1>* > storedClient, CArray<double, 1>& storedServer) const 684 501 { 685 502 if ((this->storeIndex.size()-1 ) != storedClient.size()) 686 ERROR(" CGrid::inputFieldServer(...)",503 ERROR("void CGrid::inputFieldServer(const std::deque< CArray<double, 1>* > storedClient, CArray<double, 1>& storedServer) const", 687 504 << "[ Nombre de tableau attendu = " << (this->storeIndex.size()-1) << ", " 688 505 << "[ Nombre de tableau reçu = " << storedClient.size() << "] " 689 506 << "Les données d'un client sont manquantes !") ; 690 if (storedServer.get() != NULL) 691 storedServer->resize(boost::extents[this->storeIndex[0]->num_elements()]); 692 else 693 ARRAY_ASSIGN(storedServer, double, 1, [this->storeIndex[0]->num_elements()]); 507 storedServer.resize(storeIndex[0]->numElements()); 694 508 695 509 for (StdSize i = 0, n = 0; i < storedClient.size(); i++) 696 for (StdSize j = 0; j < storedClient[i]->num _elements(); j++)697 (*storedServer)[n++] = (*storedClient[i])[j];698 } 699 700 void CGrid::outputFieldToServer( ARRAY(double, 1) fieldIn, int rank, ARRAY(double, 1)fieldOut)701 { 702 ARRAY(int,1) index=storeIndex_toSrv[rank] ;703 int nb=index ->num_elements() ;704 fieldOut ->resize(extents[nb]) ;510 for (StdSize j = 0; j < storedClient[i]->numElements(); j++) 511 storedServer(n++) = (*storedClient[i])(j); 512 } 513 514 void CGrid::outputFieldToServer(CArray<double,1>& fieldIn, int rank, CArray<double,1>& fieldOut) 515 { 516 CArray<int,1>& index = *storeIndex_toSrv[rank] ; 517 int nb=index.numElements() ; 518 fieldOut.resize(nb) ; 705 519 706 for(int k=0;k<nb;k++) (*fieldOut)[k]=(*fieldIn)[(*index)[k]];520 for(int k=0;k<nb;k++) fieldOut(k)=fieldIn(index(k)) ; 707 521 } 708 522 ///---------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.