Changeset 1114
- Timestamp:
- 05/03/17 15:07:53 (8 years ago)
- Location:
- XIOS/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/extern/remap/src/mapper.cpp
r923 r1114 109 109 } 110 110 111 vector<double> Mapper::computeWeights(int interpOrder, bool renormalize )111 vector<double> Mapper::computeWeights(int interpOrder, bool renormalize, bool quantity) 112 112 { 113 113 vector<double> timings; … … 152 152 if (mpiRank == 0 && verbose) cout << "Remapping..." << endl; 153 153 tic = cputime(); 154 nWeights = remap(&targetElements[0], targetElements.size(), interpOrder, renormalize );154 nWeights = remap(&targetElements[0], targetElements.size(), interpOrder, renormalize, quantity); 155 155 timings.push_back(cputime() - tic); 156 156 … … 166 166 @param order is the order of interpolaton (must be 1 or 2). 167 167 */ 168 int Mapper::remap(Elt *elements, int nbElements, int order, bool renormalize )168 int Mapper::remap(Elt *elements, int nbElements, int order, bool renormalize, bool quantity) 169 169 { 170 170 int mpiSize, mpiRank; … … 184 184 int **sendElement = new int*[mpiSize]; /* indices of elements required from other rank */ 185 185 double **recvValue = new double*[mpiSize]; 186 double **recvArea = new double*[mpiSize]; 186 187 Coord **recvGrad = new Coord*[mpiSize]; 187 188 GloId **recvNeighIds = new GloId*[mpiSize]; /* ids of the of the source neighbours which also contribute through gradient */ … … 205 206 sendElement[rank] = new int[nbSendElement[rank]]; 206 207 recvValue[rank] = new double[nbSendElement[rank]]; 208 recvArea[rank] = new double[nbSendElement[rank]]; 207 209 if (order == 2) 208 210 { … … 234 236 int **recvElement = new int*[mpiSize]; 235 237 double **sendValue = new double*[mpiSize]; 238 double **sendArea = new double*[mpiSize]; 236 239 Coord **sendGrad = new Coord*[mpiSize]; 237 240 GloId **sendNeighIds = new GloId*[mpiSize]; … … 250 253 recvElement[rank] = new int[nbRecvElement[rank]]; 251 254 sendValue[rank] = new double[nbRecvElement[rank]]; 255 sendArea[rank] = new double[nbRecvElement[rank]]; 252 256 if (order == 2) 253 257 { … … 278 282 { 279 283 sendValue[rank][j] = sstree.localElements[recvElement[rank][j]].val; 284 sendArea[rank][j] = sstree.localElements[recvElement[rank][j]].area; 280 285 if (order == 2) 281 286 { … … 297 302 MPI_Issend(sendValue[rank], nbRecvElement[rank], MPI_DOUBLE, rank, 0, communicator, &sendRequest[nbSendRequest]); 298 303 nbSendRequest++; 304 MPI_Issend(sendArea[rank], nbRecvElement[rank], MPI_DOUBLE, rank, 0, communicator, &sendRequest[nbSendRequest]); 305 nbSendRequest++; 299 306 if (order == 2) 300 307 { … … 317 324 MPI_Irecv(recvValue[rank], nbSendElement[rank], MPI_DOUBLE, rank, 0, communicator, &recvRequest[nbRecvRequest]); 318 325 nbRecvRequest++; 326 MPI_Irecv(recvArea[rank], nbSendElement[rank], MPI_DOUBLE, rank, 0, communicator, &recvRequest[nbRecvRequest]); 327 nbRecvRequest++; 319 328 if (order == 2) 320 329 { … … 357 366 int rank = (*it)->id.rank; 358 367 double fk = recvValue[rank][n1]; 368 double srcArea = recvArea[rank][n1]; 359 369 double w = (*it)->area; 370 if (quantity) w/=srcArea ; 360 371 361 372 /* first order: src value times weight (weight = supermesh area), later divide by target area */ 362 373 int kk = (order == 2) ? n1 * (NMAX + 1) : n1; 363 374 GloId neighID = recvNeighIds[rank][kk]; 364 wgt_map[neighID] += (*it)->area;375 wgt_map[neighID] += w; 365 376 366 377 if (order == 2) … … 383 394 for (map<GloId,double>::iterator it = wgt_map.begin(); it != wgt_map.end(); it++) 384 395 { 385 this->remapMatrix[i] = (it->second / e.area) / renorm; 396 if (quantity) this->remapMatrix[i] = (it->second ) / renorm; 397 else this->remapMatrix[i] = (it->second / e.area) / renorm; 386 398 this->srcAddress[i] = it->first.ind; 387 399 this->srcRank[i] = it->first.rank; … … 400 412 delete[] sendElement[rank]; 401 413 delete[] recvValue[rank]; 414 delete[] recvArea[rank]; 402 415 if (order == 2) 403 416 { … … 410 423 delete[] recvElement[rank]; 411 424 delete[] sendValue[rank]; 425 delete[] sendArea[rank]; 412 426 if (order == 2) 413 427 delete[] sendGrad[rank]; -
XIOS/trunk/extern/remap/src/mapper.hpp
r844 r1114 34 34 /** @param trgElts are the elements of the unstructured target grid 35 35 Returns the timings for substeps: */ 36 vector<double> computeWeights(int interpOrder, bool renormalize=false );36 vector<double> computeWeights(int interpOrder, bool renormalize=false, bool quantity=false); 37 37 int getNbWeights(void) { return nWeights ; } 38 38 /* … … 51 51 private: 52 52 /** @return number of weights (local to cpu) */ 53 int remap(Elt* elements, int nbElements, int order, bool renormalize=false );53 int remap(Elt* elements, int nbElements, int order, bool renormalize=false, bool quantity=false); 54 54 55 55 void buildMeshTopology(); -
XIOS/trunk/src/config/interpolate_domain_attribute.conf
r1014 r1114 2 2 DECLARE_ATTRIBUTE(int, order) 3 3 DECLARE_ATTRIBUTE(bool, renormalize) 4 DECLARE_ATTRIBUTE(bool, quantity) 4 5 5 6 /* Write interpolation weights into file */ -
XIOS/trunk/src/transformation/domain_algorithm_interpolate.cpp
r1046 r1114 100 100 int orderInterp = interpDomain_->order.getValue(); 101 101 bool renormalize ; 102 bool quantity ; 102 103 103 104 if (interpDomain_->renormalize.isEmpty()) renormalize=true; 104 105 else renormalize = interpDomain_->renormalize; 106 107 if (interpDomain_->quantity.isEmpty()) quantity=false; 108 else quantity = interpDomain_->quantity; 105 109 106 110 const double poleValue = 90.0; … … 342 346 mapper.setTargetMesh(boundsLonDestUnmasked.dataFirst(), boundsLatDestUnmasked.dataFirst(), nVertexDest, nDstLocalUnmasked, &dstPole[0], globalDstUnmasked); 343 347 344 std::vector<double> timings = mapper.computeWeights(orderInterp,renormalize );348 std::vector<double> timings = mapper.computeWeights(orderInterp,renormalize,quantity); 345 349 346 350 std::map<int,std::vector<std::pair<int,double> > > interpMapValue;
Note: See TracChangeset
for help on using the changeset viewer.