Changeset 873


Ignore:
Timestamp:
06/14/16 16:28:07 (5 years ago)
Author:
mhnguyen
Message:

Masked interpolated points will have default_value (if defined)

+) Default value is used to initialize spatial transform filter
+) Add a new case for testing masked points

Test
+) On Curie
+) All interpolation tests work

Location:
XIOS/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/inputs/REMAP/iodef.xml

    r871 r873  
    55   <calendar type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-28 15:00:00 + 1d" /> 
    66   <field_definition level="1" > 
    7      <field id="src_field" operation="instant" domain_ref="src_domain"/> 
     7     <field id="src_field" operation="instant" domain_ref="src_domain_clone"/> 
    88     <field id="src_field_3D" operation="instant" domain_ref="src_domain" axis_ref="src_axis"/> 
    99     <field id="src_field_3D_interp" operation="instant" field_ref="src_field_3D" axis_ref="dst_axis"/> 
     
    2424   <file_definition type="one_file" par_access="collective" output_freq="1ts" output_level="10" enabled=".TRUE."> 
    2525     <file id="output" name="output"> 
    26 <!--        <field field_ref="src_field" name="field" />--> 
     26        <field field_ref="src_field" name="field" /> 
    2727     </file> 
    28      <file id="output_3D" name="output_3D"> 
    29         <field field_ref="src_field_3D" name="field" /> 
     28     <file id="output_2D" name="output_2D"> 
     29        <field field_ref="src_field" name="field"  domain_ref="dst_domain_regular_pole" default_value="10.e+5"/> 
    3030     </file> 
    3131    <file id="output_3D_pression" name="output_3D_pression"> 
  • XIOS/trunk/src/filter/spatial_transform_filter.cpp

    r842 r873  
    66namespace xios 
    77{ 
    8   CSpatialTransformFilter::CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, size_t inputSlotsCount) 
    9     : CFilter(gc, inputSlotsCount, engine) 
     8  CSpatialTransformFilter::CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, double outputValue, size_t inputSlotsCount) 
     9    : CFilter(gc, inputSlotsCount, engine), outputDefaultValue(outputValue) 
    1010  { /* Nothing to do */ } 
    1111 
    1212  std::pair<boost::shared_ptr<CSpatialTransformFilter>, boost::shared_ptr<CSpatialTransformFilter> > 
    13   CSpatialTransformFilter::buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid) 
     13  CSpatialTransformFilter::buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, double defaultValue) 
    1414  { 
    1515    if (!srcGrid || !destGrid) 
     
    2626      const std::vector<StdString>& auxInputs = gridTransformation->getAuxInputs(); 
    2727      size_t inputCount = 1 + (auxInputs.empty() ? 0 : auxInputs.size()); 
    28       boost::shared_ptr<CSpatialTransformFilter> filter(new CSpatialTransformFilter(gc, engine, inputCount)); 
     28      boost::shared_ptr<CSpatialTransformFilter> filter(new CSpatialTransformFilter(gc, engine, defaultValue, inputCount)); 
    2929 
    3030      if (!lastFilter) 
     
    4848  } 
    4949 
     50  void CSpatialTransformFilter::onInputReady(std::vector<CDataPacketPtr> data) 
     51  { 
     52    CSpatialTransformFilterEngine* spaceFilter = static_cast<CSpatialTransformFilterEngine*>(engine); 
     53    CDataPacketPtr outputPacket = spaceFilter->applyFilter(data, outputDefaultValue); 
     54    if (outputPacket) 
     55      deliverOuput(outputPacket); 
     56  } 
     57 
    5058  CSpatialTransformFilterEngine::CSpatialTransformFilterEngine(CGridTransformation* gridTransformation) 
    5159    : gridTransformation(gridTransformation) 
     
    7583 
    7684  CDataPacketPtr CSpatialTransformFilterEngine::apply(std::vector<CDataPacketPtr> data) 
     85  { 
     86    /* Nothing to do */ 
     87  } 
     88 
     89  CDataPacketPtr CSpatialTransformFilterEngine::applyFilter(std::vector<CDataPacketPtr> data, double defaultValue) 
    7790  { 
    7891    CDataPacketPtr packet(new CDataPacket); 
     
    90103      } 
    91104      packet->data.resize(gridTransformation->getGridDestination()->storeIndex_client.numElements()); 
     105      packet->data = defaultValue; 
    92106      apply(data[0]->data, packet->data); 
    93107    } 
     
    99113  { 
    100114    CContextClient* client = CContext::getCurrent()->client; 
     115 
     116    // Get default value for output data 
     117    double defaultValue = 0.0; 
     118    if (0 != dataDest.numElements()) defaultValue = dataDest(0); 
    101119 
    102120    const std::list<CGridTransformation::SendingIndexGridSourceMap>& listLocalIndexSend = gridTransformation->getLocalIndexToSendFromGridSource(); 
    103121    const std::list<CGridTransformation::RecvIndexGridDestinationMap>& listLocalIndexToReceive = gridTransformation->getLocalIndexToReceiveOnGridDest(); 
    104122    const std::list<size_t>& listNbLocalIndexToReceive = gridTransformation->getNbLocalIndexToReceiveOnGridDest(); 
     123    const std::list<std::vector<bool> >& listLocalIndexMaskOnDest = gridTransformation->getLocalMaskIndexOnGridDest(); 
    105124 
    106125    CArray<double,1> dataCurrentDest(dataSrc.copy()); 
     
    110129    std::list<CGridTransformation::RecvIndexGridDestinationMap>::const_iterator itListRecv = listLocalIndexToReceive.begin(); 
    111130    std::list<size_t>::const_iterator itNbListRecv = listNbLocalIndexToReceive.begin(); 
    112  
    113     for (; itListSend != iteListSend; ++itListSend, ++itListRecv, ++itNbListRecv) 
     131    std::list<std::vector<bool> >::const_iterator itLocalMaskIndexOnDest = listLocalIndexMaskOnDest.begin(); 
     132 
     133    for (; itListSend != iteListSend; ++itListSend, ++itListRecv, ++itNbListRecv, ++itLocalMaskIndexOnDest) 
    114134    { 
    115135      CArray<double,1> dataCurrentSrc(dataCurrentDest); 
     
    164184 
    165185      dataCurrentDest.resize(*itNbListRecv); 
    166       dataCurrentDest = 0.0; 
     186      const std::vector<bool>& localMaskDest = *itLocalMaskIndexOnDest; 
     187      for (int i = 0; i < localMaskDest.size(); ++i) 
     188        if (localMaskDest[i]) dataCurrentDest(i) = 0.0; 
     189        else dataCurrentDest(i) = defaultValue; 
     190 
    167191      currentBuff = 0; 
    168192      for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) 
  • XIOS/trunk/src/filter/spatial_transform_filter.hpp

    r827 r873  
    2121       * \param gc the associated garbage collector 
    2222       * \param engine the engine defining the spatial transformation 
     23       * \param outputValue default value of output pin 
    2324       * \param [in] inputSlotsCount number of input, by default there is only one for field src 
    2425       */ 
    25       CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, size_t inputSlotsCount = 1); 
     26      CSpatialTransformFilter(CGarbageCollector& gc, CSpatialTransformFilterEngine* engine, double outputValue, size_t inputSlotsCount = 1); 
    2627 
    2728      /*! 
     
    3435       */ 
    3536      static std::pair<boost::shared_ptr<CSpatialTransformFilter>, boost::shared_ptr<CSpatialTransformFilter> > 
    36       buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid); 
     37      buildFilterGraph(CGarbageCollector& gc, CGrid* srcGrid, CGrid* destGrid, double defaultValue); 
     38 
     39    protected: 
     40      /*! 
     41        Overriding this function to process transformations with auxillary inputs 
     42      */ 
     43      void virtual onInputReady(std::vector<CDataPacketPtr> data); 
     44 
     45    protected: 
     46      //! Default value of output pin 
     47      double outputDefaultValue; 
    3748  }; // class CSpatialTransformFilter 
    3849 
     
    5667       * 
    5768       * \param data a vector of packets corresponding to each slot (one in this case) 
     69       * \param [in] defaultValue default value of output data 
     70       * \return the result of the grid transformation 
     71       */ 
     72      CDataPacketPtr applyFilter(std::vector<CDataPacketPtr> data, double defaultValue = 0); 
     73 
     74       /*! 
     75       * Applies the grid transformation to the input data and returns the result. 
     76       * 
     77       * \param data a vector of packets corresponding to each slot (one in this case) 
    5878       * \return the result of the grid transformation 
    5979       */ 
    6080      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); 
     81 
     82 
    6183 
    6284    protected: 
  • XIOS/trunk/src/node/field.cpp

    r854 r873  
    289289      cout<<"file->output_freq.getValue() : "<<file->output_freq.getValue()<<endl ; 
    290290      cout<<"lastDataRequestedFromServer + file->output_freq.getValue() : "<<lastDataRequestedFromServer + file->output_freq.getValue()<<endl ; 
    291       
     291 
    292292      sendReadDataRequest(); 
    293293    } 
     
    346346          nstepMax = getRelFile()->getDataInput()->getFieldNbRecords(CField::get(this)); 
    347347        } 
    348          
     348 
    349349        this->incrementNStep(); 
    350350 
     
    780780     // Check if a spatial transformation is needed 
    781781     if (grid && grid != fieldRef->grid && grid->hasTransform()) 
    782        filters = CSpatialTransformFilter::buildFilterGraph(gc, fieldRef->grid, grid); 
     782     { 
     783       double defaultValue = 0.0; 
     784       if (!default_value.isEmpty()) defaultValue = this->default_value; 
     785       filters = CSpatialTransformFilter::buildFilterGraph(gc, fieldRef->grid, grid, defaultValue); 
     786     } 
     787 
    783788     else 
    784789       filters.first = filters.second = boost::shared_ptr<CFilter>(new CPassThroughFilter(gc)); 
  • XIOS/trunk/src/test/test_remap.f90

    r871 r873  
    2121  DOUBLE PRECISION,ALLOCATABLE :: src_boundslat(:,:), dst_boundslat(:,:) 
    2222  DOUBLE PRECISION,ALLOCATABLE :: src_field(:), tmp_field(:), tmp_field_1(:), tmp_field_2(:), src_field_3D(:,:), lval(:), lval1(:), src_field_pression(:,:) 
     23  LOGICAL,ALLOCATABLE :: src_mask_2D(:) 
    2324  INTEGER :: src_ni_glo, dst_ni_glo; 
    2425  INTEGER :: src_nvertex, dst_nvertex; 
     
    6768  ALLOCATE(src_field(src_ni)) 
    6869  ALLOCATE(src_field_3D(src_ni,llm)) 
     70  ALLOCATE(src_mask_2D(src_ni)) 
    6971  ALLOCATE(src_field_pression(src_ni,llm)) 
    7072  ALLOCATE(lval(llm)) 
     
    8385  DO i=1,src_ni 
    8486    src_field_3D(i,:) = src_field(i) 
     87    IF (MOD(i,10)==0) THEN 
     88      src_mask_2D(i)=.FALSE. 
     89    ELSE 
     90      src_mask_2D(i)=.TRUE. 
     91    ENDIF 
    8592  ENDDO 
    8693 
     
    136143  CALL xios_set_domain_attr("src_domain_clone", ni_glo=src_ni_glo, ibegin=src_ibegin, ni=src_ni, type="unstructured") 
    137144  CALL xios_set_domain_attr("src_domain_clone", lonvalue_1D=src_lon, latvalue_1D=src_lat, & 
    138                             bounds_lon_1D=src_boundslon, bounds_lat_1D=src_boundslat, nvertex=src_nvertex) 
     145                            bounds_lon_1D=src_boundslon, bounds_lat_1D=src_boundslat, nvertex=src_nvertex, & 
     146                            mask_1d=src_mask_2D) 
    139147 
    140148  CALL xios_set_axis_attr("src_axis", n_glo=llm, value=lval) 
  • XIOS/trunk/src/transformation/grid_transformation.cpp

    r872 r873  
    438438      std::list<RecvIndexGridDestinationMap>().swap(localIndexToReceiveOnGridDest_); 
    439439      std::list<size_t>().swap(nbLocalIndexOnGridDest_); 
     440      std::list<std::vector<bool> >().swap(localMaskOnGridDest_); 
    440441    } 
    441442    else 
     
    458459    SourceDestinationIndexMap globaIndexWeightFromSrcToDst; 
    459460 
    460 //    if (1 < nbAlgos_) 
    461 //    { 
    462 //      // Create a temporary grid destination which contains transformed element of grid destination and 
    463 //      // non-transformed elements fo grid source 
    464 ////      if (nbAgloTransformation != (nbAlgos_-1)) setUpGridDestination(elementPositionInGrid, transType, nbAgloTransformation); 
    465 //    } 
     461    // Create a temporary grid destination which contains transformed element of grid destination and 
     462    // non-transformed elements fo grid source 
    466463    setUpGridDestination(elementPositionInGrid, transType, nbAgloTransformation); 
    467464 
     
    512509  // Recalculate the distribution of grid destination 
    513510  CDistributionClient distributionClientDest(client->clientRank, tmpGridDestination_); 
    514 //  CDistributionClient distributionClientDest(client->clientRank, gridDestination_); 
    515511  CDistributionClient::GlobalLocalDataMap& globalLocalIndexGridDestSendToServer = distributionClientDest.getGlobalLocalDataSendToServer(); 
    516   const std::vector<int>& localMask = distributionClientDest.getLocalMaskIndexOnClient(); 
    517512 
    518513  // Update number of local index on each transformation 
     
    522517  std::vector<bool>& tmpMask = localMaskOnGridDest_.back(); 
    523518  tmpMask.resize(nbLocalIndex,false); 
    524 //  for (int idx = 0; idx < nbLocalIndex; ++idx) 
    525 //  { 
    526 //    tmpMask[localMask[idx]] = true; 
    527 //  } 
    528519 
    529520  // Find out number of index sent from grid source and number of index received on grid destination 
     
    708699        recvTmp[recvRank][realRecvSize].first = globalLocalIndexGridDestSendToServer[recvIndexDst(idx)]; 
    709700        recvTmp[recvRank][realRecvSize].second = recvWeightDst(idx); 
     701        tmpMask[globalLocalIndexGridDestSendToServer[recvIndexDst(idx)]] = true; 
    710702         ++realRecvSize; 
    711703      } 
Note: See TracChangeset for help on using the changeset viewer.