Ignore:
Timestamp:
10/27/16 18:14:46 (8 years ago)
Author:
mhnguyen
Message:

Implementing domain interpolation weights exportation
The option 'file' locates file to read if it exists, otherwise a new file with name = 'file' will be created

+) Write interpolation weights into a file

Test
+) On Curie
+) Work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/interpolate_domain.cpp

    r836 r982  
    4747             << "Please define a correct one") ; 
    4848    } 
     49 
     50    StdString weightFile = "interpolation_weights_" + domainSrc->getDomainOutputName(); 
     51 
     52    if (!this->mode.isEmpty()) 
     53    {  
     54      if (mode_attr::read == this->mode) 
     55      { 
     56         if (this->file.isEmpty()) 
     57         { 
     58            ERROR("void CInterpolateDomain::checkValid(CDomain* domainSrc)", 
     59                 << "Read mode is activated but there is no file specified." << std::endl 
     60                 << "Please define a correct file containing interpolation weights with option 'file'. "); 
     61         } 
     62         else 
     63         { 
     64           weightFile = this->file; 
     65           ifstream f(weightFile.c_str()); 
     66           if (!f.good()) 
     67             ERROR("void CInterpolateDomain::checkValid(CDomain* domainSrc)", 
     68                   << "Read mode is activated but file "  << weightFile << " doesn't exist." << std::endl 
     69                   << "Please check this file "); 
     70         } 
     71      } 
     72      else 
     73      { 
     74        if (file.isEmpty()) 
     75          this->file.setValue(weightFile); 
     76      }    
     77    } 
     78    else 
     79    { 
     80      if (!file.isEmpty()) // set mode read 
     81      { 
     82         weightFile = this->file; 
     83         ifstream f(weightFile.c_str()); 
     84         if (!f.good()) // file doesn't exist 
     85           this->mode.setValue(mode_attr::write); 
     86         else 
     87           this->mode.setValue(mode_attr::read); 
     88      } 
     89      else // only calculate weights() Mode set write but there is no file) 
     90      { 
     91        this->mode.setValue(mode_attr::write); 
     92      } 
     93    } 
     94 
    4995  } 
    5096 
Note: See TracChangeset for help on using the changeset viewer.