Ignore:
Timestamp:
07/05/16 15:59:02 (8 years ago)
Author:
mhnguyen
Message:

Adding a new type of element into grid: Scalar

+) Add a new node Scalar for xml
+) Make some change on writing scalar value
+) Reorganize some codes
+) Remove some redundant codes

Test
+) On Curie
+) All tests pass

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/transformation/generic_algorithm_transformation.cpp

    r871 r887  
    8484  std::vector<CAxis*> axisListDestP = gridDst->getAxis(); 
    8585  std::vector<CDomain*> domainListDestP = gridDst->getDomains(); 
    86   CArray<bool,1> axisDomainDstOrder = gridDst->axis_domain_order; 
     86  CArray<int,1> axisDomainDstOrder = gridDst->axis_domain_order; 
    8787  std::vector<CAxis*> axisListSrcP = gridSrc->getAxis(); 
    8888  std::vector<CDomain*> domainListSrcP = gridSrc->getDomains(); 
     
    9696    if (idx == elementPositionInGrid) 
    9797      computeExchangeGlobalIndex(indexSrc, globalIndexOfTransformedElementOnProc); //globalElementIndexOnProc[idx]); 
    98     if (axisDomainDstOrder(idx)) // It's domain 
     98    if (2 == axisDomainDstOrder(idx)) // It's domain 
    9999    { 
    100100      if (idx != elementPositionInGrid) 
     
    106106 
    107107    } 
    108     else //it's an axis 
     108    else if (1 == axisDomainDstOrder(idx))//it's an axis 
    109109    { 
    110110      if (idx != elementPositionInGrid) 
     
    226226                                                                   SourceDestinationIndexMap& globaIndexWeightFromSrcToDst) 
    227227{ 
     228  std::vector<CDomain*> domainListSrcP = gridSrc->getDomains(); 
     229  std::vector<CAxis*> axisListSrcP = gridSrc->getAxis(); 
     230  std::vector<CScalar*> scalarListSrcP = gridSrc->getScalars(); 
     231  CArray<int,1> axisDomainSrcOrder = gridSrc->axis_domain_order; 
     232 
     233  size_t nbElement = axisDomainSrcOrder.numElements(); 
     234  std::vector<size_t> nGlobSrc(nbElement); 
     235  size_t globalSrcSize = 1; 
     236  int domainIndex = 0, axisIndex = 0, scalarIndex = 0; 
     237  for (int idx = 0; idx < nbElement; ++idx) 
     238  { 
     239    nGlobSrc[idx] = globalSrcSize; 
     240    int elementDimension = axisDomainSrcOrder(idx); 
     241 
     242    // If this is a domain 
     243    if (2 == elementDimension) 
     244    { 
     245      globalSrcSize *= domainListSrcP[domainIndex]->nj_glo.getValue() * domainListSrcP[domainIndex]->ni_glo.getValue(); 
     246      ++domainIndex; 
     247    } 
     248    else if (1 == elementDimension) // So it's an axis 
     249    { 
     250      globalSrcSize *= axisListSrcP[axisIndex]->n_glo.getValue(); 
     251      ++axisIndex; 
     252    } 
     253    else 
     254    { 
     255      globalSrcSize *= 1; 
     256      ++scalarIndex; 
     257    } 
     258  } 
     259 
     260  std::vector<CDomain*> domainListDestP = gridDst->getDomains(); 
    228261  std::vector<CAxis*> axisListDestP = gridDst->getAxis(); 
    229   std::vector<CDomain*> domainListDestP = gridDst->getDomains(); 
    230   CArray<bool,1> axisDomainDstOrder = gridDst->axis_domain_order; 
    231   std::vector<CAxis*> axisListSrcP = gridSrc->getAxis(); 
    232   std::vector<CDomain*> domainListSrcP = gridSrc->getDomains(); 
    233   CArray<bool,1> axisDomainSrcOrder = gridDst->axis_domain_order; 
    234   size_t nbElement = axisDomainSrcOrder.numElements(); 
    235   std::vector<size_t> nGlobSrc(nbElement), nGlobDst(nbElement); 
    236   size_t globalSrcSize = 1, globalDstSize = 1; 
    237   int domainIndex = 0; 
    238   int axisIndex = 0; 
     262  std::vector<CScalar*> scalarListDestP = gridDst->getScalars(); 
     263  CArray<int,1> axisDomainDstOrder = gridDst->axis_domain_order; 
     264 
     265  std::vector<size_t> nGlobDst(nbElement); 
     266  size_t globalDstSize = 1; 
     267  domainIndex = axisIndex = scalarIndex = 0; 
    239268  for (int idx = 0; idx < nbElement; ++idx) 
    240269  { 
    241     nGlobSrc[idx] = globalSrcSize; 
    242270    nGlobDst[idx] = globalDstSize; 
    243     bool isDomain = axisDomainSrcOrder(idx); 
     271    int elementDimension = axisDomainSrcOrder(idx); 
    244272 
    245273    // If this is a domain 
    246     if (isDomain) 
    247     { 
    248       globalSrcSize *= domainListSrcP[domainIndex]->nj_glo.getValue() * domainListSrcP[domainIndex]->ni_glo.getValue(); 
     274    if (2 == elementDimension) 
     275    { 
    249276      globalDstSize *= domainListDestP[domainIndex]->nj_glo.getValue() * domainListDestP[domainIndex]->ni_glo.getValue(); 
    250277      ++domainIndex; 
    251278    } 
    252     else // So it's an axis 
    253     { 
    254       globalSrcSize *= axisListSrcP[axisIndex]->n_glo.getValue(); 
     279    else if (1 == elementDimension) // So it's an axis 
     280    { 
    255281      globalDstSize *= axisListDestP[axisIndex]->n_glo.getValue(); 
    256282      ++axisIndex; 
     283    } 
     284    else 
     285    { 
     286      globalDstSize *= 1; 
     287      ++scalarIndex; 
    257288    } 
    258289  } 
Note: See TracChangeset for help on using the changeset viewer.