Changeset 572 for XIOS/branchs/xios-1.0


Ignore:
Timestamp:
03/10/15 13:30:08 (9 years ago)
Author:
rlacroix
Message:

Fix: Make sure the grids are consistent when doing field operations.

Always treats internal grids as such to avoid errors when doing further operations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/branchs/xios-1.0/src/node/field_impl.hpp

    r501 r572  
    1616  void CField::setData(const CArray<double, N>& _data) 
    1717  { 
    18     if (hasInstantData)  
     18    if (hasInstantData) 
    1919    { 
    20       grid->inputField(_data, instantData);  
    21       for(list< pair<CField *,int> >::iterator it=fieldDependency.begin(); it!=fieldDependency.end(); ++it)  it->first->setSlot(it->second) ; 
     20      grid->inputField(_data, instantData); 
     21      for(list< pair<CField *,int> >::iterator it=fieldDependency.begin(); it!=fieldDependency.end(); ++it)  it->first->setSlot(it->second); 
    2222    } 
    23      
     23 
    2424    if (!hasExpression) 
    2525    { 
    2626      const std::vector<CField*>& refField=getAllReference(); 
    2727      std::vector<CField*>::const_iterator  it = refField.begin(), end = refField.end(); 
    28       
    29       for (; it != end; it++) (*it)->setData(_data) ; 
    30       if (hasOutputFile || hasFieldOut) updateData(_data) ; 
     28 
     29      for (; it != end; it++) (*it)->setData(_data); 
     30      if (hasOutputFile || hasFieldOut) updateData(_data); 
    3131    } 
    32       
    3332  } 
    3433 
    3534  void CField::setDataFromExpression(const CArray<double, 1>& _data) 
    3635  { 
    37     if (hasInstantData)  
     36    if (hasInstantData) 
    3837    { 
    39       instantData=_data;  
    40       for(list< pair<CField *,int> >::iterator it=fieldDependency.begin(); it!=fieldDependency.end(); ++it)  it->first->setSlot(it->second) ; 
     38      instantData=_data; 
     39      for(list< pair<CField *,int> >::iterator it=fieldDependency.begin(); it!=fieldDependency.end(); ++it)  it->first->setSlot(it->second); 
    4140    } 
    42      
     41 
    4342    if (!hasExpression) 
    4443    { 
    4544      const std::vector<CField*>& refField=getAllReference(); 
    4645      std::vector<CField*>::const_iterator  it = refField.begin(), end = refField.end(); 
    47       
    48       for (; it != end; it++) (*it)->setData(_data) ; 
    49       if (hasOutputFile || hasFieldOut) updateData(_data) ; 
     46 
     47      for (; it != end; it++) (*it)->setDataFromExpression(_data); 
     48      if (hasOutputFile || hasFieldOut) updateDataFromExpression(_data); 
    5049    } 
    51       
    5250  } 
    5351 
    5452   template <int N> 
    5553   bool CField::updateData(const CArray<double, N>& _data) 
    56    {         
     54   { 
    5755      CContext* context=CContext::getCurrent(); 
    5856      const CDate & currDate = context->getCalendar()->getCurrentDate(); 
    5957      const CDate opeDate      = *last_operation + freq_operation; 
    60       const CDate writeDate    = *last_Write     + freq_write;        
    61       bool doOperation, doWrite;  
     58      const CDate writeDate    = *last_Write     + freq_write; 
     59      bool doOperation, doWrite; 
    6260 
    63     
     61 
    6462      info(50) << "CField::updateData " << currDate <<  " : send data to " << this->getBaseFieldId() << std::endl; 
    6563      info(50) << "Next operation "  << opeDate<<std::endl; 
    6664 
    67       doOperation = (opeDate <= currDate) ; 
     65      doOperation = (opeDate <= currDate); 
    6866      if (isOnceOperation) 
    69         if (isFirstOperation) doOperation=true ; 
    70         else doOperation=false ; 
     67        if (isFirstOperation) doOperation=true; 
     68        else doOperation=false; 
    7169 
    7270      if (doOperation) 
     
    7674            this->data.resize(this->grid->storeIndex_client.numElements()); 
    7775         } 
    78              
    79          CArray<double,1> input(data.numElements()) ; 
    80          this->grid->inputField(_data, input);           
     76 
     77         CArray<double,1> input(data.numElements()); 
     78         this->grid->inputField(_data, input); 
    8179         (*this->foperation)(input); 
    82           
     80 
    8381         *last_operation = currDate; 
    84          info(50) << "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl;  
     82         info(50) << "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl; 
    8583      } 
    8684 
    87       doWrite = (writeDate < (currDate + freq_operation)) ; 
     85      doWrite = (writeDate < (currDate + freq_operation)); 
    8886      if (isOnceOperation) 
    89       {  
    90         if(isFirstOperation)  
     87      { 
     88        if(isFirstOperation) 
    9189        { 
    92           doWrite=true ; 
    93           isFirstOperation=false ; 
     90          doWrite=true; 
     91          isFirstOperation=false; 
    9492        } 
    95         else doWrite=false ; 
     93        else doWrite=false; 
    9694      } 
    97        
     95 
    9896      if (doWrite) 
    9997      { 
     
    103101         { 
    104102           info(50) << "(*last_Write = currDate) : " << *last_Write << " = " << currDate << std::endl; 
    105            CTimer::get("XIOS Send Data").resume() ; 
    106            sendUpdateData() ; 
    107            CTimer::get("XIOS Send Data").suspend() ; 
     103           CTimer::get("XIOS Send Data").resume(); 
     104           sendUpdateData(); 
     105           CTimer::get("XIOS Send Data").suspend(); 
    108106         } 
    109           
     107 
    110108         if (hasFieldOut) 
    111109         { 
    112            fieldOut->setDataFromExpression(data) ; 
     110           fieldOut->setDataFromExpression(data); 
    113111         } 
    114          return (true);         
     112         return (true); 
    115113      } 
    116114 
    117115      return (false); 
    118116   } 
    119     
     117 
    120118   bool CField::updateDataFromExpression(const CArray<double, 1>& _data) 
    121    {         
     119   { 
    122120      CContext* context=CContext::getCurrent(); 
    123121      const CDate & currDate = context->getCalendar()->getCurrentDate(); 
    124122      const CDate opeDate      = *last_operation + freq_operation; 
    125       const CDate writeDate    = *last_Write     + freq_write;        
    126       bool doOperation, doWrite;  
     123      const CDate writeDate    = *last_Write     + freq_write; 
     124      bool doOperation, doWrite; 
    127125 
    128     
     126 
    129127      info(50) << "CField::updateData " << currDate <<  " : send data to " << this->getBaseFieldId() << std::endl; 
    130128      info(50) << "Next operation "  << opeDate<<std::endl; 
    131129 
    132       doOperation = (opeDate <= currDate) ; 
     130      doOperation = (opeDate <= currDate); 
    133131      if (isOnceOperation) 
    134         if (isFirstOperation) doOperation=true ; 
    135         else doOperation=false ; 
     132        if (isFirstOperation) doOperation=true; 
     133        else doOperation=false; 
    136134 
    137135      if (doOperation) 
     
    141139            this->data.resize(this->grid->storeIndex_client.numElements()); 
    142140         } 
    143              
     141 
    144142        (*this->foperation)(_data); 
    145           
     143 
    146144         *last_operation = currDate; 
    147          info(50) << "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl;  
     145         info(50) << "(*last_operation = currDate) : " << *last_operation << " = " << currDate << std::endl; 
    148146      } 
    149147 
    150       doWrite = (writeDate < (currDate + freq_operation)) ; 
     148      doWrite = (writeDate < (currDate + freq_operation)); 
    151149      if (isOnceOperation) 
    152       {  
    153         if(isFirstOperation)  
     150      { 
     151        if(isFirstOperation) 
    154152        { 
    155           doWrite=true ; 
    156           isFirstOperation=false ; 
     153          doWrite=true; 
     154          isFirstOperation=false; 
    157155        } 
    158         else doWrite=false ; 
     156        else doWrite=false; 
    159157      } 
    160        
     158 
    161159      if (doWrite) 
    162160      { 
    163161         this->foperation->final(); 
    164162         *last_Write = writeDate; 
    165          info(50) << "(*last_Write = currDate) : " << *last_Write << " = " << currDate  << std::endl; 
    166          CTimer::get("XIOS Send Data").resume() ; 
    167          sendUpdateData() ; 
    168          CTimer::get("XIOS Send Data").suspend() ; 
    169          return (true);         
     163         if (hasOutputFile) 
     164         { 
     165           info(50) << "(*last_Write = currDate) : " << *last_Write << " = " << currDate << std::endl; 
     166           CTimer::get("XIOS Send Data").resume(); 
     167           sendUpdateData(); 
     168           CTimer::get("XIOS Send Data").suspend(); 
     169         } 
     170 
     171         if (hasFieldOut) 
     172         { 
     173           fieldOut->setDataFromExpression(data); 
     174         } 
     175         return (true); 
    170176      } 
    171177 
Note: See TracChangeset for help on using the changeset viewer.