Changeset 300 for XMLIO_V2/dev/common/src/node/grid.cpp
- Timestamp:
- 02/13/12 19:35:25 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/common/src/node/grid.cpp
r286 r300 160 160 { 161 161 if (this->isChecked) return; 162 shared_ptr<CContext> context=CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()) ; 163 CContextClient* client=context->client ; 164 162 165 this->solveDomainRef() ; 163 166 this->solveAxisRef() ; 164 if ( this->storeIndex.size() == 1)167 if (context->hasClient) 165 168 { 166 169 … … 176 179 this->out_l_index.push_front(out_l_index_); 177 180 } 178 this->computeIndexServer();181 // this->computeIndexServer(); 179 182 this->isChecked = true; 180 183 } … … 225 228 size = (this->hasAxis()) ? axis->size.getValue() : 1 ; 226 229 227 /*std::cout << ni << " : "228 << nj << " : "229 << size << std::endl;*/230 230 231 231 const int data_dim = domain->data_dim.getValue() , … … 238 238 data_j_index = domain->data_j_index.getValue() ; 239 239 240 /*std::cout << data_n_index << " : "241 << data_i_index << " : "242 << data_j_index << std::endl; */243 240 244 241 ARRAY(bool, 2) mask = domain->mask.getValue() ; … … 265 262 } 266 263 267 //std::cout << indexCount << std::endl;268 264 ARRAY_ASSIGN(this->storeIndex[0] , int, 1, [indexCount]); 269 265 ARRAY_ASSIGN(this->out_l_index[0], int, 1, [indexCount]); … … 271 267 ARRAY_ASSIGN(this->out_j_index[0], int, 1, [indexCount]); 272 268 273 // for(int count = 0, indexCount = 0, l = 0; l < size; l++)274 // for(int n = 0, i = 0, j = 0; n < data_n_index; n++, count++)275 276 //for(int n = 0, i = 0, j = 0, count = 0, indexCount = 0; n < data_n_index; n++)277 //for(int l = 0; l < size; l++, count++)269 ARRAY_ASSIGN(storeIndex_client,int,1,[indexCount]); 270 ARRAY_ASSIGN(out_i_client,int,1,[indexCount]); 271 ARRAY_ASSIGN(out_j_client,int,1,[indexCount]); 272 ARRAY_ASSIGN(out_l_client,int,1,[indexCount]); 273 278 274 279 275 for(int count = 0, indexCount = 0, l = 0; l < size; l++) … … 296 292 (*this->out_i_index[0])[indexCount] = i ; 297 293 (*this->out_j_index[0])[indexCount] = j ; 294 295 (*storeIndex_client)[indexCount] = count ; 296 (*out_i_client)[indexCount]=i+domain->ibegin_client-1 ; 297 (*out_j_client)[indexCount]=j+domain->jbegin_client-1 ; 298 (*out_l_client)[indexCount]=l ; 298 299 indexCount++ ; 299 300 } 300 301 } 301 302 } 302 303 304 // if (this->storeIndex[0]->size() != 0) 305 // for (StdSize u = 0; u < this->storeIndex[0]->size(); u++) 306 // (*local_mask)[(*out_i_index[0])[u]][(*out_j_index[0])[u]] = 1; 307 308 // std::cout << "indexCount" << indexCount << std::endl; 309 // std::cout << this->getId() << " : " << (*this->storeIndex[0]).num_elements() << std::endl; 310 // StdOFStream ofs2(("log_client_"+this->getId()).c_str()); 311 // for (StdSize h = 0; h < storeIndex[0]->size(); h++) 312 // { 313 // ofs2 << "(" << (*storeIndex[0])[h] << ";" 314 // << (*out_i_index[0])[h] << "," 315 // << (*out_j_index[0])[h] << "," 316 // << (*out_l_index[0])[h] << ")" << std::endl; 317 // } 318 // ofs2.close(); 303 sendIndex() ; 304 305 319 306 } 320 307 … … 345 332 //---------------------------------------------------------------- 346 333 347 template <> 348 void CGrid::outputField 349 (const ARRAY(double, 1) stored, ARRAY(double, 3) field) const 350 { 351 //std::cout <<"champ : " ; 352 for(StdSize n = 0; n < storeIndex[0]->num_elements(); n++) 353 { 354 (*field)[(*out_i_index[0])[n]][(*out_j_index[0])[n]][(*out_l_index[0])[n]] = (*stored)[n] ; 355 /*if (storeIndex[0]->num_elements() == 31) 356 { 357 std::cout << "( " << (*field)[(*out_i_index[0])[n]][(*out_j_index[0])[n]][(*out_l_index[0])[n]] << ", " 358 << (*out_i_index[0])[n] << ", " 359 << (*out_j_index[0])[n] << ", " 360 << (*out_l_index[0])[n] << ")"; 361 }*/ 362 } 363 //std::cout << std::endl; 364 365 } 366 367 //--------------------------------------------------------------- 368 369 template <> 370 void CGrid::outputField 371 (const ARRAY(double, 1) stored, ARRAY(double, 2) field) const 372 { 373 for(StdSize n = 0; n < storeIndex[0]->num_elements(); n++) 374 (*field)[(*out_i_index[0])[n]][(*out_j_index[0])[n]] = (*stored)[n] ; 375 } 376 377 //--------------------------------------------------------------- 378 379 template <> 380 void CGrid::outputField 381 (const ARRAY(double, 1) stored, ARRAY(double, 1) field) const 382 { 383 for(StdSize n = 0; n < storeIndex[0]->num_elements(); n++) 384 (*field)[(*out_i_index[0])[n]] = (*stored)[n] ; 334 void CGrid::outputField(int rank, const ARRAY(double, 1) stored, ARRAY(double, 3) field) 335 { 336 ARRAY(int,1) out_i=out_i_fromClient[rank] ; 337 ARRAY(int,1) out_j=out_j_fromClient[rank] ; 338 ARRAY(int,1) out_l=out_l_fromClient[rank] ; 339 340 for(StdSize n = 0; n < stored->num_elements(); n++) 341 (*field)[(*out_i)[n]][(*out_j)[n]][(*out_l)[n]] = (*stored)[n] ; 342 } 343 344 void CGrid::outputField(int rank, const ARRAY(double, 1) stored, ARRAY(double, 2) field) 345 { 346 ARRAY(int,1) out_i=out_i_fromClient[rank] ; 347 ARRAY(int,1) out_j=out_j_fromClient[rank] ; 348 349 for(StdSize n = 0; n < stored->num_elements(); n++) 350 (*field)[(*out_i)[n]][(*out_j)[n]] = (*stored)[n] ; 351 } 352 353 //--------------------------------------------------------------- 354 355 void CGrid::outputField(int rank,const ARRAY(double, 1) stored, ARRAY(double, 1) field) 356 { 357 ARRAY(int,1) out_i = out_i_fromClient[rank] ; 358 for(StdSize n = 0; n < stored->num_elements(); n++) 359 (*field)[(*out_i)[n]] = (*stored)[n] ; 385 360 } 386 361 387 362 //---------------------------------------------------------------- 363 388 364 389 365 void CGrid::storeField_arr 390 366 (const double * const data, ARRAY(double, 1) stored) const 391 367 { 392 const StdSize size = (this->storeIndex [0])->num_elements() ;393 // std::cout << this->getId() << "> size : " << size << std::endl; 368 const StdSize size = (this->storeIndex_client)->num_elements() ; 369 394 370 stored->resize(boost::extents[size]) ; 395 371 for(StdSize i = 0; i < size; i++) 396 (*stored)[i] = data[(*storeIndex [0])[i]] ;372 (*stored)[i] = data[(*storeIndex_client)[i]] ; 397 373 } 398 374 … … 442 418 443 419 //--------------------------------------------------------------- 444 420 void CGrid::sendIndex(void) 421 { 422 shared_ptr<CContext> context=CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()) ; 423 CContextClient* client=context->client ; 424 425 CEventClient event(getType(),EVENT_ID_INDEX) ; 426 int rank ; 427 list<shared_ptr<CMessage> > list_msg ; 428 list<ARRAY(int,1) > list_out_i,list_out_j,list_out_l ; 429 430 for(int ns=0;ns<domain->connectedServer.size();ns++) 431 { 432 rank=domain->connectedServer[ns] ; 433 int ib=domain->ib_srv[ns] ; 434 int ie=domain->ie_srv[ns] ; 435 int jb=domain->jb_srv[ns] ; 436 int je=domain->je_srv[ns] ; 437 438 int i,j ; 439 int nb=0 ; 440 for(int k=0;k<storeIndex_client->num_elements();k++) 441 { 442 i=(*out_i_client)[k] ; 443 j=(*out_j_client)[k] ; 444 if (i>=ib-1 && i<=ie-1 && j>=jb-1 && j<=je-1) nb++ ; 445 } 446 447 ARRAY_CREATE(storeIndex,int,1,[nb]) ; 448 ARRAY_CREATE(out_i,int,1,[nb]) ; 449 ARRAY_CREATE(out_j,int,1,[nb]) ; 450 ARRAY_CREATE(out_l,int,1,[nb]) ; 451 452 nb=0 ; 453 for(int k=0;k<storeIndex_client->num_elements();k++) 454 { 455 i=(*out_i_client)[k] ; 456 j=(*out_j_client)[k] ; 457 if (i>=ib-1 && i<=ie-1 && j>=jb-1 && j<=je-1) 458 { 459 (*storeIndex)[nb]=k ; 460 (*out_i)[nb]=(*out_i_client)[k] ; 461 (*out_j)[nb]=(*out_j_client)[k] ; 462 (*out_l)[nb]=(*out_l_client)[k] ; 463 nb++ ; 464 } 465 } 466 467 storeIndex_toSrv.insert(pair<int,ARRAY(int,1) >(rank,storeIndex)) ; 468 nbSenders.insert(pair<int,int>(rank,domain->nbSenders[ns])) ; 469 list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ; 470 list_out_i.push_back(out_i) ; 471 list_out_j.push_back(out_j) ; 472 list_out_l.push_back(out_l) ; 473 474 *list_msg.back()<<getId()<<list_out_i.back()<<list_out_j.back()<<list_out_l.back() ; 475 event.push(rank,domain->nbSenders[ns],*list_msg.back()) ; 476 } 477 client->sendEvent(event) ; 478 } 479 480 void CGrid::recvIndex(CEventServer& event) 481 { 482 list<CEventServer::SSubEvent>::iterator it ; 483 for (it=event.subEvents.begin();it!=event.subEvents.end();++it) 484 { 485 int rank=it->rank; 486 CBufferIn* buffer=it->buffer; 487 string domainId ; 488 *buffer>>domainId ; 489 get(domainId)->recvIndex(rank,*buffer) ; 490 } 491 } 492 493 void CGrid::recvIndex(int rank, CBufferIn& buffer) 494 { 495 ARRAY_CREATE(out_i,int,1,[0]) ; 496 ARRAY_CREATE(out_j,int,1,[0]) ; 497 ARRAY_CREATE(out_l,int,1,[0]) ; 498 499 buffer>>out_i>>out_j>>out_l ; 500 int offset ; 501 502 offset=domain->zoom_ibegin_srv-1 ; 503 for(int k=0;k<out_i->num_elements();k++) (*out_i)[k]=(*out_i)[k]-offset ; 504 505 offset=domain->zoom_jbegin_srv-1 ; 506 for(int k=0;k<out_i->num_elements();k++) (*out_j)[k]=(*out_j)[k]-offset ; 507 508 out_i_fromClient.insert(pair< int,ARRAY(int,1) >(rank,out_i)) ; 509 out_j_fromClient.insert(pair< int,ARRAY(int,1) >(rank,out_j)) ; 510 out_l_fromClient.insert(pair< int,ARRAY(int,1) >(rank,out_l)) ; 511 } 512 513 bool CGrid::dispatchEvent(CEventServer& event) 514 { 515 516 if (SuperClass::dispatchEvent(event)) return true ; 517 else 518 { 519 switch(event.type) 520 { 521 case EVENT_ID_INDEX : 522 recvIndex(event) ; 523 return true ; 524 break ; 525 526 default : 527 ERROR("bool CDomain::dispatchEvent(CEventServer& event)", 528 <<"Unknown Event") ; 529 return false ; 530 } 531 } 532 } 533 534 535 445 536 void CGrid::computeIndexServer(void) 446 537 { … … 468 559 const int jend_zoom_srv = jbegin_zoom_srv + zoom_nj_srv-1 ; 469 560 470 // std::cout<<"----> computeIndexServer !!"<<std::endl ;471 561 StdSize dn = 0; 472 562 for (StdSize j = 1; j < this->out_i_index.size(); j++) … … 503 593 } 504 594 505 // std::cout<<"--> client No "<<i<<std::endl ;506 // std::cout<<" ibegin "<<ibegin[i]<<" iend "<<iend[i]<<" jbegin "<<jbegin[i]<<" jend "<<jend[i]<<std::endl ;507 // std::cout<<"zoom cl : ibegin "<<ibegin_zoom_cl<<" iend "<<iend_zoom_cl<<" jbegin "<<jbegin_zoom_cl<<" jend "<<jend_zoom_cl<<std::endl ;508 // std::cout<<"--> server "<<std::endl ;509 // std::cout<<" ibegin "<<ibegin_srv<<" iend "<<iend_srv<<" jbegin "<<jbegin_srv<<" jend "<<jend_srv<<std::endl ;510 // std::cout<<"zoom : ibegin "<<ibegin_zoom_srv<<" iend "<<iend_zoom_srv<< " ni "<<zoom_ni_srv<<" jbegin "<<jbegin_zoom_srv<<" jend "<<jend_zoom_srv<<" nj "<<zoom_nj_srv<<std::endl ;511 // std::cout<<"zoom_size "<<ibegin_zoom.size()<<std::endl ;512 595 513 596 if (comm::CMPIManager::IsClient()) … … 517 600 (*storeIndex_srv)[n] = (*storeIndex_cl)[m]; // Faux mais inutile dans le cas serveur. 518 601 519 // (*out_i_index_srv)[n] = (*out_i_index_cl)[m]520 // /*+ (ibegin_cl - 1) - (ibegin_srv - 1)*/ + (ibegin_zoom_cl - 1) - (ibegin_zoom_srv - 1);521 // (*out_j_index_srv)[n] = (*out_j_index_cl)[m]522 // /*+ (jbegin_cl - 1) - (jbegin_srv - 1)*/ + (jbegin_zoom_cl - 1) - (jbegin_zoom_srv - 1);523 // (*out_l_index_srv)[n] = (*out_l_index_cl)[m];524 602 (*out_i_index_srv)[n] = (*out_i_index_cl)[m] + ibegin_cl - 1 - (ibegin_srv + ibegin_zoom_srv - 1) + 1 ; 525 603 (*out_j_index_srv)[n] = (*out_j_index_cl)[m] + jbegin_cl - 1 - (jbegin_srv + jbegin_zoom_srv - 1) + 1 ; … … 542 620 543 621 dn += storeIndex_cl->size(); 544 // std::cout<<"storeIndex_cl->size() "<<storeIndex_cl->size()<<std::endl;545 546 // std::cout<<"storeIndex_srv->size() "<<storeIndex_srv->size()<<std::endl;547 622 } 548 623 … … 558 633 *std::max_element(out_j_index_srv->begin(), out_j_index_srv->end()); 559 634 560 // std::cout<< "[ grille = " << this->getId()561 // << ", ibegin_t = " << ibegin_t562 // << ", jbegin_t = " << jbegin_t563 // << ", iend_t = " << iend_t564 // << ", jend_t = " << jend_t565 // << ", zoom_ni_srv = " << zoom_ni_srv566 // << ", zoom_nj_srv = " << zoom_nj_srv567 // << ", nb subdomain = " << out_i_index.size()-1<<std::endl ;568 635 569 636 if ((ibegin_t < 0) || (jbegin_t < 0) || … … 623 690 } 624 691 692 void CGrid::outputFieldToServer(ARRAY(double, 1) fieldIn, int rank, ARRAY(double, 1) fieldOut) 693 { 694 ARRAY(int,1) index=storeIndex_toSrv[rank] ; 695 int nb=index->num_elements() ; 696 fieldOut->resize(extents[nb]) ; 697 698 for(int k=0;k<nb;k++) (*fieldOut)[k]=(*fieldIn)[(*index)[k]] ; 699 } 625 700 ///--------------------------------------------------------------- 626 701
Note: See TracChangeset
for help on using the changeset viewer.