Changeset 1875 for XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.cpp
- Timestamp:
- 05/12/20 11:52:13 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.cpp
r1871 r1875 2101 2101 } 2102 2102 2103 void CDomain::sendDomainToCouplerOut(CContextClient* client, const string& fieldId, int posInGrid) 2104 { 2105 if (sendDomainToFileServer_done_.count(client)!=0) return ; 2106 else sendDomainToFileServer_done_.insert(client) ; 2107 2108 const string domainId = "_domain["+std::to_string(posInGrid)+"]_of_"+fieldId ; 2109 2110 if (!domain_ref.isEmpty()) 2111 { 2112 auto domain_ref_tmp=domain_ref.getValue() ; 2113 domain_ref.reset() ; // remove the reference, find an other way to do that more cleanly 2114 this->sendAllAttributesToServer(client, domainId) ; 2115 domain_ref = domain_ref_tmp ; 2116 } 2117 else this->sendAllAttributesToServer(client, domainId) ; 2118 2119 this->sendDistributionAttributes(client, domainId); 2120 this->sendIndex(client, domainId); 2121 this->sendLonLat(client, domainId); 2122 this->sendArea(client, domainId); 2123 this->sendDataIndex(client, domainId); 2124 } 2125 2126 void CDomain::makeAliasForCoupling(const string& fieldId, int posInGrid) 2127 { 2128 const string domainId = "_domain["+std::to_string(posInGrid)+"]_of_"+fieldId ; 2129 this->createAlias(domainId) ; 2130 } 2131 2103 2132 /*! 2104 2133 Send all attributes from client to connected clients … … 2119 2148 Send global index from client to connected client(s) 2120 2149 */ 2121 void CDomain::sendIndex(CContextClient* client )2150 void CDomain::sendIndex(CContextClient* client, const string& domainId) 2122 2151 TRY 2123 2152 { 2153 string serverDomainId = domainId.empty() ? this->getId() : domainId ; 2154 2124 2155 int ns, n, i, j, ind, nv, idx; 2125 2126 2156 int serverSize = client->serverSize; 2127 2157 CEventClient eventIndex(getType(), EVENT_ID_INDEX); … … 2146 2176 2147 2177 list_msgsIndex.push_back(CMessage()); 2148 list_msgsIndex.back() << this->getId()<< (int)type; // enum ne fonctionne pour les message => ToFix2178 list_msgsIndex.back() << serverDomainId << (int)type; // enum ne fonctionne pour les message => ToFix 2149 2179 list_msgsIndex.back() << isCurvilinear; 2150 2180 list_msgsIndex.back() << list_indGlob.back(); //list_indi.back() << list_indj.back(); … … 2161 2191 it calculates this distribution then sends it to the corresponding clients on the next level 2162 2192 */ 2163 void CDomain::sendDistributionAttributes(CContextClient* client )2193 void CDomain::sendDistributionAttributes(CContextClient* client, const string& domainId) 2164 2194 TRY 2165 2195 { 2196 string serverDomainId = domainId.empty() ? this->getId() : domainId ; 2197 2166 2198 int nbServer = client->serverSize; 2167 2199 std::vector<int> nGlobDomain(2); … … 2192 2224 msgs.push_back(CMessage()); 2193 2225 CMessage& msg = msgs.back(); 2194 msg << this->getId();2226 msg << serverDomainId ; 2195 2227 msg << isUnstructed_; 2196 2228 msg << ni_srv << ibegin_srv << nj_srv << jbegin_srv; … … 2209 2241 Send area from client to connected client(s) 2210 2242 */ 2211 void CDomain::sendArea(CContextClient* client )2243 void CDomain::sendArea(CContextClient* client, const string& domainId) 2212 2244 TRY 2213 2245 { 2214 2246 if (!hasArea) return; 2215 2247 string serverDomainId = domainId.empty() ? this->getId() : domainId ; 2248 2216 2249 int ns, n, i, j, ind, nv, idx; 2217 2250 int serverSize = client->serverSize; … … 2242 2275 2243 2276 list_msgsArea.push_back(CMessage()); 2244 list_msgsArea.back() << this->getId()<< hasArea;2277 list_msgsArea.back() <<serverDomainId << hasArea; 2245 2278 list_msgsArea.back() << list_area.back(); 2246 2279 eventArea.push(rank, nbSenders[serverSize][rank], list_msgsArea.back()); … … 2255 2288 Because longitude and latitude are optional, this function only called if latitude and longitude exist 2256 2289 */ 2257 void CDomain::sendLonLat(CContextClient* client )2290 void CDomain::sendLonLat(CContextClient* client, const string& domainId) 2258 2291 TRY 2259 2292 { 2260 2293 if (!hasLonLat) return; 2261 2294 string serverDomainId = domainId.empty() ? this->getId() : domainId ; 2295 2262 2296 int ns, n, i, j, ind, nv, idx; 2263 2297 int serverSize = client->serverSize; … … 2316 2350 list_msgsLat.push_back(CMessage()); 2317 2351 2318 list_msgsLon.back() << this->getId()<< hasLonLat;2352 list_msgsLon.back() << serverDomainId << hasLonLat; 2319 2353 if (hasLonLat) 2320 2354 list_msgsLon.back() << list_lon.back(); … … 2325 2359 } 2326 2360 2327 list_msgsLat.back() << this->getId()<< hasLonLat;2361 list_msgsLat.back() << serverDomainId << hasLonLat; 2328 2362 if (hasLonLat) 2329 2363 list_msgsLat.back() << list_lat.back(); … … 2348 2382 The compressed index are represented with 1 and others are represented with -1 2349 2383 */ 2350 void CDomain::sendDataIndex(CContextClient* client )2384 void CDomain::sendDataIndex(CContextClient* client, const string& domainId) 2351 2385 TRY 2352 2386 { 2387 string serverDomainId = domainId.empty() ? this->getId() : domainId ; 2388 2353 2389 int ns, n, i, j, ind, nv, idx; 2354 2390 int serverSize = client->serverSize; … … 2406 2442 2407 2443 list_msgsDataIndex.push_back(CMessage()); 2408 list_msgsDataIndex.back() << this->getId();2444 list_msgsDataIndex.back() << serverDomainId ; 2409 2445 list_msgsDataIndex.back() << list_data_i_index.back() << list_data_j_index.back(); 2410 2446 eventDataIndex.push(rank, nbSenders[serverSize][rank], list_msgsDataIndex.back()); … … 2614 2650 << "The number of sending clients is not correct." 2615 2651 << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 2616 2652 2653 int nbLonInd = 0; 2617 2654 vector<CArray<double,1> > recvLonValue(nbReceived); 2618 2655 vector<CArray<double,2> > recvBoundsLonValue(nbReceived); … … 2631 2668 if (hasLonLat) 2632 2669 { 2633 int nbLonInd = 0;2634 2670 for (i = 0; i < nbReceived; ++i) 2635 2671 { … … 2665 2701 } 2666 2702 } 2703 } 2704 2705 // setup attribute depending the type of domain 2706 if (hasLonLat) 2707 { 2708 nbLonInd = globalLocalIndexMap_.size(); 2709 if (ni*nj != nbLonInd) 2710 ERROR("void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers)", 2711 << "The number of index received is not coherent with the given resolution" 2712 << "nbLonInd=" << nbLonInd << ", ni=" << ni <<", nj"<<ni<<" ni*nj="<<ni*nj); 2713 2714 if (type == type_attr::rectilinear || type == type_attr::curvilinear) 2715 { 2716 lonvalue_2d.resize(ni,nj); 2717 for(int ij=0, j=0 ; j<nj ; j++) 2718 for(int i=0 ; i<ni; i++, ij++) lonvalue_2d(i,j) = lonvalue(ij) ; 2719 2720 if (hasBounds) 2721 { 2722 bounds_lon_2d.resize(nvertex, ni, nj) ; 2723 for(int ij=0, j=0 ; j<nj ; j++) 2724 for(int i=0 ; i<ni; i++, ij++) 2725 for(int nv=0; nv<nvertex; nv++) bounds_lon_2d(nv,i,j) = bounds_lonvalue(nv,ij) ; 2726 } 2727 } 2728 } 2729 else if (type == type_attr::unstructured || type == type_attr::gaussian) 2730 { 2731 lonvalue_1d.resize(nbLonInd); 2732 lonvalue_1d = lonvalue ; 2733 if (hasBounds) 2734 { 2735 bounds_lon_1d.resize(nvertex, nbLonInd) ; 2736 bounds_lon_1d = bounds_lonvalue ; 2737 } 2667 2738 } 2668 2739 } … … 2717 2788 } 2718 2789 2790 int nbLatInd = 0; 2719 2791 if (hasLonLat) 2720 2792 { 2721 int nbLatInd = 0;2722 2793 for (i = 0; i < nbReceived; ++i) 2723 2794 { … … 2756 2827 } 2757 2828 } 2829 // setup attribute depending the type of domain 2830 if (hasLonLat) 2831 { 2832 nbLatInd = globalLocalIndexMap_.size(); 2833 2834 if (ni*nj != nbLatInd) 2835 ERROR("void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers)", 2836 << "The number of index received is not coherent with the given resolution" 2837 << "nbLonInd=" << nbLatInd << ", ni=" << ni <<", nj"<<ni<<" ni*nj="<<ni*nj); 2838 2839 if (type == type_attr::rectilinear || type == type_attr::curvilinear) 2840 { 2841 { 2842 latvalue_2d.resize(ni,nj); 2843 for(int ij=0, j=0 ; j<nj ; j++) 2844 for(int i=0 ; i<ni; i++, ij++) latvalue_2d(i,j) = latvalue(ij) ; 2845 2846 if (hasBounds) 2847 { 2848 bounds_lat_2d.resize(nvertex, ni, nj) ; 2849 for(int ij=0, j=0 ; j<nj ; j++) 2850 for(int i=0 ; i<ni; i++, ij++) 2851 for(int nv=0; nv<nvertex; nv++) bounds_lat_2d(nv,i,j) = bounds_latvalue(nv,ij) ; 2852 } 2853 } 2854 } 2855 else if (type == type_attr::unstructured || type == type_attr::gaussian) 2856 { 2857 if (hasLonLat) 2858 { 2859 latvalue_1d.resize(nbLatInd); 2860 latvalue_1d = latvalue ; 2861 if (hasBounds) 2862 { 2863 bounds_lat_1d.resize(nvertex, nbLatInd) ; 2864 bounds_lon_1d = bounds_lonvalue ; 2865 } 2866 } 2867 } 2868 } 2758 2869 } 2759 2870 CATCH_DUMP_ATTR … … 3016 3127 } 3017 3128 CATCH_DUMP_ATTR 3018 3019 /*! 3020 \brief Check if a domain is completed 3021 Before make any domain processing, we must be sure that all domain informations have 3022 been sent, for exemple when reading a grid in a file or when grid elements are sent by an 3023 other context (coupling). So all direct reference of the domain (domain_ref) must be also completed 3024 \return true if domain and domain reference are completed 3025 */ 3026 bool CDomain::checkIfCompleted(void) 3027 { 3028 if (hasDirectDomainReference()) if (!getDirectDomainReference()->checkIfCompleted()) return false; 3029 return isCompleted_ ; 3030 } 3031 3032 /*! 3033 \brief Set a domain as completed 3034 When all information about a domain have been received, the domain is tagged as completed and is 3035 suitable for processing 3036 */ 3037 void CDomain::setCompleted(void) 3038 { 3039 if (hasDirectDomainReference()) getDirectDomainReference()->setCompleted() ; 3040 isCompleted_=true ; 3041 } 3042 3043 /*! 3044 \brief Set a domain as uncompleted 3045 When informations about a domain are expected from a grid reading from file or coupling, the domain is 3046 tagged as uncompleted and is not suitable for processing 3047 */ 3048 void CDomain::setUncompleted(void) 3049 { 3050 if (hasDirectDomainReference()) getDirectDomainReference()->setUncompleted() ; 3051 isCompleted_=false ; 3052 } 3053 3129 3054 3130 /*! 3055 3131 * Go through the hierarchy to find the domain from which the transformations must be inherited
Note: See TracChangeset
for help on using the changeset viewer.