Changeset 2311


Ignore:
Timestamp:
03/15/22 19:00:58 (2 years ago)
Author:
ymipsl
Message:

Add possibility to refer to a grid using the field which is attached to, using notation : "fieldId::"

YM

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

Legend:

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

    r2302 r2311  
    365365    else if (hasFileOut()) return this->fileOut_ ; 
    366366    else return nullptr ; 
     367  } 
     368  CATCH 
     369 
     370  CGrid* CField::getAssociatedGrid(void) const 
     371  TRY 
     372  { 
     373    return this->grid_; 
    367374  } 
    368375  CATCH 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.hpp

    r2230 r2311  
    104104         CGrid* getRelGrid(void) const; 
    105105         CFile* getRelFile(void) const; 
     106         CGrid* getAssociatedGrid(void) const ; 
    106107         CDomain* getAssociatedDomain(const std::string& domainId, bool noError=false) const; 
    107108         CAxis*   getAssociatedAxis(const std::string& axisId, bool noError=false) const; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp

    r2305 r2311  
    182182   } 
    183183   CATCH 
     184 
     185 
     186   CGrid* CGrid::get(const string& id, bool noError) 
     187   { 
     188     const regex r("::"); 
     189     smatch m; 
     190     if (regex_search(id, m, r)) 
     191     { 
     192        if (m.size()!=1) ERROR("CGrid* Cgrid::get(string& id)", <<" id = "<<id<< "  -> bad format id, separator :: append more than one time"); 
     193        string fieldId=m.prefix() ; 
     194        if (fieldId.empty()) ERROR("CGrid* CGrid::get(string& id)", <<" id = "<<id<< "  -> bad format id, field name is empty"); 
     195        string suffix=m.suffix() ; 
     196        if (!suffix.empty()) ERROR("CGrid* CGrid::get(string& id)", <<" id = "<<id<< "  -> bad format id, suffix is not empty"); 
     197        if (!CField::has(fieldId))  
     198          if (noError)  return nullptr ; 
     199          else ERROR("CGrid* CGrid::get(string& id)", <<" id = "<<id<< "  -> field Id : < "<<fieldId<<" > doesn't exist"); 
     200        CField* field=CField::get(fieldId) ; 
     201        return field->getAssociatedGrid() ; 
     202     } 
     203     else  
     204     { 
     205       if (noError) if(!CObjectFactory::HasObject<CGrid>(id)) return nullptr ; 
     206       return CObjectFactory::GetObject<CGrid>(id).get(); 
     207     } 
     208   } 
     209    
     210   bool CGrid::has(const string& id) 
     211   { 
     212     if (CGrid::get(id,true)==nullptr) return false ; 
     213     else return true ; 
     214   } 
    184215 
    185216   //---------------------------------------------------------------- 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.hpp

    r2270 r2311  
    142142         static CGrid* createGrid(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, 
    143143                                  const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder); 
     144         static CGrid* get(const string& id, bool noError=false) ; //<! return grid pointer using id 
     145         static bool has(const string& id) ; //<! return if grid exist using id 
    144146         static StdString generateId(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, 
    145147                                     const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder = CArray<int,1>()); 
Note: See TracChangeset for help on using the changeset viewer.