Changeset 551 for XIOS/trunk/src/node/grid.cpp
- Timestamp:
- 02/11/15 16:23:02 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/grid.cpp
r540 r551 21 21 , withAxis(false), isChecked(false), isDomainAxisChecked(false), axis(), domain() 22 22 , storeIndex(1), out_i_index(1), out_j_index(1), out_l_index(1), isDomConServerComputed_(false) 23 , vDomainGroup_(), vAxisGroup_(), axis Order_(), axisList_(), isAxisListSet(false), isDomListSet(false)23 , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false), clientDistribution_(0), isIndexSent(false) 24 24 { 25 25 setVirtualDomainGroup(); … … 31 31 , withAxis(false), isChecked(false), isDomainAxisChecked(false), axis(), domain() 32 32 , storeIndex(1), out_i_index(1), out_j_index(1), out_l_index(1), isDomConServerComputed_(false) 33 , vDomainGroup_(), vAxisGroup_(), axis Order_(), axisList_(), isAxisListSet(false), isDomListSet(false)33 , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false), clientDistribution_(0), isIndexSent(false) 34 34 { 35 35 setVirtualDomainGroup(); … … 51 51 for(map<int,CArray<int,1>* >::iterator it=out_j_fromClient.begin();it!=out_j_fromClient.end();it++) delete it->second ; 52 52 for(map<int,CArray<int,1>* >::iterator it=out_l_fromClient.begin();it!=out_l_fromClient.end();it++) delete it->second ; 53 54 for(map<int,CArray<size_t,1>* >::iterator it=outIndexFromClient.begin();it!=outIndexFromClient.end();++it) delete (it->second); 55 56 if (0 != clientDistribution_) delete clientDistribution_; 53 57 54 58 } … … 176 180 std::map<int, StdSize> CGrid::getConnectedServerDataSize() 177 181 { 182 double secureFactor = 2.5 * sizeof(double) * CXios::bufferServerFactorSize; 183 StdSize retVal; 178 184 std::map<int, StdSize> ret; 179 std::map<int, int>::const_iterator it = domConnectedServerSide_.begin(), 180 itE = domConnectedServerSide_.end(); 181 std::vector<int> nData = domain->nbDataSrv; 182 std::vector<int>::const_iterator itData = nData.begin(); 183 StdSize retVal = StdSize(0.0); 184 for (; it != itE; ++it, ++itData) 185 const std::map<int, std::vector<int> >& distribution = clientDistribution_->getLocalIndexSendToServer(); 186 std::map<int, std::vector<int> >::const_iterator it = distribution.begin(), itE = distribution.end(); 187 for (; it != itE; ++it) 185 188 { 186 retVal = (it->second < *itData) ? *itData : it->second; 187 if (this->withAxis) retVal *= this->axis->size.getValue(); 188 retVal *= sizeof(double); 189 retVal *= 2.5 * CXios::bufferServerFactorSize; // Secure factor, myterious number 190 ret.insert(make_pair(it->first, retVal)); 189 retVal = it->second.size(); 190 retVal *= secureFactor; 191 ret.insert(std::make_pair<int,StdSize>(it->first, retVal)); 191 192 } 193 192 194 return ret; 193 195 } … … 235 237 236 238 if (context->hasClient) 237 if (this->isChecked && doSendingIndex ) sendIndex();239 if (this->isChecked && doSendingIndex && !isIndexSent) { sendIndex(); this->isIndexSent = true; } 238 240 239 241 if (this->isChecked) return; … … 397 399 void CGrid::computeIndex(void) 398 400 { 399 401 CContext* context = CContext::getCurrent() ; 402 CContextClient* client=context->client ; 403 clientDistribution_ = new CDistributionClient(client->clientRank, this); 404 clientDistribution_->computeServerIndexMapping(client->serverSize); 405 nbSenders = clientDistribution_->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm); 406 407 storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().numElements()); 408 storeIndex_client = (clientDistribution_->getLocalDataIndexOnClient()); 409 410 /* 400 411 const int ni = domain->ni.getValue() , 401 412 nj = domain->nj.getValue() , … … 476 487 } 477 488 } 478 computeDomConServer(); 489 */ 490 // computeDomConServer(); 479 491 // sendIndex() ; 480 492 … … 520 532 grid->setDomainList(domains); 521 533 grid->setAxisList(axis); 534 535 //By default, domains are always the first ones of a grid 536 if (grid->axisDomainOrder.isEmpty()) 537 { 538 int size = domains.size()+axis.size(); 539 grid->axisDomainOrder.resize(size); 540 for (int i = 0; i < size; ++i) 541 { 542 if (i < domains.size()) grid->axisDomainOrder(i) = true; 543 else grid->axisDomainOrder(i) = false; 544 } 545 } 546 522 547 return (grid); 523 548 } … … 561 586 for(StdSize n = 0; n < stored.numElements(); n++) 562 587 field(out_i(n)) = stored(n) ; 588 } 589 590 void CGrid::outputField(int rank, const CArray<double, 1>& stored, double* field) 591 { 592 CArray<size_t,1>& out_i=*outIndexFromClient[rank]; 593 StdSize numElements = stored.numElements(); 594 for (StdSize n = 0; n < numElements; ++n) 595 { 596 *(field+out_i(n)) = stored(n); 597 } 563 598 } 564 599 … … 599 634 // if (domain->mapConnectedServer(i,j)==ns) nb++ ; 600 635 // } 601 //602 636 // CArray<int,1> storeIndex(nb) ; 603 637 // CArray<int,1> out_i(nb) ; … … 676 710 int rank ; 677 711 list<shared_ptr<CMessage> > list_msg ; 678 list< CArray<int,1>* > list_out_i,list_out_j,list_out_l ; 679 712 list< CArray<size_t,1>* > listOutIndex; 713 714 const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientDistribution_->getGlobalIndexOnServer(); 715 const std::map<int, std::vector<int> >& localIndexSendToServer = clientDistribution_->getLocalIndexSendToServer(); 716 717 std::map<int, std::vector<size_t> >::const_iterator iteMap, itbMap, itGlobal; 718 std::map<int, std::vector<int> >::const_iterator itLocal; 719 itbMap = itGlobal = globalIndexOnServer.begin(); 720 iteMap = globalIndexOnServer.end(); 721 itLocal = localIndexSendToServer.begin(); 722 723 724 for (int ns = 0; itGlobal != iteMap; ++itGlobal, ++itLocal, ++ns) 725 { 726 rank = itGlobal->first; 727 int nb = (itGlobal->second).size(); 728 729 CArray<size_t, 1> outGlobalIndexOnServer(nb); 730 CArray<int, 1> outLocalIndexToServer(nb); 731 for (int k = 0; k < nb; ++k) 732 { 733 outGlobalIndexOnServer(k) = itGlobal->second.at(k); 734 outLocalIndexToServer(k) = itLocal->second.at(k); 735 } 736 737 storeIndex_toSrv.insert( pair<int,CArray<int,1>* >(rank,new CArray<int,1>(outLocalIndexToServer) )); 738 listOutIndex.push_back(new CArray<size_t,1>(outGlobalIndexOnServer)); 739 740 list_msg.push_back(shared_ptr<CMessage>(new CMessage)); 741 *list_msg.back()<<getId()<<*listOutIndex.back(); 742 event.push(rank, nbSenders[rank], *list_msg.back()); 743 } 744 client->sendEvent(event); 745 for(list<CArray<size_t,1>* >::iterator it=listOutIndex.begin();it!=listOutIndex.end();++it) delete *it ; 746 747 /* 680 748 if (!isDomConServerComputed_) computeDomConServer(); 681 749 … … 721 789 for(list<CArray<int,1>* >::iterator it=list_out_j.begin();it!=list_out_j.end();it++) delete *it ; 722 790 for(list<CArray<int,1>* >::iterator it=list_out_l.begin();it!=list_out_l.end();it++) delete *it ; 723 791 */ 724 792 } 725 793 … … 731 799 int rank=it->rank; 732 800 CBufferIn* buffer=it->buffer; 733 string domainId ;734 *buffer>> domainId ;735 get( domainId)->recvIndex(rank,*buffer) ;801 string gridId ; 802 *buffer>>gridId ; 803 get(gridId)->recvIndex(rank,*buffer) ; 736 804 } 737 805 } … … 739 807 void CGrid::recvIndex(int rank, CBufferIn& buffer) 740 808 { 809 CArray<size_t,1> outIndex; 810 buffer>>outIndex; 811 outIndexFromClient.insert(std::pair<int, CArray<size_t,1>* >(rank, new CArray<size_t,1>(outIndex))); 812 813 /* 741 814 CArray<int,1> out_i ; 742 815 CArray<int,1> out_j ; … … 751 824 out_j_fromClient.insert(pair< int,CArray<int,1>* >(rank,new CArray<int,1>(out_j) )) ; 752 825 out_l_fromClient.insert(pair< int,CArray<int,1>* >(rank,new CArray<int,1>(out_l) )) ; 826 */ 753 827 } 754 828 … … 947 1021 } 948 1022 1023 /*! 1024 \brief Solve domain and axis references 1025 As field, domain and axis can refer to other domains or axis. In order to inherit correctly 1026 all attributes from their parents, they should be processed with this function 1027 \param[in] apply inherit all attributes of parents (true) 1028 */ 949 1029 void CGrid::solveDomainAxisRefInheritance(bool apply) 950 1030 { … … 963 1043 if ((!pDom->domain_ref.isEmpty()) && (pDom->name.isEmpty())) 964 1044 pDom->name.setValue(pDom->getBaseDomainReference()->getId()); 965 966 1045 } 967 1046 } … … 982 1061 } 983 1062 1063 /*! 1064 \brief Get the list of domain pointers 1065 \return list of domain pointers 1066 */ 984 1067 std::vector<CDomain*> CGrid::getDomains() 985 1068 { … … 992 1075 } 993 1076 1077 /*! 1078 \brief Get the list of axis pointers 1079 \return list of axis pointers 1080 */ 994 1081 std::vector<CAxis*> CGrid::getAxis() 995 1082 { … … 1001 1088 } 1002 1089 1090 /*! 1091 \brief Set domain(s) of a grid from a list 1092 \param[in] domains list of domains 1093 */ 1003 1094 void CGrid::setDomainList(const std::vector<CDomain*> domains) 1004 1095 { … … 1019 1110 } 1020 1111 1112 /*! 1113 \brief Set axis(s) of a grid from a list 1114 \param[in] axis list of axis 1115 */ 1021 1116 void CGrid::setAxisList(const std::vector<CAxis*> axis) 1022 1117 { … … 1036 1131 } 1037 1132 1133 /*! 1134 \brief Get list of id of domains 1135 \return id list of domains 1136 */ 1038 1137 std::vector<StdString> CGrid::getDomainList() 1039 1138 { … … 1042 1141 } 1043 1142 1143 /*! 1144 \brief Get list of id of axis 1145 \return id list of axis 1146 */ 1044 1147 std::vector<StdString> CGrid::getAxisList() 1045 1148 { … … 1074 1177 { 1075 1178 SuperClass::parse(node); 1179 // List order of axis and domain in a grid, if there is a domain, it will take value 1 (true), axis 0 (false) 1180 // std::vector<int> axisOrder; 1181 std::vector<bool> order; 1076 1182 1077 1183 if (node.goToChildElement()) 1078 1184 { 1079 int domainIdx = -1;1080 int posAxis = 0;1081 1185 StdString domainName("domain"); 1082 1186 StdString axisName("axis"); … … 1084 1188 { 1085 1189 if (node.getElementName() == domainName) { 1086 axisOrder_.push_back(domainIdx);1190 order.push_back(true); 1087 1191 this->getVirtualDomainGroup()->parseChild(node); 1088 1192 } 1089 1193 if (node.getElementName() == axisName) { 1090 axisOrder_.push_back(posAxis); 1091 ++posAxis; 1194 order.push_back(false); 1092 1195 this->getVirtualAxisGroup()->parseChild(node); 1093 1196 } … … 1096 1199 } 1097 1200 1098 if (! axisOrder_.empty())1099 { 1100 int sizeOrd = axisOrder_.size();1101 axisDom Order.resize(sizeOrd);1201 if (!order.empty()) 1202 { 1203 int sizeOrd = order.size(); 1204 axisDomainOrder.resize(sizeOrd); 1102 1205 for (int i = 0; i < sizeOrd; ++i) 1103 1206 { 1104 axisDom Order(i) = axisOrder_[i];1207 axisDomainOrder(i) = order[i]; 1105 1208 } 1106 1209 }
Note: See TracChangeset
for help on using the changeset viewer.