Changeset 687 for XIOS/trunk/src/node
- Timestamp:
- 09/15/15 17:30:55 (9 years ago)
- Location:
- XIOS/trunk/src/node
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/domain.cpp
r679 r687 20 20 #include "zoom_domain.hpp" 21 21 #include "interpolate_from_file_domain.hpp" 22 #include "generate_rectilinear_domain.hpp" 22 23 23 24 #include <algorithm> … … 34 35 , isClientAfterTransformationChecked(false), hasLonLat(false) 35 36 , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client() 37 , srcObject_(0) 36 38 { /* Ne rien faire de plus */ } 37 39 … … 43 45 , isClientAfterTransformationChecked(false), hasLonLat(false) 44 46 , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client() 47 , srcObject_(0) 45 48 { /* Ne rien faire de plus */ } 46 49 … … 158 161 159 162 //---------------------------------------------------------------- 163 164 /*! 165 Redistribute RECTILINEAR domain with a number of local domains. 166 All attributes ni,nj,ibegin,jbegin (if defined) will be rewritten 167 The optional attributes lonvalue, latvalue will be added. Because this function only serves (for now) 168 for interpolation from unstructured domain to rectilinear one, range of latvalue is 0-360 and lonvalue is -90 - +90 169 \param [in] nbLocalDomain number of local domain on the domain destination 170 */ 171 void CDomain::redistribute(int nbLocalDomain) 172 { 173 if (type_attr::rectilinear == type) 174 { 175 CContext* context = CContext::getCurrent(); 176 CContextClient* client = context->client; 177 int rankClient = client->clientRank; 178 int rankOnDomain = rankClient%nbLocalDomain; 179 180 if (ni_glo.isEmpty() || ni_glo <= 0 ) 181 { 182 ERROR("CDomain::redistribute(int nbLocalDomain)", 183 << "[ Id = " << this->getId() << " ] " 184 << "The global domain is badly defined," 185 << " check the \'ni_glo\' value !") 186 } 187 188 if (nj_glo.isEmpty() || nj_glo <= 0 ) 189 { 190 ERROR("CDomain::redistribute(int nbLocalDomain)", 191 << "[ Id = " << this->getId() << " ] " 192 << "The global domain is badly defined," 193 << " check the \'nj_glo\' value !") 194 } 195 196 int globalDomainSize = ni_glo * nj_glo; 197 if (globalDomainSize <= nbLocalDomain) 198 { 199 for (int idx = 0; idx < nbLocalDomain; ++idx) 200 { 201 if (rankOnDomain < globalDomainSize) 202 { 203 int iIdx = rankOnDomain % ni_glo; 204 int jIdx = rankOnDomain / ni_glo; 205 ibegin.setValue(iIdx); jbegin.setValue(jIdx); 206 ni.setValue(1); nj.setValue(1); 207 } 208 else 209 { 210 ibegin.setValue(0); jbegin.setValue(0); 211 ni.setValue(0); nj.setValue(0); 212 } 213 } 214 } 215 else 216 { 217 // Compute (approximately) number of segment on x and y axis 218 float yOverXRatio = (nj_glo.getValue())/(ni_glo.getValue()); 219 int nbProcOnX, nbProcOnY, range; 220 nbProcOnX = std::ceil(std::sqrt(nbLocalDomain/yOverXRatio)); 221 nbProcOnY = std::ceil(((float)nbLocalDomain)/nbProcOnX); 222 223 // Simple distribution: Sweep from top to bottom, left to right 224 // Calculate local begin on x 225 std::vector<int> ibeginVec(nbProcOnX,0), jbeginVec(nbProcOnY,0); 226 std::vector<int> niVec(nbProcOnX), njVec(nbProcOnY); 227 for (int i = 1; i < nbProcOnX; ++i) 228 { 229 range = ni_glo / nbProcOnX; 230 if (i < (ni_glo%nbProcOnX)) ++range; 231 niVec[i-1] = range; 232 ibeginVec[i] = ibeginVec[i-1] + niVec[i-1]; 233 } 234 niVec[nbProcOnX-1] = ni_glo - ibeginVec[nbProcOnX-1]; 235 236 // Calculate local begin on y 237 for (int j = 1; j < nbProcOnY; ++j) 238 { 239 range = nj_glo / nbProcOnY; 240 if (j < (nj_glo%nbProcOnY)) ++range; 241 njVec[j-1] = range; 242 jbeginVec[j] = jbeginVec[j-1] + njVec[j-1]; 243 } 244 njVec[nbProcOnY-1] = nj_glo - jbeginVec[nbProcOnY-1]; 245 246 // Now assign value to ni, ibegin, nj, jbegin 247 int iIdx = rankOnDomain % nbProcOnX; 248 int jIdx = rankOnDomain / nbProcOnX; 249 250 if (rankOnDomain != (nbLocalDomain-1)) 251 { 252 ibegin.setValue(ibeginVec[iIdx]); 253 jbegin.setValue(jbeginVec[jIdx]); 254 nj.setValue(njVec[jIdx]); 255 ni.setValue(niVec[iIdx]); 256 } 257 else // just merge all the remaining rectangle into the last one 258 { 259 ibegin.setValue(ibeginVec[iIdx]); 260 jbegin.setValue(jbeginVec[jIdx]); 261 nj.setValue(njVec[jIdx]); 262 ni.setValue(ni_glo - ibeginVec[iIdx]); 263 } 264 } 265 266 // Now fill other attributes 267 fillInRectilinearLonLat(); 268 } 269 } 270 271 /*! 272 Fill in the values for lonvalue_1d and latvalue_1d of rectilinear domain 273 Range of longitude value from 0 - 360 274 Range of latitude value from -90 - +90 275 */ 276 void CDomain::fillInRectilinearLonLat() 277 { 278 if (!lonvalue_2d.isEmpty()) lonvalue_2d.free(); 279 if (!latvalue_2d.isEmpty()) latvalue_1d.free(); 280 lonvalue_1d.resize(ni); 281 latvalue_1d.resize(nj); 282 double lonStep = double(360/ni_glo.getValue()); 283 double latStep = double(180/nj_glo.getValue()); 284 285 // Assign lon value 286 for (int i = 0; i < ni; ++i) 287 { 288 lonvalue_1d(i) = static_cast<double>(ibegin + i) * lonStep; 289 } 290 291 for (int j = 0; j < nj; ++j) 292 { 293 latvalue_1d(j) = static_cast<double>(jbegin + j) * latStep - 90; 294 } 295 } 160 296 161 297 void CDomain::checkDomain(void) … … 702 838 if (!lonvalue_1d.isEmpty() && lonvalue_2d.isEmpty()) 703 839 { 704 if ( lonvalue_1d.numElements() != i_index.numElements())840 if ((type_attr::rectilinear != type) && (lonvalue_1d.numElements() != i_index.numElements())) 705 841 ERROR("CDomain::completeLonLatClient(void)", 706 842 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " … … 728 864 if (!latvalue_1d.isEmpty() && latvalue_2d.isEmpty()) 729 865 { 730 if ( latvalue_1d.numElements() != i_index.numElements())866 if ((type_attr::rectilinear != type) && (latvalue_1d.numElements() != i_index.numElements())) 731 867 ERROR("CDomain::completeLonLatClient(void)", 732 868 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " … … 1580 1716 } 1581 1717 1718 void CDomain::solveSrcInheritance() 1719 { 1720 if (!domain_src.isEmpty()) 1721 { 1722 if (!CDomain::has(this->domain_src.getValue())) \ 1723 ERROR("CDomain::solveSrcInheritance()", \ 1724 << "[ src_name = " << this->domain_src.getValue() << "]" \ 1725 << " invalid domain name !"); 1726 1727 srcObject_ = CDomain::get(this->domain_src.getValue()); 1728 } 1729 } 1730 1731 CDomain* CDomain::getDomainSrc() 1732 { 1733 return srcObject_; 1734 } 1735 1582 1736 /*! 1583 1737 Parse children nodes of a domain in xml file. … … 1595 1749 StdString interpFromFileDomainDefRoot("interpolate_from_file_domain_definition"); 1596 1750 StdString interpFromFile("interpolate_from_file_domain"); 1751 StdString generateRectilinearDefRoot("generate_rectilinear_domain_definition"); 1752 StdString generateRectilinear("generate_rectilinear_domain"); 1597 1753 do 1598 1754 { … … 1608 1764 transformationMap_.push_back(std::make_pair(TRANS_INTERPOLATE_DOMAIN_FROM_FILE,tmp)); 1609 1765 } 1766 else if (node.getElementName() == generateRectilinear) 1767 { 1768 CGenerateRectilinearDomain* tmp = (CGenerateRectilinearDomainGroup::get(generateRectilinearDefRoot))->createChild(); 1769 tmp->parse(node); 1770 transformationMap_.push_back(std::make_pair(TRANS_GENERATE_RECTILINEAR_DOMAIN,tmp)); 1771 } 1610 1772 } while (node.goToNextElement()) ; 1611 1773 node.goToParentElement(); -
XIOS/trunk/src/node/domain.hpp
r676 r687 76 76 bool hasTransformation(); 77 77 void solveInheritanceTransformation(); 78 void solveSrcInheritance(); 79 CDomain* getDomainSrc(); 78 80 TransMapTypes getAllTransformations(); 81 void redistribute(int nbLocalDomain); 79 82 80 83 public: … … 164 167 void setTransformations(const TransMapTypes&); 165 168 void computeNGlobDomain(); 169 void fillInRectilinearLonLat(); 166 170 167 171 void sendIndex(); … … 187 191 std::vector<int> nGlobDomain_; 188 192 bool isUnstructed_; 193 CDomain* srcObject_; 189 194 190 195 DECLARE_REF_FUNC(Domain,domain) -
XIOS/trunk/src/node/field.cpp
r676 r687 175 175 client->sendEvent(event); 176 176 } 177 177 178 178 CTimer::get("XIOS Send Data").suspend(); 179 179 } … … 498 498 solveGridReference(); 499 499 } 500 if (context->hasClient) 501 { 502 solveGenerateGrid(); 503 } 504 500 505 solveGridDomainAxisRef(doSending2Sever); 506 501 507 if (context->hasClient) 502 508 { 503 509 solveTransformedGrid(); 504 510 } 511 505 512 solveCheckMaskIndex(doSending2Sever); 506 513 } … … 775 782 } 776 783 784 void CField::solveGenerateGrid() 785 { 786 if (!grid_ref.isEmpty() && hasDirectFieldReference() && !getDirectFieldReference()->grid_ref.isEmpty() 787 && grid_ref.getValue() != getDirectFieldReference()->grid_ref.getValue() && !grid->isTransformed()) 788 grid->completeGrid(getDirectFieldReference()->grid); 789 } 790 777 791 ///------------------------------------------------------------------- 778 792 -
XIOS/trunk/src/node/field.hpp
r676 r687 110 110 void solveGridDomainAxisRef(bool checkAtt); 111 111 void solveTransformedGrid(); 112 void solveGenerateGrid(); 112 113 113 114 void buildFilterGraph(CGarbageCollector& gc, bool enableOutput); -
XIOS/trunk/src/node/grid.cpp
r676 r687 17 17 #include "distribution_client.hpp" 18 18 #include "grid_transformation.hpp" 19 #include "grid_generate.hpp" 19 20 20 21 namespace xios { … … 1168 1169 pDom->solveRefInheritance(apply); 1169 1170 pDom->solveBaseReference(); 1171 pDom->solveSrcInheritance(); 1170 1172 pDom->solveInheritanceTransformation(); 1171 1173 if ((!pDom->domain_ref.isEmpty()) && (pDom->name.isEmpty())) … … 1203 1205 { 1204 1206 return transformations_; 1207 } 1208 1209 /*! 1210 Complete all the necessary (and lacking) attributes of a grid 1211 This function is similar to gridTransformation but works only (till now) on generate_rectilinear_domain transformation 1212 */ 1213 void CGrid::completeGrid(CGrid* transformGridSrc) 1214 { 1215 if (axis_domain_order.numElements() != transformGridSrc->axis_domain_order.numElements()) 1216 { 1217 ERROR("CGrid::transformGrid(CGrid* transformGridSrc)", 1218 << "Two grids have different dimension size" 1219 << "Dimension of grid destination " << this->getId() << " is " << axis_domain_order.numElements() << std::endl 1220 << "Dimension of grid source " << transformGridSrc->getId() << " is " << transformGridSrc->axis_domain_order.numElements()); 1221 } 1222 else 1223 { 1224 int ssize = axis_domain_order.numElements(); 1225 for (int i = 0; i < ssize; ++i) 1226 if (axis_domain_order(i) != (transformGridSrc->axis_domain_order)(i)) 1227 ERROR("CGrid::transformGrid(CGrid* transformGridSrc)", 1228 << "Grids " << this->getId() << " and " << transformGridSrc->getId() 1229 << " don't have elements in the same order"); 1230 } 1231 1232 CGridGenerate gridGenerate(this, transformGridSrc); 1233 gridGenerate.completeGrid(); 1205 1234 } 1206 1235 -
XIOS/trunk/src/node/grid.hpp
r680 r687 180 180 181 181 void transformGrid(CGrid* transformGridSrc); 182 void completeGrid(CGrid* transformGridSrc); 183 void doAutoDistribution(CGrid* transformGridSrc); 182 184 bool isTransformed(); 183 185 void setTransformed(); -
XIOS/trunk/src/node/node_enum.hpp
r657 r687 24 24 eInterpolateAxis, 25 25 eZoomDomain, 26 eInterpolateFromFileDomain 26 eInterpolateFromFileDomain, 27 eGenerateRectilinearDomain 27 28 28 29 } ENodeType; -
XIOS/trunk/src/node/node_type.hpp
r657 r687 15 15 #include "zoom_domain.hpp" 16 16 #include "interpolate_from_file_domain.hpp" 17 #include "generate_rectilinear_domain.hpp" 17 18 18 19 #endif // __XIOS_NODE_TYPE__ -
XIOS/trunk/src/node/transformation_enum.hpp
r657 r687 11 11 TRANS_INTERPOLATE_AXIS, 12 12 TRANS_ZOOM_DOMAIN, 13 TRANS_INTERPOLATE_DOMAIN_FROM_FILE 13 TRANS_INTERPOLATE_DOMAIN_FROM_FILE, 14 TRANS_GENERATE_RECTILINEAR_DOMAIN 14 15 } ETranformationType; 15 16
Note: See TracChangeset
for help on using the changeset viewer.