Ignore:
Timestamp:
03/10/15 10:49:02 (9 years ago)
Author:
mhnguyen
Message:

Implementing a grid formed by only one axis or group of axis

+) Add several new attributes to axis. From now on, each axis can be distributed on client side
+) Modify mask of grid to make it more flexible to different dimension
+) Fix some bugs relating to calculation of local data index on client
+) Clean some redundant codes

Test
+) On Curie, only test_new_features.f90
+) Test cases:

  • Grid composed of: 1 domain and 1 axis, 3 axis, 1 axis
  • Mode: Attached and connected
  • No of client-server: 6-2(Connected), 2 (Attached)

+) All tests passed and results are correct

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/field.cpp

    • Property svn:executable set to *
    r562 r567  
    152152    list< CArray<double,1>* > list_data; 
    153153 
    154      for (it = grid->storeIndex_toSrv.begin(); it != grid->storeIndex_toSrv.end(); it++) 
    155     { 
    156       int rank = (*it).first; 
    157       CArray<int,1>& index = *(it->second); 
    158       CArray<double,1> data_tmp(index.numElements()); 
    159       for (int n = 0; n < data_tmp.numElements(); n++) data_tmp(n) = data(index(n)); 
    160       list_msg.push_back(shared_ptr<CMessage>(new CMessage)); 
    161       list_data.push_back(new CArray<double,1>(data_tmp)); 
    162       *list_msg.back() << getId() << *list_data.back(); 
    163       event.push(rank,grid->nbSenders[rank],*list_msg.back()); 
    164     } 
    165     client->sendEvent(event); 
     154    if (!grid->doGridHaveDataDistributed()) 
     155    { 
     156       if (0 == client->getClientRank()) 
     157       { 
     158          for(it=grid->storeIndex_toSrv.begin();it!=grid->storeIndex_toSrv.end();it++) 
     159          { 
     160            int rank=(*it).first ; 
     161            CArray<int,1>& index = *(it->second) ; 
     162            CArray<double,1> data_tmp(index.numElements()) ; 
     163            for(int n=0;n<data_tmp.numElements();n++) data_tmp(n)=data(index(n)) ; 
     164 
     165            list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ; 
     166            list_data.push_back(new CArray<double,1>(data_tmp)) ; 
     167            *list_msg.back()<<getId()<<*list_data.back() ; 
     168            event.push(rank,1,*list_msg.back()) ; 
     169          } 
     170          client->sendEvent(event) ; 
     171       } else client->sendEvent(event); 
     172    } 
     173    else 
     174    { 
     175      for(it=grid->storeIndex_toSrv.begin();it!=grid->storeIndex_toSrv.end();it++) 
     176      { 
     177        int rank=(*it).first ; 
     178        CArray<int,1>& index = *(it->second) ; 
     179        CArray<double,1> data_tmp(index.numElements()) ; 
     180        for(int n=0;n<data_tmp.numElements();n++) data_tmp(n)=data(index(n)) ; 
     181        list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ; 
     182        list_data.push_back(new CArray<double,1>(data_tmp)) ; 
     183        *list_msg.back()<<getId()<<*list_data.back() ; 
     184        event.push(rank,grid->nbSenders[rank],*list_msg.back()) ; 
     185      } 
     186      client->sendEvent(event) ; 
     187    } 
    166188 
    167189    for (list< CArray<double,1>* >::iterator it = list_data.begin(); it != list_data.end(); it++) delete *it; 
     
    189211  void  CField::recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) 
    190212  { 
    191  
    192213    if (data_srv.empty()) 
    193214    { 
    194 //      for (map<int, CArray<int, 1>* >::iterator it = grid->out_i_fromClient.begin(); it != grid->out_i_fromClient.end(); it++) 
    195215      for (map<int, CArray<size_t, 1>* >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 
    196216      { 
     
    234254  { 
    235255    if (!getRelFile()->allDomainEmpty) 
    236       if (!grid->domain->isEmpty() || getRelFile()->type == CFile::type_attr::one_file) 
     256      if (grid->doGridHaveDataToWrite() || getRelFile()->type == CFile::type_attr::one_file) //      if (! grid->domain->isEmpty() || getRelFile()->type == CFile::type_attr::one_file) 
    237257      { 
    238258        getRelFile()->checkFile(); 
     
    553573      } 
    554574 
    555 //     if (!grid_ref.isEmpty()) 
    556 //     { 
    557 //       domain = grid->domain; 
    558 //       axis = grid->axis; 
    559 //     } 
    560  
    561 //     CType<string> goodDomain; 
    562 //     CType<string> goodAxis; 
    563 //     if (!grid_ref.isEmpty()) 
    564 //     { 
    565 //       if (!grid->domain_ref.isEmpty()) goodDomain = grid->domain_ref; 
    566 //       if (!grid->axis_ref.isEmpty()) goodAxis = grid->axis_ref; 
    567 //     } 
    568 //     if (!domain_ref.isEmpty()) goodDomain = domain_ref; 
    569 //     if (!axis_ref.isEmpty()) goodAxis = axis_ref; 
    570  
    571 //     CArray<std::string,1> domListTmp = grid->domainList.getValue(); 
    572 //     CArray<std::string,1> axisListTmp = grid->axisList.getValue(); 
    573575 
    574576     if (domList.empty() && axisList.empty()) 
     
    576578       this->grid = CGrid::createGrid(vecDom, vecAxis); 
    577579     } 
    578  
    579 //     std::string goodDomain = domListTmp[0]; 
    580 //     std::string goodAxis = axisListTmp[0]; 
    581  
    582 //     if (goodDomain.isEmpty()) 
    583 //     if (goodDomain.empty()) 
    584 //     { 
    585 //       ERROR("CField::solveGridReference(void)", << "The horizontal domain for this field is not defined"); 
    586 //     } 
    587 //     else 
    588 //     { 
    589 //       if (CDomain::has(goodDomain)) domain = CDomain::get(goodDomain); 
    590 //       else ERROR("CField::solveGridReference(void)",<< "Reference to the domain \'" 
    591 //                  << goodDomain << "\' is wrong"); 
    592 ////                << goodDomain.get() << "\' is wrong"); 
    593 //     } 
    594 // 
    595 ////     if (!goodAxis.isEmpty()) 
    596 //     if (!goodAxis.empty()) 
    597 //     { 
    598 //       if (CAxis::has(goodAxis))  axis = CAxis::get(goodAxis); 
    599 //       else  ERROR("CField::solveGridReference(void)", << "Reference to the axis \'" 
    600 //                   << goodAxis <<"\' is wrong"); 
    601 //                   << goodAxis.get() <<"\' is wrong"); 
    602 //     } 
    603  
    604 //     bool nothingToDo = false; 
    605 // 
    606 //     if (!grid_ref.isEmpty()) 
    607 //     { 
    608 //       if (!grid->domain_ref.isEmpty() && goodDomain.get() == grid->domain_ref.get()) 
    609 //         if (goodAxis.isEmpty()) nothingToDo = true; 
    610 //         else if (!grid->axis_ref.isEmpty()) 
    611 //                 if (grid->axis_ref.get() == goodAxis.get()) nothingToDo = true; 
    612 //     } 
    613 // 
    614 //     nothingToDo = true; 
    615 //     if (!nothingToDo) 
    616 //     { 
    617 //       if (!goodAxis.isEmpty()) 
    618 //       { 
    619 //         this->grid = CGrid::createGrid(domain, axis); 
    620 //         this->grid_ref.setValue(this->grid->getId()); 
    621 //       } 
    622 //       else 
    623 //       { 
    624 //         this->grid = CGrid::createGrid(domain); 
    625 //         this->grid_ref.setValue(this->grid->getId()); 
    626 //       } 
    627 //     } 
    628  
    629 //     grid->solveReference(); 
    630 //     grid->solveDomainAxisRef(); 
    631 //     grid->checkMaskIndex(); 
    632580   } 
    633581 
     
    682630        grid->outputField(it->first,*it->second, fieldOut.dataFirst()); 
    683631      } 
    684  
    685 //         grid->outputField(it->first,*it->second, fieldOut.); 
    686632   } 
    687633 
     
    689635   { 
    690636      map<int, CArray<double,1>* >::iterator it; 
     637      for(it=data_srv.begin();it!=data_srv.end();it++) 
     638      { 
     639         grid->outputField(it->first,*it->second, fieldOut.dataFirst()) ; 
     640      } 
     641   } 
     642 
     643   void CField::outputField(CArray<double,1>& fieldOut) 
     644   { 
     645      map<int, CArray<double,1>* >::iterator it; 
    691646 
    692647      for (it = data_srv.begin(); it != data_srv.end(); it++) 
    693648      { 
    694          grid->outputField(it->first, *it->second, fieldOut); 
     649         grid->outputField(it->first,*it->second, fieldOut.dataFirst()) ; 
    695650      } 
    696651   } 
     
    844799   \return pair of Domain and Axis id 
    845800   */ 
    846    const std::pair<StdString,StdString>& CField::getDomainAxisIds() 
    847    { 
    848      CGrid* cgPtr = getRelGrid(); 
    849      if (NULL != cgPtr) 
    850      { 
    851        if (NULL != cgPtr->getRelDomain()) domAxisIds_.first = cgPtr->getRelDomain()->getId(); 
    852        if (NULL != cgPtr->getRelAxis()) domAxisIds_.second = cgPtr->getRelAxis()->getId(); 
    853      } 
    854  
    855      return domAxisIds_; 
    856    } 
     801//   const std::pair<StdString,StdString>& CField::getDomainAxisIds() 
     802//   { 
     803//     CGrid* cgPtr = getRelGrid(); 
     804//     if (NULL != cgPtr) 
     805//     { 
     806//       if (NULL != cgPtr->getRelDomain()) domAxisIds_.first = cgPtr->getRelDomain()->getId(); 
     807//       if (NULL != cgPtr->getRelAxis()) domAxisIds_.second = cgPtr->getRelAxis()->getId(); 
     808//     } 
     809// 
     810//     return (domAxisIds_); 
     811//   } 
    857812 
    858813   CVariable* CField::addVariable(const string& id) 
Note: See TracChangeset for help on using the changeset viewer.