Changeset 265 for XMLIO_V2/dev/dev_rv/src/xmlio/node/grid.cpp
- Timestamp:
- 09/06/11 11:57:45 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/xmlio/node/grid.cpp
r205 r265 1 1 2 #include "grid.hpp" 2 3 … … 100 101 //--------------------------------------------------------------- 101 102 102 std::vector<StdSize> CGrid::get Shape(void) const103 std::vector<StdSize> CGrid::getLocalShape(void) const 103 104 { 104 105 std::vector<StdSize> retvalue; 105 retvalue.push_back( this->domain->ni.getValue());106 retvalue.push_back( this->domain->nj.getValue());106 retvalue.push_back(domain->zoom_ni_loc.getValue()); 107 retvalue.push_back(domain->zoom_nj_loc.getValue()); 107 108 if (this->withAxis) 108 109 retvalue.push_back(this->axis->size.getValue()); … … 111 112 //--------------------------------------------------------------- 112 113 113 StdSize CGrid::get Size(void) const114 StdSize CGrid::getLocalSize(void) const 114 115 { 115 116 StdSize retvalue = 1; 116 std::vector<StdSize> shape_ = this->getShape(); 117 std::vector<StdSize> shape_ = this->getLocalShape(); 118 for (StdSize s = 0; s < shape_.size(); s++) 119 retvalue *= shape_[s]; 120 return (retvalue); 121 } 122 123 //--------------------------------------------------------------- 124 125 std::vector<StdSize> CGrid::getGlobalShape(void) const 126 { 127 std::vector<StdSize> retvalue; 128 retvalue.push_back(domain->ni.getValue()); 129 retvalue.push_back(domain->nj.getValue()); 130 if (this->withAxis) 131 retvalue.push_back(this->axis->size.getValue()); 132 return (retvalue); 133 } 134 //--------------------------------------------------------------- 135 136 StdSize CGrid::getGlobalSize(void) const 137 { 138 StdSize retvalue = 1; 139 std::vector<StdSize> shape_ = this->getGlobalShape(); 117 140 for (StdSize s = 0; s < shape_.size(); s++) 118 141 retvalue *= shape_[s]; … … 129 152 if (this->storeIndex.size() == 1) 130 153 { 154 131 155 this->computeIndex() ; 132 } 133 else 134 { 135 this->computeIndexServer(); 136 } 156 ARRAY_CREATE(storeIndex_ , int, 1, [0]); 157 ARRAY_CREATE(out_l_index_, int, 1, [0]); 158 ARRAY_CREATE(out_i_index_, int, 1, [0]); 159 ARRAY_CREATE(out_j_index_, int, 1, [0]); 160 161 this->storeIndex .push_front(storeIndex_); 162 this->out_i_index.push_front(out_i_index_); 163 this->out_j_index.push_front(out_j_index_); 164 this->out_l_index.push_front(out_l_index_); 165 } 166 this->computeIndexServer(); 137 167 this->isChecked = true; 138 168 } … … 177 207 178 208 void CGrid::computeIndex(void) 179 { 209 { 210 180 211 const int ni = domain->ni.getValue() , 181 212 nj = domain->nj.getValue() , … … 200 231 201 232 ARRAY(bool, 2) mask = domain->mask.getValue() ; 233 ARRAY(int, 2) local_mask = this->domain->getLocalMask(); 202 234 203 235 int indexCount = 0; … … 210 242 temp_j = (data_dim == 1) ? -1 211 243 : (*data_j_index)[n] + data_jbegin; 212 i = (data_dim == 1) ? (temp_i - 2) % ni244 i = (data_dim == 1) ? (temp_i - 1) % ni 213 245 : (temp_i - 1) ; 214 j = (data_dim == 1) ? (temp_i - 2) / ni246 j = (data_dim == 1) ? (temp_i - 1) / ni 215 247 : (temp_j - 1) ; 216 248 … … 226 258 ARRAY_ASSIGN(this->out_i_index[0], int, 1, [indexCount]); 227 259 ARRAY_ASSIGN(this->out_j_index[0], int, 1, [indexCount]); 228 260 261 // for(int count = 0, indexCount = 0, l = 0; l < size; l++) 262 // for(int n = 0, i = 0, j = 0; n < data_n_index; n++, count++) 263 264 //for(int n = 0, i = 0, j = 0, count = 0, indexCount = 0; n < data_n_index; n++) 265 //for(int l = 0; l < size; l++, count++) 266 229 267 for(int count = 0, indexCount = 0, l = 0; l < size; l++) 230 268 { … … 234 272 temp_j = (data_dim == 1) ? -1 235 273 : (*data_j_index)[n] + data_jbegin; 236 i = (data_dim == 1) ? (temp_i - 2) % ni274 i = (data_dim == 1) ? (temp_i - 1) % ni 237 275 : (temp_i - 1) ; 238 j = (data_dim == 1) ? (temp_i - 2) / ni276 j = (data_dim == 1) ? (temp_i - 1) / ni 239 277 : (temp_j - 1) ; 240 278 … … 250 288 } 251 289 } 290 291 292 // if (this->storeIndex[0]->size() != 0) 293 // for (StdSize u = 0; u < this->storeIndex[0]->size(); u++) 294 // (*local_mask)[(*out_i_index[0])[u]][(*out_j_index[0])[u]] = 1; 295 296 // std::cout << "indexCount" << indexCount << std::endl; 297 // std::cout << this->getId() << " : " << (*this->storeIndex[0]).num_elements() << std::endl; 298 // StdOFStream ofs2(("log_client_"+this->getId()).c_str()); 299 // for (StdSize h = 0; h < storeIndex[0]->size(); h++) 300 // { 301 // ofs2 << "(" << (*storeIndex[0])[h] << ";" 302 // << (*out_i_index[0])[h] << "," 303 // << (*out_j_index[0])[h] << "," 304 // << (*out_l_index[0])[h] << ")" << std::endl; 305 // } 306 // ofs2.close(); 252 307 } 253 308 … … 282 337 (const ARRAY(double, 1) stored, ARRAY(double, 3) field) const 283 338 { 339 //std::cout <<"champ : " ; 284 340 for(StdSize n = 0; n < storeIndex[0]->num_elements(); n++) 341 { 285 342 (*field)[(*out_i_index[0])[n]][(*out_j_index[0])[n]][(*out_l_index[0])[n]] = (*stored)[n] ; 343 /*if (storeIndex[0]->num_elements() == 31) 344 { 345 std::cout << "( " << (*field)[(*out_i_index[0])[n]][(*out_j_index[0])[n]][(*out_l_index[0])[n]] << ", " 346 << (*out_i_index[0])[n] << ", " 347 << (*out_j_index[0])[n] << ", " 348 << (*out_l_index[0])[n] << ")"; 349 }*/ 350 } 351 //std::cout << std::endl; 352 286 353 } 287 354 … … 311 378 (const double * const data, ARRAY(double, 1) stored) const 312 379 { 313 const StdSize size = storeIndex[0]->num_elements() ; 380 const StdSize size = (this->storeIndex[0])->num_elements() ; 381 // std::cout << this->getId() << "> size : " << size << std::endl; 314 382 stored->resize(boost::extents[size]) ; 315 383 for(StdSize i = 0; i < size; i++) … … 365 433 void CGrid::computeIndexServer(void) 366 434 { 367 ARRAY(int, 1) storeIndex_srv = this->storeIndex[0];368 ARRAY(int, 1) out_i_index_srv = this->out_i_index[0];369 ARRAY(int, 1) out_j_index_srv = this->out_j_index[0];370 ARRAY(int, 1) out_l_index_srv = this->out_l_index[0];371 372 435 ARRAY(int, 2) local_mask = this->domain->getLocalMask(); 373 436 … … 375 438 const std::vector<int> & jbegin = this->domain->getJBeginSub(); 376 439 377 const int ibegin_srv = this->domain->ibegin.getValue();378 const int jbegin_srv = this->domain->jbegin.getValue();379 const int zoom_ni_srv 380 const int zoom_nj_srv 440 const int ibegin_srv = this->domain->ibegin.getValue(); 441 const int jbegin_srv = this->domain->jbegin.getValue(); 442 const int zoom_ni_srv = this->domain->zoom_ni_loc.getValue(); 443 const int zoom_nj_srv = this->domain->zoom_nj_loc.getValue(); 381 444 382 445 const int ibegin_zoom_srv = this->domain->zoom_ibegin_loc.getValue(); … … 387 450 dn += this->out_i_index[j]->size(); 388 451 389 ARRAY_ ASSIGN(storeIndex_srv , int, 1, [dn]);390 ARRAY_ ASSIGN(out_i_index_srv, int, 1, [dn]);391 ARRAY_ ASSIGN(out_j_index_srv, int, 1, [dn]);392 ARRAY_ ASSIGN(out_l_index_srv, int, 1, [dn]);452 ARRAY_CREATE(storeIndex_srv , int, 1, [dn]); 453 ARRAY_CREATE(out_i_index_srv, int, 1, [dn]); 454 ARRAY_CREATE(out_j_index_srv, int, 1, [dn]); 455 ARRAY_CREATE(out_l_index_srv, int, 1, [dn]); 393 456 394 457 for (StdSize i = 0, dn = 0; i < ibegin.size(); i++) … … 404 467 for (StdSize n = dn, m = 0; n < (dn + storeIndex_cl->size()); n++, m++) 405 468 { 406 (*storeIndex_srv)[n] = (*storeIndex_cl)[m] + dn; // Faux mais inutile dans tous les cas.469 (*storeIndex_srv)[n] = (*storeIndex_cl)[m]; // Faux mais inutile dans le cas serveur. 407 470 (*out_i_index_srv)[n] = (*out_i_index_cl)[m] 408 471 + (ibegin_cl - 1) - (ibegin_srv - 1) - (ibegin_zoom_srv - 1); … … 438 501 (*local_mask)[(*out_i_index_srv)[u]][(*out_j_index_srv)[u]] = 1; 439 502 440 //~ StdOFStream ofs(this->getId().c_str()); 441 //~ for (StdSize h = 0; h < storeIndex_srv->size(); h++) 442 //~ { 443 //~ ofs << "(" << (*storeIndex_srv)[h] << ";" 444 //~ << (*out_i_index_srv)[h] << "," 445 //~ << (*out_j_index_srv)[h] << "," 446 //~ << (*out_l_index_srv)[h] << ")" << std::endl; 447 //~ } 448 //~ ofs.close(); 503 // StdOFStream ofs(("log_server_"+this->getId()).c_str()); 504 // for (StdSize h = 0; h < storeIndex_srv->size(); h++) 505 // { 506 // ofs << "(" << (*storeIndex_srv)[h] << ";" 507 // << (*out_i_index_srv)[h] << "," 508 // << (*out_j_index_srv)[h] << "," 509 // << (*out_l_index_srv)[h] << ")" << std::endl; 510 // } 511 // ofs.close(); 512 513 this->storeIndex [0] = storeIndex_srv ; 514 this->out_i_index[0] = out_i_index_srv; 515 this->out_j_index[0] = out_j_index_srv; 516 this->out_l_index[0] = out_l_index_srv; 517 449 518 this->storeIndex.resize(1); 450 519 this->out_i_index.resize(1); … … 454 523 } 455 524 456 //----------------------------------------------------------------457 525 458 526 void CGrid::inputFieldServer
Note: See TracChangeset
for help on using the changeset viewer.