Changeset 620 for XIOS/trunk/src/node/field.cpp
- Timestamp:
- 06/22/15 13:36:17 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/field.cpp
r619 r620 549 549 } 550 550 solveGridDomainAxisRef(doSending2Sever); 551 solveCheckMaskIndex(doSending2Sever); 551 552 if (context->hasClient) 552 553 { 553 554 solveTransformedGrid(); 554 555 } 555 solveCheckMaskIndex(doSending2Sever);556 556 } 557 557 … … 804 804 gridRefOfFieldRef->transformGrid(relGridRef); 805 805 filterSources_.push_back(fieldRef); 806 transformations_ = relGridRef->getTransformations(); 807 switch (gridRefOfFieldRef->getGridElementType()) { 808 case CGrid::GRID_ONLY_AXIS: 809 filter = new CAxisFilter(gridRefOfFieldRef, relGridRef); 810 break; 811 default: 812 break; 813 } 814 setAlgorithms(); 806 // transformations_ = relGridRef->getTransformations(); 807 // switch (gridRefOfFieldRef->getGridElementType()) { 808 // case CGrid::GRID_ONLY_AXIS: 809 //// filter = new CAxisFilter(gridRefOfFieldRef, relGridRef); 810 //// break; 811 // default: 812 // filter = new CAxisFilter(gridRefOfFieldRef, relGridRef); 813 // break; 814 // } 815 // setAlgorithms(); 815 816 } 816 817 } … … 818 819 819 820 820 void CField::setAlgorithms() 821 { 822 std::vector<ETransformationType>::iterator itTrans = transformations_.begin(), 823 iteTrans = transformations_.end(); 824 std::set<ETransformationType> tmp; 825 for (; itTrans != iteTrans; ++itTrans) 826 { 827 if (tmp.end() == tmp.find(*itTrans)) 828 { 829 switch (*itTrans) { 830 case eInverse: 831 algorithms_.push_back(new CInvertAlgorithm()); 832 break; 833 default: 834 break; 821 // void CField::setAlgorithms() 822 // { 823 // std::vector<ETransformationType>::iterator itTrans = transformations_.begin(), 824 // iteTrans = transformations_.end(); 825 // std::set<ETransformationType> tmp; 826 // for (; itTrans != iteTrans; ++itTrans) 827 // { 828 // if (tmp.end() == tmp.find(*itTrans)) 829 // { 830 // switch (*itTrans) { 831 // case eInverse: 832 // algorithms_.push_back(new CInvertAlgorithm()); 833 // break; 834 // default: 835 // break; 836 // } 837 // } 838 // tmp.insert(*itTrans); 839 // } 840 // } 841 842 const std::vector<CField*>& CField::getFilterSources() 843 { 844 return filterSources_; 845 } 846 847 void CField::applyFilter(const CArray<double, 1>& dataToSend, CArray<double,1>& dataToReceive) 848 { 849 std::vector<CField*>::iterator itFilterSrc, iteFilterSrc; 850 if (!filterSources_.empty()) 851 { 852 itFilterSrc = filterSources_.begin(); iteFilterSrc = filterSources_.end(); 853 for (; itFilterSrc != iteFilterSrc; ++itFilterSrc) 854 { 855 if (0 != (*itFilterSrc)->grid->getTransformations()) 856 { 857 const std::map<int, CArray<int,1>* >& localIndexToSend = (*itFilterSrc)->grid->getTransformations()->getLocalIndexToSendFromGridSource(); 858 const std::map<int, std::vector<CArray<int,1>* > > localIndexToReceive = (*itFilterSrc)->grid->getTransformations()->getLocalIndexToReceiveOnGridDest(); 859 sendAndReceiveTransformedData(localIndexToSend, dataToSend, 860 localIndexToReceive, dataToReceive); 861 } 862 835 863 } 836 } 837 tmp.insert(*itTrans); 838 } 839 } 840 841 const std::vector<CField*>& CField::getFilterSources() 842 { 843 return filterSources_; 844 } 845 846 void CField::applyFilter() 847 { 848 filter->setInputs(filterSources_); 849 filter->setOutput(this); 850 filter->apply(algorithms_); 851 864 865 // std::cout << "it data " << (*it)->data << std::endl; 866 // std::cout << "it filtered data " << (*it)->filteredData << std::endl; 867 } 868 } 869 870 void CField::sendAndReceiveTransformedData(const std::map<int, CArray<int,1>* >& localIndexToSend, 871 const CArray<double, 1>& dataSrc, 872 const std::map<int, std::vector<CArray<int,1>* > >& localIndexToReceive, 873 CArray<double,1>& dataDest) 874 { 875 CContext* context = CContext::getCurrent(); 876 CContextClient* client=context->client; 877 878 // Sending data from field sources to do transformations 879 std::map<int, CArray<int,1>* >::const_iterator itbSend = localIndexToSend.begin(), itSend, 880 iteSend = localIndexToSend.end(); 881 int sendBuffSize = 0; 882 for (itSend = itbSend; itSend != iteSend; ++itSend) sendBuffSize = (sendBuffSize < (itSend->second)->numElements()) 883 ? (itSend->second)->numElements(): sendBuffSize; 884 double* sendBuff; 885 if (0 != sendBuffSize) sendBuff = new double [sendBuffSize]; 886 for (itSend = itbSend; itSend != iteSend; ++itSend) 887 { 888 int destRank = itSend->first; 889 CArray<int,1>* localIndex_p = itSend->second; 890 int countSize = localIndex_p->numElements(); 891 for (int idx = 0; idx < countSize; ++idx) 892 { 893 sendBuff[idx] = dataSrc((*localIndex_p)(idx)); 894 } 895 MPI_Send(sendBuff, countSize, MPI_DOUBLE, destRank, 12, client->intraComm); 896 } 897 898 // Receiving data on destination fields 899 std::map<int, std::vector<CArray<int,1>* > >::const_iterator itbRecv = localIndexToReceive.begin(), itRecv, 900 iteRecv = localIndexToReceive.end(); 901 int recvBuffSize = 0; 902 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) recvBuffSize = (recvBuffSize < (itRecv->second).size()) 903 ? (itRecv->second).size() : recvBuffSize; 904 double* recvBuff; 905 if (0 != recvBuffSize) recvBuff = new double [recvBuffSize]; 906 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) 907 { 908 MPI_Status status; 909 int srcRank = itRecv->first; 910 int countSize = (itRecv->second).size(); 911 MPI_Recv(recvBuff, recvBuffSize, MPI_DOUBLE, srcRank, 12, client->intraComm, &status); 912 for (int idx = 0; idx < countSize; ++idx) 913 { 914 CArray<int,1>* localIndex_p = (itRecv->second)[idx]; 915 int numIndex = localIndex_p->numElements(); 916 for (int i = 0; i < numIndex; ++i) 917 { 918 dataDest((*localIndex_p)(i)) = recvBuff[idx]; 919 } 920 } 921 } 922 923 if (0 != sendBuffSize) delete [] sendBuff; 924 if (0 != recvBuffSize) delete [] recvBuff; 852 925 } 853 926
Note: See TracChangeset
for help on using the changeset viewer.