Changeset 2022


Ignore:
Timestamp:
01/22/21 18:46:08 (8 months ago)
Author:
ymipsl
Message:

Reimplement coupling in the new infrastructure.
Tested for 2-way coupling toy model.

YM

Location:
XIOS/dev/dev_ym/XIOS_COUPLING/src
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/context_server.cpp

    r1875 r2022  
    5252    CXios::getContextsManager()->getContextInfo(context->getId(), contextInfo, intraComm) ; 
    5353 
    54     if (contextInfo.serviceType != CServicesManager::CLIENT) // we must have an event scheduler => to be retrieve from the associated services 
    55     { 
     54  //  if (contextInfo.serviceType != CServicesManager::CLIENT) // we must have an event scheduler => to be retrieve from the associated services 
     55  //  { 
    5656      if (!isAttachedModeEnabled()) eventScheduler_=CXios::getPoolRessource()->getService(contextInfo.serviceId,contextInfo.partitionId)->getEventScheduler() ; 
    57     } 
     57  //  } 
    5858 
    5959 
     
    323323        else if (!eventScheduler_ || eventScheduler_->queryEvent(currentTimeLine,hashId) ) 
    324324        { 
     325          MPI_Barrier(intraComm) ; 
    325326         // When using attached mode, synchronise the processes to avoid that differents event be scheduled by differents processes 
    326327         // The best way to properly solve this problem will be to use the event scheduler also in attached mode 
     
    332333         isProcessingEvent_=true ; 
    333334         CTimer::get("Process events").resume(); 
     335         info(100)<<"Received Event "<<currentTimeLine<<" of class "<<event->classId<<" of type "<<event->type<<endl ; 
    334336         dispatchEvent(*event); 
    335337         CTimer::get("Process events").suspend(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/event_scheduler.cpp

    r1760 r2022  
    7676  { 
    7777    registerEvent(timeLine, contextHashId, level) ; 
     78    checkEvent() ; 
    7879  } 
    7980   
     
    9495  bool CEventScheduler::queryEvent(const size_t timeLine, const size_t contextHashId) 
    9596  { 
    96  
     97    checkEvent() ; 
    9798    if (! eventStack.empty() && eventStack.front().first==timeLine && eventStack.front().second==contextHashId) 
    9899    { 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/filter/client_from_client_source_filter.cpp

    r1973 r2022  
    3434    CDataPacketPtr packet(new CDataPacket); 
    3535    packet->date = date; 
     36    packet->status = CDataPacket::NO_ERROR; 
     37    for (auto& subEvent : event.subEvents) (*subEvent.buffer) >> packet->timestamp  ; // better management of time lien later... 
    3638    packet->timestamp = date; 
    37     packet->status = CDataPacket::NO_ERROR; 
    38  
     39          
    3940    grid_->getClientFromClientConnector()->transfer(event,packet->data) ; 
    4041    onOutputReady(packet); 
     
    4748    if (wasDataAlreadyReceived_) isDataLate = lastDateReceived_ + offset_ + freqOp_ <= currentDate ; 
    4849    else isDataLate = CContext::getCurrent()->getCalendar()->getInitDate()+ offset_ <= currentDate ; 
     50    return isDataLate ; 
    4951  } 
    5052 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/filter/client_to_server_store_filter.cpp

    r1984 r2022  
    1515  { 
    1616    if (!field) 
    17       ERROR("CFileWriterFilter::CFileWriterFilter(CField* field)", 
     17      ERROR("CClientToServerStoreFilter::CClientToServerStoreFilter(CGarbageCollector& gc, CField* field, CContextClient* client)", 
    1818            "The field cannot be null."); 
    1919  } 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.cpp

    r1984 r2022  
    452452    } 
    453453 
     454  string CAxis::getCouplingAlias(const string& fieldId, int posInGrid) 
     455  { 
     456    return "_axis["+std::to_string(posInGrid)+"]_of_"+fieldId ; 
     457  } 
     458 
    454459  void CAxis::makeAliasForCoupling(const string& fieldId, int posInGrid) 
    455460  { 
    456     const string axisId = "_axis["+std::to_string(posInGrid)+"]_of_"+fieldId ; 
     461    const string axisId = getCouplingAlias(fieldId,posInGrid) ; 
    457462    this->createAlias(axisId) ; 
    458463  } 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.hpp

    r2007 r2022  
    175175      public: 
    176176         void makeAliasForCoupling(const string& fieldId, int posInGrid) ; 
    177  
     177         string getCouplingAlias(const string& fieldId, int posInGrid) ; 
    178178 
    179179      private: 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.cpp

    r2002 r2022  
    2626#include "coupler_in.hpp" 
    2727#include "coupler_out.hpp" 
    28  
    29 namespace xios { 
     28#include "servers_ressource.hpp" 
     29#include "pool_ressource.hpp" 
     30#include "services.hpp" 
     31#include "contexts_manager.hpp" 
     32#include <chrono> 
     33#include <random> 
     34 
     35namespace xios 
     36{ 
    3037 
    3138  std::shared_ptr<CContextGroup> CContext::root; 
     
    6774   //---------------------------------------------------------------- 
    6875 
     76  void CContext::initEventScheduler(void) 
     77  { 
     78    SRegisterContextInfo contextInfo ; 
     79    CXios::getContextsManager()->getContextInfo(this->getId(), contextInfo, getIntraComm()) ; 
     80 
     81    eventScheduler_=CXios::getPoolRessource()->getService(contextInfo.serviceId,contextInfo.partitionId)->getEventScheduler() ; 
     82  
     83    // generate unique hash for server 
     84    auto time=chrono::system_clock::now().time_since_epoch().count() ; 
     85    std::default_random_engine rd(time); // not reproducible from a run to another 
     86    std::uniform_int_distribution<size_t> dist; 
     87    hashId_=dist(rd) ; 
     88    MPI_Bcast(&hashId_,1,MPI_SIZE_T,0,getIntraComm()) ; // Bcast to all server of the context 
     89  } 
    6990   /*! 
    7091   \brief Get context group (context root) 
     
    497518     else 
    498519       initServer(intraComm, serviceType) ; 
     520     initEventScheduler() ; 
    499521    } 
    500522    CATCH_DUMP_ATTR 
     
    699721  { 
    700722    bool finished=true;  
    701  
    702     if (client!=nullptr && !finalized) client->checkBuffers(); 
     723    bool out;  
     724    size_t timeLine=timeLine_ ; 
     725    if (serviceType_==CServicesManager::CLIENT) 
     726    { 
     727      timeLine_++ ; 
     728      eventScheduler_->registerEvent(timeLine, hashId_) ; 
     729    } 
     730 
     731    do 
     732    {  
     733      if (client!=nullptr && !finalized) client->checkBuffers(); 
    703734     
    704     for (int i = 0; i < clientPrimServer.size(); ++i) 
    705     { 
    706       if (!finalized) clientPrimServer[i]->checkBuffers(); 
    707       if (!finalized) finished &= serverPrimServer[i]->eventLoop(enableEventsProcessing); 
    708     } 
    709  
    710     for (auto couplerOut : couplerOutClient_) 
    711       if (!finalized) couplerOut.second->checkBuffers(); 
     735      for (int i = 0; i < clientPrimServer.size(); ++i) 
     736      { 
     737        if (!finalized) clientPrimServer[i]->checkBuffers(); 
     738        if (!finalized) finished &= serverPrimServer[i]->eventLoop(enableEventsProcessing); 
     739      } 
     740 
     741      for (auto couplerOut : couplerOutClient_) 
     742        if (!finalized) couplerOut.second->checkBuffers(); 
    712743     
    713     for (auto couplerIn : couplerInClient_) 
    714       if (!finalized) couplerIn.second->checkBuffers(); 
     744      for (auto couplerIn : couplerInClient_) 
     745        if (!finalized) couplerIn.second->checkBuffers(); 
    715746     
    716     for (auto couplerOut : couplerOutServer_) 
    717       if (!finalized) couplerOut.second->eventLoop(enableEventsProcessing); 
    718  
    719     for (auto couplerIn : couplerInServer_) 
    720       if (!finalized) couplerIn.second->eventLoop(enableEventsProcessing); 
     747      for (auto couplerOut : couplerOutServer_) 
     748        if (!finalized) couplerOut.second->eventLoop(enableEventsProcessing); 
     749 
     750      for (auto couplerIn : couplerInServer_) 
     751        if (!finalized) couplerIn.second->eventLoop(enableEventsProcessing); 
    721752     
    722     if (server!=nullptr) if (!finalized) finished &= server->eventLoop(enableEventsProcessing); 
     753      if (server!=nullptr) if (!finalized) finished &= server->eventLoop(enableEventsProcessing); 
    723754   
     755      if (serviceType_==CServicesManager::CLIENT) out = eventScheduler_->queryEvent(timeLine,hashId_) ; 
     756      else out=true ; 
     757    }  while(!out) ; 
    724758    return finalized && finished ; 
    725759  } 
     
    9901024 
    9911025    bool workflowGraphIsCompleted ; 
    992  
     1026     
    9931027    bool first=true ; 
     1028    
    9941029    do 
    9951030    { 
     
    9991034        workflowGraphIsCompleted &= endWorkflowField->buildWorkflowGraph(garbageCollector) ; 
    10001035      } 
    1001  
     1036    
    10021037      for(auto couplerIn : enabledCouplerIn) couplerIn->assignContext() ; 
    10031038      for(auto field : couplerInField) field->makeGridAliasForCoupling(); 
     
    10131048      } 
    10141049      if (first) setClientServerBuffer(couplerOutField, true) ; // set buffer context --> to check 
    1015     
     1050 
    10161051      bool couplersReady ; 
    10171052      do  
     
    10241059          couplersReady &= ready ; 
    10251060        } 
    1026         if (!couplersReady) this->eventLoop() ; 
     1061        this->eventLoop() ; 
     1062 
    10271063      } while (!couplersReady) ; 
    1028  
     1064       
    10291065      first=false ; 
    10301066      this->eventLoop() ; 
     1067 
    10311068    } while (!workflowGraphIsCompleted) ; 
     1069 
    10321070 
    10331071    for( auto field : couplerInField) couplerInFields_.push_back(field) ; 
     
    11601198      ok = true ; 
    11611199      for(auto& couplerOutClient : couplerOutClient_) ok &= isCouplerInCloseDefinition(couplerOutClient.second) ; 
    1162       this->eventLoop() ;  
     1200      this->eventLoop() ; 
    11631201    } while (!ok) ; 
    11641202 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.hpp

    r2002 r2022  
    1414#include "services_manager.hpp" 
    1515#include "server_context.hpp" 
    16  
    17  
    18 namespace xios { 
     16#include "event_scheduler.hpp" 
     17 
     18 
     19namespace xios 
     20{ 
    1921   class CContextClient; 
    2022   class CContextServer; 
     
    339341         
    340342      private: 
     343         CEventScheduler* eventScheduler_ ; //! The local event scheduler for context 
     344         size_t hashId_ ; //! the local hashId for scheduler 
     345         size_t timeLine_=0 ; 
     346         void initEventScheduler(void) ; 
     347 
    341348         bool isPostProcessed; 
    342349         bool allProcessed; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.cpp

    r1984 r2022  
    17811781 
    17821782 
     1783  string CDomain::getCouplingAlias(const string& fieldId, int posInGrid) 
     1784  { 
     1785    return "_domain["+std::to_string(posInGrid)+"]_of_"+fieldId ; 
     1786  } 
    17831787    
    17841788  /* to be removed later when coupling will be reimplemented, just to  not forget */ 
     
    17881792    else sendDomainToFileServer_done_.insert(client) ; 
    17891793     
    1790     const string domainId = "_domain["+std::to_string(posInGrid)+"]_of_"+fieldId ; 
     1794    const string domainId = getCouplingAlias(fieldId, posInGrid) ; 
    17911795     
    17921796    if (!domain_ref.isEmpty()) 
     
    18051809  void CDomain::makeAliasForCoupling(const string& fieldId, int posInGrid) 
    18061810  { 
    1807     const string domainId = "_domain["+std::to_string(posInGrid)+"]_of_"+fieldId ; 
     1811    const string domainId = getCouplingAlias(fieldId, posInGrid); 
    18081812    this->createAlias(domainId) ; 
    18091813  } 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.hpp

    r1984 r2022  
    240240       public: 
    241241        void makeAliasForCoupling(const string& fieldId, int posInGrid) ; 
    242  
     242        string getCouplingAlias(const string& fieldId, int posInGrid) ; 
    243243       private: 
    244244 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp

    r2018 r2022  
    586586      { 
    587587        grid->solveElementsRefInheritance() ; 
    588         
    589         // new 
    590          
    591588        std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters = grid->buildTransformationGraph(gc, false,  gridSrc, detectMissingValues, defaultValue, newGrid) ; 
    592589        lastFilter->connectOutput(filters.first, 0); 
    593590        lastFilter = filters.second; 
    594591        gridSrc = newGrid ; 
    595  
    596         // end new 
    597 /* 
    598         grid->completeGrid(gridSrc); // grid generation, to be checked 
    599         grid->checkElementsAttributes() ; 
    600         grid->prepareTransformGrid(gridSrc) ; // prepare the grid tranformation 
    601         for(auto fieldId : grid->getAuxInputTransformGrid()) // try to build workflow graph for auxillary field tranformation 
    602           if (!CField::get(fieldId)->buildWorkflowGraph(gc)) return false ; 
    603         gridSrc=grid ; 
    604 */ 
    605       } 
    606  
    607     /*   
    608       std::shared_ptr<COutputPin> lastFilter ; 
    609       if (filterExpr) lastFilter=filterExpr ; 
    610       else lastFilter = inputFilter ; 
    611        
    612       gridSrc=getDirectFieldReference()->getGrid() ; 
    613       for(auto grid : gridPath)  
    614       { 
    615         grid->makeTransformGrid() ; // make the grid transformation 
    616         if (grid->hasTransform())  
    617         { 
    618           std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters = CSpatialTransformFilter::buildFilterGraph(gc, gridSrc, grid, detectMissingValues, defaultValue);  
    619           lastFilter->connectOutput(filters.first, 0); 
    620           lastFilter = filters.second; 
    621           gridSrc=grid ; 
    622         } 
    623       } 
    624     */ 
     592      } 
     593 
    625594      grid_=newGrid ; 
    626595      grid_ref=grid_->getId() ; // for server  
     
    665634        grid_ = newGrid ; 
    666635        grid_ref=grid_->getId() ; // for server  
    667 //        grid_->completeGrid(); // grid generation, to be checked => later 
    668636        grid_->checkElementsAttributes() ; 
    669637        instantDataFilter=inputFilter ; 
     
    12841252    if (sendFieldToCouplerOut_done_) return ; 
    12851253    else sendFieldToCouplerOut_done_=true ; 
    1286     grid_->sendGridToCouplerOut(client, this->getId()); 
     1254    sentGrid_ = grid_-> duplicateSentGrid() ; 
     1255    sentGrid_->sendGridToCouplerOut(client, this->getId()); 
    12871256    this->sendGridCompleted(); 
    12881257 
     
    13301299   CATCH_DUMP_ATTR 
    13311300 
     1301  bool CField::isGridCompleted(void) 
     1302  TRY 
     1303  {  
     1304    bool isFullCompleted ; 
     1305    MPI_Allreduce(&isGridCompleted_,&isFullCompleted,1,MPI_C_BOOL, MPI_LAND, CContext::getCurrent()->getIntraComm() ) ; 
     1306    if ( (isGridCompleted_==false && isFullCompleted==true) ) ERROR("bool CField::isGridCompleted(void)",<< "incoherecy in MPI_AllReduce") ; 
     1307    return isFullCompleted ;  
     1308  } 
     1309  CATCH_DUMP_ATTR 
    13321310 
    13331311  void CField::sendAddAllVariables(CContextClient* client) 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.hpp

    r2011 r2022  
    236236          bool isGridCompleted_ = true ; 
    237237      public: 
    238           bool isGridCompleted() { return isGridCompleted_ ;}  
     238          bool isGridCompleted()  ;  
    239239          void setGridCompleted(void) { isGridCompleted_= true; } 
    240240          void unsetGridCompleted(void) { isGridCompleted_ = false ;} 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp

    r2016 r2022  
    12071207    gridPtr->sendCreateChild(this->getId(),client); 
    12081208    this->sendAllAttributesToServer(client); 
    1209     distributeGridToFileServer(client) ; 
    1210   } 
    1211  
    1212  
    1213   void CGrid::distributeGridToFileServer(CContextClient* client) 
     1209    distributeGridToServer(client) ; 
     1210  } 
     1211 
     1212 
     1213  void CGrid::sendGridToCouplerOut(CContextClient* client, const string& fieldId) 
     1214  { 
     1215    if (sendGridToCouplerOut_done_.count(client)!=0) return ; 
     1216    else sendGridToCouplerOut_done_.insert(client) ; 
     1217    this->sendAllAttributesToServer(client, getCouplingAlias(fieldId)); 
     1218    distributeGridToServer(client,fieldId) ; 
     1219  } 
     1220 
     1221 
     1222  void CGrid::distributeGridToServer(CContextClient* client, const string& fieldId) 
    12141223  { 
    12151224    CContext* context = CContext::getCurrent(); 
     1225    bool isCoupling = !fieldId.empty() ; 
    12161226    // simple Distribution for now  
    12171227    // distribute over the fisrt element except if it is a scalar 
     
    12611271      if (elements[i].type==TYPE_DOMAIN)  
    12621272      {  
    1263          CDomain* domain = (CDomain*) elements[i].ptr ; 
    1264          sendAddDomain(domain->getId(),client) ; 
    1265          domain->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector) ; 
    1266          scattererConnectors.push_back(scattererConnector) ; 
     1273        CDomain* domain = (CDomain*) elements[i].ptr ; 
     1274        if (isCoupling) domain->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector,  domain->getCouplingAlias(fieldId,i)) ; 
     1275        else  
     1276        { 
     1277          sendAddDomain(domain->getId(),client) ; 
     1278          domain->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector) ; 
     1279        } 
     1280        scattererConnectors.push_back(scattererConnector) ; 
    12671281      } 
    12681282      else if (elements[i].type==TYPE_AXIS) 
    12691283      { 
    12701284        CAxis* axis = (CAxis*) elements[i].ptr ; 
    1271         sendAddAxis(axis->getId(),client) ; 
    1272         axis->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector) ; 
     1285        if (isCoupling) axis->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector,  axis->getCouplingAlias(fieldId,i)) ; 
     1286        else  
     1287        { 
     1288          sendAddAxis(axis->getId(),client) ; 
     1289          axis->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector) ; 
     1290        } 
    12731291        scattererConnectors.push_back(scattererConnector) ; 
    12741292      } 
     
    12761294      { 
    12771295        CScalar* scalar = (CScalar*) elements[i].ptr ; 
    1278         sendAddScalar(scalar->getId(),client) ; 
    1279         scalar->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector) ; 
     1296        if (isCoupling) scalar->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector,  scalar->getCouplingAlias(fieldId,i)) ; 
     1297        else  
     1298        { 
     1299          sendAddScalar(scalar->getId(),client) ; 
     1300          scalar->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector) ; 
     1301        } 
    12801302        scattererConnectors.push_back(scattererConnector) ; 
    12811303      } 
     
    12911313    CEventClient event(getType(), EVENT_ID_SEND_MASK); 
    12921314    CMessage message ; 
    1293     message<<getId() ;  
     1315    if (isCoupling) message<<getCouplingAlias(fieldId) ; 
     1316    else message<<getId() ;  
    12941317    gridScattererConnector.transfer(maskOut, client, event, message) ; 
    12951318    for(auto& it : scattererConnectors) delete it ; 
     
    13211344    clientFromServerConnector_[client] = new CGridGathererConnector(clientFromServerConnectors) ; 
    13221345 
    1323  
    1324   } 
     1346  } 
     1347 
    13251348 
    13261349  void CGrid::recvMask(CEventServer& event) 
     
    13731396  } 
    13741397 
    1375  
    1376   void CGrid::sendGridToCouplerOut(CContextClient* client, const string& fieldId) 
    1377   { 
    1378 /*    if (sendGridToCouplerOut_done_.count(client)!=0) return ; 
    1379     else sendGridToCouplerOut_done_.insert(client) ; 
    1380   
    1381     CContext* context = CContext::getCurrent(); 
    1382     // simple Distribution for now  
    1383     // distribute over the fisrt element except if it is a scalar 
     1398  string CGrid::getCouplingAlias(const string& fieldId) 
     1399  { 
     1400    return "_grid_of_"+fieldId; 
     1401  } 
     1402 
     1403  void CGrid::makeAliasForCoupling(const string& fieldId) 
     1404  { 
     1405    string gridId=getCouplingAlias(fieldId) ; 
     1406    createAlias(gridId) ; 
     1407 
    13841408    auto& elements = getElements() ; 
    1385     int posDistributed = 0 ; 
    1386     for(auto& element : elements) 
    1387     { 
    1388       if (element.type==TYPE_DOMAIN) break ; 
    1389       else if (element.type==TYPE_AXIS) break ; 
    1390       else if (element.type==TYPE_SCALAR) posDistributed++ ; 
    1391     } 
    1392      
    1393     vector<CLocalView*> localViews ; 
    1394     vector<CDistributedView*> remoteViews ; 
    1395  
    13961409    for(int i=0 ; i<elements.size() ; i++) 
    13971410    { 
    1398       if (elements[i].type==TYPE_DOMAIN)  
    1399       {  
    1400          CDomain* domain = (CDomain*) elements[i].ptr ; 
    1401          domain->computeRemoteElement(client, posDistributed==i ? EDistributionType::BANDS : EDistributionType::NONE) ; 
    1402          remoteViews.push_back(domain->getRemoteElement(client)->getView(CElementView::FULL)) ; 
    1403          localViews.push_back(domain->getLocalView(CElementView::FULL)) ; 
    1404       } 
    1405       else if (elements[i].type==TYPE_AXIS) 
    1406       { 
    1407         CAxis* axis = (CAxis*) elements[i].ptr ; 
    1408         axis->computeRemoteElement(client, posDistributed==i ? EDistributionType::BANDS : EDistributionType::NONE) ; 
    1409         remoteViews.push_back(axis->getRemoteElement(client)->getView(CElementView::FULL)) ; 
    1410         localViews.push_back(axis->getLocalView(CElementView::FULL)) ; 
    1411       } 
    1412       else if (elements[i].type==TYPE_SCALAR) 
    1413       { 
    1414         CScalar* scalar = (CScalar*) elements[i].ptr ; 
    1415         scalar->computeRemoteElement(client, posDistributed==i ? EDistributionType::BANDS : EDistributionType::NONE) ; 
    1416         remoteViews.push_back(scalar->getRemoteElement(client)->getView(CElementView::FULL)) ; 
    1417         localViews.push_back(scalar->getLocalView(CElementView::FULL)) ; 
    1418       } 
    1419     } 
    1420     CGridRemoteConnector gridRemoteConnector(localViews, remoteViews, context->getIntraComm(), client->getRemoteSize()) ; 
    1421     gridRemoteConnector.computeConnector() ; 
    1422      
    1423     vector<CScattererConnector*> clientToClientConnectors ; 
    1424     for(int i=0 ; i<elements.size() ; i++) 
    1425     { 
    1426       if (elements[i].type==TYPE_DOMAIN)  
    1427       {  
    1428          CDomain* domain = (CDomain*) elements[i].ptr ; 
    1429          sendAddDomain(domain->getId(),client) ; 
    1430          domain->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i)) ; 
    1431          clientToClientConnectors.push_back(domain->getClientToServerConnector(client)) ; 
    1432       } 
    1433       else if (elements[i].type==TYPE_AXIS) 
    1434       { 
    1435         CAxis* axis = (CAxis*) elements[i].ptr ; 
    1436         sendAddAxis(axis->getId(),client) ; 
    1437         axis->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i)) ; 
    1438         clientToClientConnectors.push_back(axis->getClientToServerConnector(client)) ; 
    1439       } 
    1440       else if (elements[i].type==TYPE_SCALAR) 
    1441       { 
    1442         CScalar* scalar = (CScalar*) elements[i].ptr ; 
    1443         sendAddScalar(scalar->getId(),client) ; 
    1444         scalar->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i)) ; 
    1445         clientToClientConnectors.push_back(scalar->getClientToServerConnector(client)) ; 
    1446       } 
    1447     } 
    1448      
    1449     // compute the grid clientToServerConnector to send flux from client to servers 
    1450     clientToClientConnector_[client] = new CGridScattererConnector(clientToClientConnectors) ;*/ 
    1451   } 
    1452  
    1453   void CGrid::makeAliasForCoupling(const string& fieldId) 
    1454   { 
    1455     string gridId="_grid_of_"+fieldId ; 
    1456     createAlias(gridId) ; 
    1457      
    1458     const auto& domVect = getDomains() ; 
    1459     for (int pos=0; pos<domVect.size();pos++) domVect[pos]->makeAliasForCoupling(fieldId, pos); 
    1460  
    1461     const auto& axisVect=getAxis() ; 
    1462     for (int pos=0; pos<axisVect.size();pos++) axisVect[pos]->makeAliasForCoupling(fieldId, pos); 
    1463  
    1464     const auto& scalVect=getScalars() ; 
    1465     for (int pos=0; pos<scalVect.size();pos++) scalVect[pos]->makeAliasForCoupling(fieldId, pos); 
     1411      if (elements[i].type==TYPE_DOMAIN) elements[i].domain->makeAliasForCoupling(fieldId, i); 
     1412      else if (elements[i].type==TYPE_AXIS) elements[i].axis->makeAliasForCoupling(fieldId, i); 
     1413      else if (elements[i].type==TYPE_SCALAR) elements[i].scalar->makeAliasForCoupling(fieldId, i); 
     1414    } 
    14661415  } 
    14671416 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.hpp

    r2011 r2022  
    174174      public: 
    175175         void makeAliasForCoupling(const string& fieldId) ; 
     176         string getCouplingAlias(const string& fieldId) ; 
    176177 
    177178      public: 
     
    341342 
    342343      public: //?  
    343         void distributeGridToFileServer(CContextClient* client); 
     344        void distributeGridToServer(CContextClient* client, const string& fieldId=""); 
    344345       
    345346             
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.cpp

    r1984 r2022  
    197197    else sendScalarToCouplerOut_done_.insert(client) ; 
    198198 
    199     string scalarId="_scalar["+std::to_string(posInGrid)+"]_of_"+fieldId ; 
     199    string scalarId = getCouplingAlias(fieldId, posInGrid) ; 
    200200 
    201201    this->sendAllAttributesToServer(client, scalarId); 
    202202  }   
    203203 
     204  string CScalar::getCouplingAlias(const string& fieldId, int posInGrid) 
     205  { 
     206    return "_scalar["+std::to_string(posInGrid)+"]_of_"+fieldId ; 
     207  } 
     208 
    204209  void CScalar::makeAliasForCoupling(const string& fieldId, int posInGrid) 
    205210  { 
    206     const string scalarId = "_scalar["+std::to_string(posInGrid)+"]_of_"+fieldId ; 
     211    const string scalarId = getCouplingAlias(fieldId, posInGrid) ; 
    207212    this->createAlias(scalarId) ; 
    208213  } 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.hpp

    r1984 r2022  
    9494    public: 
    9595      void makeAliasForCoupling(const string& fieldId, int posInGrid) ; 
     96      string getCouplingAlias(const string& fieldId, int posInGrid) ; 
    9697 
    9798      //////////////////////////////// 
Note: See TracChangeset for help on using the changeset viewer.