Ignore:
Timestamp:
08/24/21 13:48:12 (3 years ago)
Author:
ymipsl
Message:

New feature : when can now use the syntax :
fieldId:domainId[n], in domain reference inside the workflow (XML). Same for axis and scalar.

YM

File:
1 edited

Legend:

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

    r2203 r2206  
    400400  CATCH_DUMP_ATTR 
    401401 
    402   CDomain* CGrid::getAssociatedDomain(const string& domainId) 
     402  CDomain* CGrid::getAssociatedDomain(const string& domainId, bool noError) 
    403403  { 
    404404    const regex r("\\[[0-9]*\\]"); 
     
    413413    } 
    414414    std::vector<CDomain*> domainList = this->getDomains(); 
    415     if (domainList.empty()) ERROR("CGrid::getAssociatedDomain(const string& domainId)", <<"no domain is compsing the grid"); 
     415    if (domainList.empty())  
     416      if (noError) return nullptr ; 
     417      else ERROR("CGrid::getAssociatedDomain(const string& domainId)", <<"no domain is composing the grid"); 
    416418    if (id.empty()) 
    417419    { 
     
    419421      { 
    420422        if (domainList.size()==1) return domainList[0] ; 
    421         else ERROR("CGrid::getAssociatedDomain(const string& domainId)", <<"the grid contain more than 1 domain, use [#n] to specify which one must be retrieved"); 
     423        else  
     424          if (noError) return nullptr ; 
     425          else ERROR("CGrid::getAssociatedDomain(const string& domainId)", <<"the grid contain more than 1 domain, use [#n] to specify which one must be retrieved"); 
    422426      } 
    423427      else 
    424428      { 
    425429        if (domainList.size()>pos) return domainList[pos] ; 
     430        else if (noError) return nullptr ; 
    426431        else ERROR("CGrid::getAssociatedDomain(const string& domainId)", <<"the position of the requested domain [ pos = "<<pos 
    427432                   <<" ] is greater than the number of domain composing the grid  [ numDomain = "<<domainList.size()<<" ]"); 
     
    434439        int nbDomain=0 ; 
    435440        for(int i=0; i<domainList.size();i++) if (domainList[i]->getTemplateId()==id) nbDomain++ ; 
    436         if (nbDomain>1) ERROR("CGrid::getAssociatedDomain(const string& domainId)", <<"no domain with the id = "<<id 
     441        if (nbDomain>1)  
     442          if (noError) return nullptr ; 
     443          else ERROR("CGrid::getAssociatedDomain(const string& domainId)", <<"no domain with the id = "<<id 
    437444                              <<" is composing the grid") ; 
    438         if (nbDomain==0) ERROR("CGrid::getAssociatedDomain(const string& domainId)", <<"the grid contain more than 1 domain with the id = " 
     445        if (nbDomain==0)  
     446          if (noError) return nullptr ; 
     447          else ERROR("CGrid::getAssociatedDomain(const string& domainId)", <<"the grid contain more than 1 domain with the id = " 
    439448                               <<id<<" , use [#n] to specify which one must be retrieved") ; 
    440449        for(int i=0; i<domainList.size();i++) if (domainList[i]->getTemplateId()==id) return domainList[i]  ; 
     
    448457          currentPos++ ; 
    449458        } 
    450         ERROR("CGrid::getAssociatedDomain(const string& domainId)",<<"Cannot find domain with [ id = "<< id <<" ] at [ pos = "<<pos<<" ] in the grid"); 
     459        if (noError) return nullptr ;  
     460        else ERROR("CGrid::getAssociatedDomain(const string& domainId)",<<"Cannot find domain with [ id = "<< id <<" ] at [ pos = "<<pos<<" ] in the grid"); 
    451461      }   
    452462    } 
    453463  }  
    454464 
    455   CAxis* CGrid::getAssociatedAxis(const string& axisId) 
     465  CAxis* CGrid::getAssociatedAxis(const string& axisId, bool noError) 
    456466  { 
    457467    const regex r("\\[[0-9]*\\]"); 
     
    466476    } 
    467477    std::vector<CAxis*> axisList = this->getAxis(); 
    468     if (axisList.empty()) ERROR("CGrid::getAssociatedAxis(const string& AxisId)", <<"no axis is composing the grid"); 
     478    if (axisList.empty()) 
     479      if (noError) return nullptr; 
     480      else ERROR("CGrid::getAssociatedAxis(const string& AxisId)", <<"no axis is composing the grid"); 
    469481    if (id.empty()) 
    470482    { 
     
    472484      { 
    473485        if (axisList.size()==1) return axisList[0] ; 
    474         else ERROR("CGrid::getAssociatedAxis(const string& axisId)", <<"the grid contain more than 1 axis, use [#n] to specify which one must be retrieved"); 
     486        else  
     487          if (noError) return nullptr; 
     488          else ERROR("CGrid::getAssociatedAxis(const string& axisId)", <<"the grid contain more than 1 axis, use [#n] to specify which one must be retrieved"); 
    475489      } 
    476490      else 
    477491      { 
    478492        if (axisList.size()>pos) return axisList[pos] ; 
    479         else ERROR("CGrid::getAssociatedAxis(const string& axisId)", <<"the position of the requested axis [ pos = "<<pos 
     493        else 
     494          if (noError) return nullptr; 
     495          else ERROR("CGrid::getAssociatedAxis(const string& axisId)", <<"the position of the requested axis [ pos = "<<pos 
    480496                   <<" ] is greater than the number of axis composing the grid  [ numAxis = "<<axisList.size()<<" ]"); 
    481497      } 
     
    487503        int nbAxis=0 ; 
    488504        for(int i=0; i<axisList.size();i++) if (axisList[i]->getTemplateId()==id) nbAxis++ ; 
    489         if (nbAxis>1) ERROR("CGrid::getAssociatedAxis(const string& axisId)", <<"no axis with the id = "<<id 
     505        if (nbAxis>1)  
     506          if (noError) return nullptr; 
     507          else ERROR("CGrid::getAssociatedAxis(const string& axisId)", <<"no axis with the id = "<<id 
    490508                              <<" is composing the grid") ; 
    491         if (nbAxis==0) ERROR("CGrid::getAssociatedAxis(const string& axisId)", <<"the grid contain more than 1 axis with the id = " 
     509        if (nbAxis==0)  
     510          if (noError) return nullptr; 
     511          else ERROR("CGrid::getAssociatedAxis(const string& axisId)", <<"the grid contain more than 1 axis with the id = " 
    492512                               <<id<<" , use [#n] to specify which one must be retrieved") ; 
    493513        for(int i=0; i<axisList.size();i++) if (axisList[i]->getTemplateId()==id) return axisList[i]  ; 
     
    501521          currentPos++ ; 
    502522        } 
    503         ERROR("CGrid::getAssociatedAxis(const string& axisId)",<<"Cannot find axis with [ id = "<< id <<" ] at [ pos = "<<pos<<" ] in the grid"); 
     523        if (noError) return nullptr; 
     524        else ERROR("CGrid::getAssociatedAxis(const string& axisId)",<<"Cannot find axis with [ id = "<< id <<" ] at [ pos = "<<pos<<" ] in the grid"); 
    504525      }   
    505526    } 
    506527  }  
    507528 
    508   CScalar* CGrid::getAssociatedScalar(const string& scalarId) 
     529  CScalar* CGrid::getAssociatedScalar(const string& scalarId, bool noError) 
    509530  { 
    510531    const regex r("\\[[0-9]*\\]"); 
     
    519540    } 
    520541    std::vector<CScalar*> scalarList = this->getScalars(); 
    521     if (scalarList.empty()) ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"no scalar is composing the grid"); 
     542    if (scalarList.empty())  
     543      if (noError) return nullptr; 
     544      else ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"no scalar is composing the grid"); 
    522545    if (id.empty()) 
    523546    { 
     
    525548      { 
    526549        if (scalarList.size()==1) return scalarList[0] ; 
    527         else ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"the grid contain more than 1 scalar, use [#n] to specify which one must be retrieved"); 
     550        else  
     551          if (noError) return nullptr; 
     552          else ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"the grid contain more than 1 scalar, use [#n] to specify which one must be retrieved"); 
    528553      } 
    529554      else 
    530555      { 
    531556        if (scalarList.size()>pos) return scalarList[pos] ; 
    532         else ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"the position of the requested scalar [ pos = "<<pos 
     557        else  
     558          if (noError) return nullptr; 
     559          else ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"the position of the requested scalar [ pos = "<<pos 
    533560                   <<" ] is greater than the number of scalar composing the grid  [ numScalar = "<<scalarList.size()<<" ]"); 
    534561      } 
     
    540567        int nbScalar=0 ; 
    541568        for(int i=0; i<scalarList.size();i++) if (scalarList[i]->getTemplateId()==id) nbScalar++ ; 
    542         if (nbScalar>1) ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"no scalar with the id = "<<id 
     569        if (nbScalar>1)  
     570          if (noError) return nullptr; 
     571          else ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"no scalar with the id = "<<id 
    543572                              <<" is composing the grid") ; 
    544         if (nbScalar==0) ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"the grid contain more than 1 scalar with the id = " 
     573        if (nbScalar==0)  
     574          if (noError) return nullptr; 
     575          else ERROR("CGrid::getAssociatedScalar(const string& scalarId)", <<"the grid contain more than 1 scalar with the id = " 
    545576                               <<id<<" , use [#n] to specify which one must be retrieved") ; 
    546577        for(int i=0; i<scalarList.size();i++) if (scalarList[i]->getTemplateId()==id) return scalarList[i]  ; 
     
    554585          currentPos++ ; 
    555586        } 
    556         ERROR("CGrid::getAssociatedScalar(const string& scalarId)",<<"Cannot find scalar with [ id = "<< id <<" ] at [ pos = "<<pos<<" ] in the grid"); 
     587        if (noError) return nullptr; 
     588        else ERROR("CGrid::getAssociatedScalar(const string& scalarId)",<<"Cannot find scalar with [ id = "<< id <<" ] at [ pos = "<<pos<<" ] in the grid"); 
    557589      }   
    558590    } 
     
    17741806      pScalar->solveInheritanceTransformation(); 
    17751807    } 
     1808  } 
     1809  CATCH_DUMP_ATTR 
     1810 
     1811  bool CGrid::activateFieldWorkflow(CGarbageCollector& gc) 
     1812  TRY 
     1813  { 
     1814    setDomainList(); 
     1815    for (auto domainId : domList_) 
     1816    { 
     1817      CDomain* pDom = CDomain::get(domainId); 
     1818      bool ret = pDom->activateFieldWorkflow(gc); 
     1819      if (!ret) return false ; 
     1820    } 
     1821 
     1822    setAxisList(); 
     1823    for (auto axisId : axisList_) 
     1824    { 
     1825      CAxis* pAxis = CAxis::get(axisId); 
     1826      bool ret = pAxis->activateFieldWorkflow(gc); 
     1827      if (!ret) return false ; 
     1828    } 
     1829 
     1830    setScalarList(); 
     1831    for (auto scalarId : scalarList_) 
     1832    { 
     1833      CScalar* pScalar = CScalar::get(scalarId); 
     1834      bool ret = pScalar->activateFieldWorkflow(gc); 
     1835      if (!ret) return false ; 
     1836    } 
     1837    return true ; 
    17761838  } 
    17771839  CATCH_DUMP_ATTR 
Note: See TracChangeset for help on using the changeset viewer.