Changeset 2206


Ignore:
Timestamp:
08/24/21 13:48:12 (3 months 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

Location:
XIOS/dev/dev_ym/XIOS_COUPLING/src/node
Files:
10 edited

Legend:

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

    r2203 r2206  
    221221   CATCH 
    222222 
    223    CAxis* CAxis::get(const string& id) 
     223   CAxis* CAxis::get(const string& id, bool noError) 
    224224   { 
    225225     const regex r("::"); 
     
    231231        if (fieldId.empty()) ERROR("CAxis* CAxis::get(string& id)", <<" id = "<<id<< "  -> bad format id, field name is empty"); 
    232232        string suffix=m.suffix() ; 
     233        if (!CField::has(fieldId))  
     234          if (noError)  return nullptr ; 
     235          else ERROR("CAxis* CAxis::get(string& id, bool noError)", <<" id = "<<id<< "  -> field Id : < "<<fieldId<<" > doesn't exist"); 
    233236        CField* field=CField::get(fieldId) ; 
    234         return field->getAssociatedAxis(suffix) ; 
     237        return field->getAssociatedAxis(suffix, noError) ; 
    235238     } 
    236      else return CObjectFactory::GetObject<CAxis>(id).get(); 
     239     { 
     240       if (noError) if(!CObjectFactory::HasObject<CAxis>(id)) return nullptr ; 
     241       return CObjectFactory::GetObject<CAxis>(id).get(); 
     242     } 
     243   } 
     244    
     245   bool CAxis::has(const string& id) 
     246   { 
     247     if (CAxis::get(id,true)==nullptr) return false ; 
     248     else return true ; 
     249   } 
     250    
     251   CField* CAxis::getFieldFromId(const string& id) 
     252   { 
     253     const regex r("::"); 
     254     smatch m; 
     255     if (regex_search(id, m, r)) 
     256     { 
     257        if (m.size()!=1) ERROR("CField* CAxis::getFieldFromId(const string& id)", <<" id = "<<id<< "  -> bad format id, separator :: append more than one time"); 
     258        string fieldId=m.prefix() ; 
     259        if (fieldId.empty()) ERROR("CField* CAxis::getFieldFromId(const string& id)", <<" id = "<<id<< "  -> bad format id, field name is empty"); 
     260        string suffix=m.suffix() ; 
     261        CField* field=CField::get(fieldId) ; 
     262        return field ; 
     263     } 
     264     else return nullptr; 
    237265   } 
    238266 
     
    635663  } 
    636664  CATCH_DUMP_ATTR 
     665 
     666  bool CAxis::activateFieldWorkflow(CGarbageCollector& gc) 
     667  TRY 
     668  { 
     669    if (!axis_ref.isEmpty()) 
     670    { 
     671      CField* field=getFieldFromId(axis_ref) ; 
     672      if (field!=nullptr) 
     673      { 
     674        bool ret = field->buildWorkflowGraph(gc) ; 
     675        if (!ret) return false ; // cannot build workflow graph at this state 
     676      } 
     677      else  
     678      { 
     679        CAxis* axis = get(axis_ref) ; 
     680        bool ret = axis->activateFieldWorkflow(gc) ; 
     681        if (!ret) return false ; // cannot build workflow graph at this state 
     682        axis_ref=axis->getId() ; // replace domain_ref by solved reference 
     683      } 
     684    } 
     685    activateFieldWorkflow_done_=true ; 
     686    return true ; 
     687  } 
     688  CATCH_DUMP_ATTR 
     689 
    637690 
    638691  void CAxis::setContextClient(CContextClient* contextClient) 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.hpp

    r2203 r2206  
    3232   class CAxisAttributes; 
    3333   class CAxis; 
     34   class CField; 
    3435 
    3536   ///-------------------------------------------------------------- 
     
    6970 
    7071         static CAxis* createAxis(); 
    71          static CAxis* get(const string& id) ; //<! return axis pointer using id 
     72         static CAxis* get(const string& id, bool noError=false) ; //<! return axis pointer using id 
     73         static bool has(const string& id) ; //<! return domain pointer using id 
     74         static CField*  getFieldFromId(const string& id) ; 
    7275 
    7376         /// Accesseurs /// 
     
    144147      private: 
    145148        bool solveInheritanceTransformation_done_= false ; 
     149      public: 
     150        bool activateFieldWorkflow(CGarbageCollector& gc) ; 
     151      private: 
     152        bool activateFieldWorkflow_done_=false ; 
    146153      private: 
    147154        CGenericAlgorithmTransformation* transformationAlgorithm_ = nullptr ; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.cpp

    r2203 r2206  
    7979   CATCH 
    8080 
    81    CDomain* CDomain::get(const string& id) 
     81   CDomain* CDomain::get(const string& id, bool noError) 
    8282   { 
    8383     const regex r("::"); 
     
    8989        if (fieldId.empty()) ERROR("CDomain* CDomain::get(string& id)", <<" id = "<<id<< "  -> bad format id, field name is empty"); 
    9090        string suffix=m.suffix() ; 
     91        if (!CField::has(fieldId))  
     92          if (noError)  return nullptr ; 
     93          else ERROR("CDomain* CDomain::get(string& id)", <<" id = "<<id<< "  -> field Id : < "<<fieldId<<" > doesn't exist"); 
    9194        CField* field=CField::get(fieldId) ; 
    92         return field->getAssociatedDomain(suffix) ; 
    93      } 
    94      else return CObjectFactory::GetObject<CDomain>(id).get(); 
    95    } 
    96  
     95        return field->getAssociatedDomain(suffix, noError) ; 
     96     } 
     97     else  
     98     { 
     99       if (noError) if(!CObjectFactory::HasObject<CDomain>(id)) return nullptr ; 
     100       return CObjectFactory::GetObject<CDomain>(id).get(); 
     101     } 
     102   } 
     103 
     104   bool CDomain::has(const string& id) 
     105   { 
     106     if (CDomain::get(id,true)==nullptr) return false ; 
     107     else return true ; 
     108   } 
     109    
     110   CField* CDomain::getFieldFromId(const string& id) 
     111   { 
     112     const regex r("::"); 
     113     smatch m; 
     114     if (regex_search(id, m, r)) 
     115     { 
     116        if (m.size()!=1) ERROR("CField* CDomain::getFieldFromId(const string& id)", <<" id = "<<id<< "  -> bad format id, separator :: append more than one time"); 
     117        string fieldId=m.prefix() ; 
     118        if (fieldId.empty()) ERROR("CField* CDomain::getFieldFromId(const string& id)", <<" id = "<<id<< "  -> bad format id, field name is empty"); 
     119        string suffix=m.suffix() ; 
     120        CField* field=CField::get(fieldId) ; 
     121        return field ; 
     122     } 
     123     else return nullptr; 
     124   } 
    97125 
    98126   const std::set<StdString> & CDomain::getRelFiles(void) const 
     
    23372365  CATCH_DUMP_ATTR 
    23382366   
     2367 
     2368  bool CDomain::activateFieldWorkflow(CGarbageCollector& gc) 
     2369  TRY 
     2370  { 
     2371    if (!domain_ref.isEmpty()) 
     2372    { 
     2373      CField* field=getFieldFromId(domain_ref) ; 
     2374      if (field!=nullptr) 
     2375      { 
     2376        bool ret = field->buildWorkflowGraph(gc) ; 
     2377        if (!ret) return false ; // cannot build workflow graph at this state 
     2378      } 
     2379      else  
     2380      { 
     2381        CDomain* domain = get(domain_ref) ; 
     2382        bool ret = domain->activateFieldWorkflow(gc) ; 
     2383        if (!ret) return false ; // cannot build workflow graph at this state 
     2384        domain_ref=domain->getId() ; // replace domain_ref by solved reference 
     2385      } 
     2386    } 
     2387    activateFieldWorkflow_done_=true ; 
     2388    return true ; 
     2389  } 
     2390  CATCH_DUMP_ATTR 
    23392391///////////////////////////////////////////////////////////////////////////////////////////// 
    23402392/////////////////////////////////////////////////////////////////////////////////////////////  
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.hpp

    r2203 r2206  
    3636   class CDomain; 
    3737   class CFile; 
     38   class CField ; 
    3839 
    3940   ///-------------------------------------------------------------- 
     
    7273        
    7374         static CDomain* createDomain(); 
    74          static CDomain* get(const string& id) ; //<! return domain pointer using id 
    75         // static bool has(const string& id) ;     //<! return true if domain with identifier id exist 
     75         static CDomain* get(const string& id, bool noError=false) ; //<! return domain pointer using id 
     76         static bool has(const string& id) ; //<! return domain pointer using id 
     77         static CField*  getFieldFromId(const string& id) ; 
    7678 
    7779         CMesh* mesh; 
     
    109111      private: 
    110112        bool solveInheritanceTransformation_done_= false ; 
     113      public: 
     114        bool activateFieldWorkflow(CGarbageCollector& gc) ; 
     115      private: 
     116        bool activateFieldWorkflow_done_=false ; 
     117 
    111118      private: 
    112119        CGenericAlgorithmTransformation* transformationAlgorithm_ = nullptr ; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp

    r2203 r2206  
    327327  CATCH 
    328328 
    329   CDomain* CField::getAssociatedDomain(const string& domainId) const 
    330   { 
    331     if (grid_==nullptr) ERROR("CDomain* CField::getAssociatedDomain(const string& domainId)", <<" field with id="<<getId()<<" has no associated grid, " 
     329  CDomain* CField::getAssociatedDomain(const string& domainId, bool noError) const 
     330  { 
     331    if (grid_==nullptr) 
     332    {  
     333      if (noError) return nullptr ; 
     334      else ERROR("CDomain* CField::getAssociatedDomain(const string& domainId)", <<" field with id="<<getId()<<" has no associated grid, " 
    332335                              <<"check if the worklfow is enabled for this field"); 
    333     grid_->getAssociatedDomain(domainId) ; 
    334   } 
    335  
    336   CAxis* CField::getAssociatedAxis(const string& axisId) const 
    337   { 
    338     if (grid_==nullptr) ERROR("CAxis* CField::getAssociatedAxis(const string& axisId)", <<" field with id="<<getId()<<" has no associated grid, " 
     336    } 
     337    return grid_->getAssociatedDomain(domainId, noError) ; 
     338  } 
     339 
     340  CAxis* CField::getAssociatedAxis(const string& axisId, bool noError) const 
     341  { 
     342    if (grid_==nullptr)  
     343    { 
     344      if (noError) return nullptr ; 
     345      else  ERROR("CAxis* CField::getAssociatedAxis(const string& axisId)", <<" field with id="<<getId()<<" has no associated grid, " 
    339346                              <<"check if the worklfow is enabled for this field"); 
    340     grid_->getAssociatedAxis(axisId) ; 
    341   } 
    342  
    343   CScalar* CField::getAssociatedScalar(const string& scalarId) const 
    344   { 
    345     if (grid_==nullptr) ERROR("CScalar* CField::getAssociatedScalar(const string& scalarId)", <<" field with id="<<getId()<<" has no associated grid, " 
     347    } 
     348    return grid_->getAssociatedAxis(axisId, noError) ; 
     349  } 
     350 
     351  CScalar* CField::getAssociatedScalar(const string& scalarId, bool noError) const 
     352  { 
     353    if (grid_==nullptr)  
     354    {  
     355      if (noError) return nullptr ; 
     356      else ERROR("CScalar* CField::getAssociatedScalar(const string& scalarId)", <<" field with id="<<getId()<<" has no associated grid, " 
    346357                              <<"check if the worklfow is enabled for this field"); 
    347     grid_->getAssociatedScalar(scalarId) ; 
     358    } 
     359    return grid_->getAssociatedScalar(scalarId, noError) ; 
    348360  } 
    349361 
     
    618630    solveGridReference() ; // grid_ is now defined 
    619631    if (!isGridCompleted()) return false; 
     632    if (grid_->activateFieldWorkflow(gc)==false) return false; // workflow graph cannot be built at this stage 
    620633 
    621634    // Check if we have an expression to parse 
     
    11811194      if (!domain_ref.isEmpty()) 
    11821195      { 
    1183         StdString tmp = domain_ref.getValue(); 
     1196        CField* field=CDomain::getFieldFromId(domain_ref) ; 
     1197        if (field!=nullptr) field->solveGridReference() ; 
    11841198        if (CDomain::has(domain_ref)) 
    11851199        { 
     
    11951209      if (!axis_ref.isEmpty()) 
    11961210      { 
     1211        CField* field=CAxis::getFieldFromId(axis_ref) ; 
     1212        if (field!=nullptr) field->solveGridReference() ; 
    11971213        if (CAxis::has(axis_ref)) 
    11981214        { 
     
    12081224      if (!scalar_ref.isEmpty()) 
    12091225      { 
     1226        CField* field=CScalar::getFieldFromId(scalar_ref) ; 
     1227        if (field!=nullptr) field->solveGridReference() ; 
    12101228        if (CScalar::has(scalar_ref)) 
    12111229        { 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.hpp

    r2203 r2206  
    104104         CGrid* getRelGrid(void) const; 
    105105         CFile* getRelFile(void) const; 
    106          CDomain* getAssociatedDomain(const std::string& domainId) const; 
    107          CAxis*   getAssociatedAxis(const std::string& axisId) const; 
    108          CScalar* getAssociatedScalar(const std::string& scalarId) const; 
     106         CDomain* getAssociatedDomain(const std::string& domainId, bool noError=false) const; 
     107         CAxis*   getAssociatedAxis(const std::string& axisId, bool noError=false) const; 
     108         CScalar* getAssociatedScalar(const std::string& scalarId, bool noError=false) const; 
    109109 
    110110         func::CFunctor::ETimeType getOperationTimeType() const; 
  • 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 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.hpp

    r2203 r2206  
    147147         static CGrid* cloneGrid(const StdString& idNewGrid, CGrid* gridSrc); 
    148148 
    149          CDomain* getAssociatedDomain(const string& domainId) ; 
    150          CAxis*   getAssociatedAxis(const string& axisId) ; 
    151          CScalar* getAssociatedScalar(const string& scalarId) ; 
     149         CDomain* getAssociatedDomain(const string& domainId, bool noError=false) ; 
     150         CAxis*   getAssociatedAxis(const string& axisId, bool noError=false) ; 
     151         CScalar* getAssociatedScalar(const string& scalarId, bool noError=false) ; 
    152152      public:             
    153153         void solveDomainAxisRef(bool areAttributesChecked); 
     
    158158         void solveScalarRef(bool checkAtt); 
    159159         void solveElementsRefInheritance(bool apply = true); 
     160         bool activateFieldWorkflow(CGarbageCollector& gc) ; 
    160161        // void solveTransformations(); 
    161162         void solveDomainAxisBaseRef(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.cpp

    r2203 r2206  
    5353  } 
    5454 
    55   CScalar* CScalar::get(const string& id) 
     55  CScalar* CScalar::get(const string& id, bool noError) 
    5656  { 
    5757    const regex r("::"); 
     
    6363      if (fieldId.empty()) ERROR("CScalar* CScalar::get(string& id)", <<" id = "<<id<< "  -> bad format id, field name is empty"); 
    6464      string suffix=m.suffix() ; 
     65      if (!CField::has(fieldId))  
     66          if (noError)  return nullptr ; 
     67          else ERROR("CScalar* CScalar::get(const string& id, bool noError)", <<" id = "<<id<< "  -> field Id : < "<<fieldId<<" > doesn't exist"); 
    6568      CField* field=CField::get(fieldId) ; 
    66       return field->getAssociatedScalar(suffix) ; 
    67     } 
    68     else return CObjectFactory::GetObject<CScalar>(id).get(); 
    69   } 
     69      return field->getAssociatedScalar(suffix, noError) ; 
     70    } 
     71    else 
     72    { 
     73       if (noError) if(!CObjectFactory::HasObject<CScalar>(id)) return nullptr ; 
     74       return CObjectFactory::GetObject<CScalar>(id).get(); 
     75     } 
     76   } 
     77 
     78   bool CScalar::has(const string& id) 
     79   { 
     80     if (CScalar::get(id,true)==nullptr) return false ; 
     81     else return true ; 
     82   } 
     83    
     84   CField* CScalar::getFieldFromId(const string& id) 
     85   { 
     86     const regex r("::"); 
     87     smatch m; 
     88     if (regex_search(id, m, r)) 
     89     { 
     90        if (m.size()!=1) ERROR("CField* CScalar::getFieldFromId(const string& id)", <<" id = "<<id<< "  -> bad format id, separator :: append more than one time"); 
     91        string fieldId=m.prefix() ; 
     92        if (fieldId.empty()) ERROR("CField* CScalar::getFieldFromId(const string& id)", <<" id = "<<id<< "  -> bad format id, field name is empty"); 
     93        string suffix=m.suffix() ; 
     94        CField* field=CField::get(fieldId) ; 
     95        return field ; 
     96     } 
     97     else return nullptr; 
     98   } 
    7099 
    71100  bool CScalar::IsWritten(const StdString & filename) const 
     
    210239  } 
    211240  CATCH_DUMP_ATTR 
     241 
     242  bool CScalar::activateFieldWorkflow(CGarbageCollector& gc) 
     243  TRY 
     244  { 
     245    if (!scalar_ref.isEmpty()) 
     246    { 
     247      CField* field=getFieldFromId(scalar_ref) ; 
     248      if (field!=nullptr) 
     249      { 
     250        bool ret = field->buildWorkflowGraph(gc) ; 
     251        if (!ret) return false ; // cannot build workflow graph at this state 
     252      } 
     253      else  
     254      { 
     255        CScalar* scalar = get(scalar_ref) ; 
     256        bool ret = scalar->activateFieldWorkflow(gc) ; 
     257        if (!ret) return false ; // cannot build workflow graph at this state 
     258        scalar_ref=scalar->getId() ; // replace domain_ref by solved reference 
     259      } 
     260    } 
     261    activateFieldWorkflow_done_=true ; 
     262    return true ; 
     263  } 
     264  CATCH_DUMP_ATTR 
     265 
    212266 
    213267  /* obsolete, to remove after reimplementing coupling */ 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.hpp

    r2203 r2206  
    2929  class CScalarAttributes; 
    3030  class CScalar; 
     31  class CField; 
    3132  ///-------------------------------------------------------------- 
    3233 
     
    7879    public: 
    7980      static CScalar* createScalar(); 
    80       static CScalar* get(const string& id) ; //<! return scalar pointer using id 
     81      static CScalar* get(const string& id, bool noError=false) ; //<! return scalar pointer using id 
     82      static bool     has(const string& id) ; //<! return domain pointer using id 
     83      static CField*  getFieldFromId(const string& id) ; 
    8184 
    8285    public: 
     
    118121      private: 
    119122        bool solveInheritanceTransformation_done_= false ; 
     123      public: 
     124        bool activateFieldWorkflow(CGarbageCollector& gc) ; 
     125      private: 
     126        bool activateFieldWorkflow_done_=false ; 
    120127      private: 
    121128        CGenericAlgorithmTransformation* transformationAlgorithm_ = nullptr ; 
Note: See TracChangeset for help on using the changeset viewer.