Changeset 946
- Timestamp:
- 09/22/16 12:05:01 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/mesh.cpp
r945 r946 1923 1923 nbNghbFaces.resize(nbFaces); 1924 1924 nbNghbFaces = 0; 1925 int maxNb = 10; // assumption on max number of edges sharing the same node 1926 1927 // faceToNodes connectivity 1928 CArray<int, 2> nodeToFaces(maxNb, nbFaces*nvertex); 1929 nodeToFaces = -1; 1930 boost::unordered_map <pair<double,double>, int> mapNodes; 1931 vector<int> countNodes(nbFaces*nvertex); 1932 countNodes.assign(nbFaces*nvertex, 0); 1933 1925 1926 // nodeToFaces connectivity 1927 CClientClientDHTSizet::Index2VectorInfoTypeMap nodeToFaces; 1934 1928 for (int nf = 0; nf < nbFaces; ++nf) 1935 1929 for (int nv = 0; nv < nvertex; ++nv) 1936 1930 { 1937 if (mapNodes.find(make_pair (bounds_lon(nv, nf), bounds_lat(nv ,nf))) == mapNodes.end()) 1938 { 1939 mapNodes[make_pair (bounds_lon(nv, nf), bounds_lat(nv, nf))] = nbNodes; 1940 nodeToFaces(countNodes[nbNodes], nbNodes) = face_idx(nf); 1941 ++(countNodes[nbNodes]); 1942 ++nbNodes; 1943 } 1944 else 1945 { 1946 int node = mapNodes[make_pair (bounds_lon(nv, nf), bounds_lat(nv ,nf))]; 1947 nodeToFaces(countNodes[node], node) = face_idx(nf); 1948 ++(countNodes[node]); 1949 } 1931 size_t nodeHash = (CMesh::createHashes(bounds_lon(nv, nf), bounds_lat(nv ,nf)))[0]; 1932 nodeToFaces[nodeHash].push_back(face_idx(nf)); 1950 1933 } 1951 nodeToFaces.resizeAndPreserve(maxNb, nbNodes);1952 1953 vector<int> tmpVec (nbNodes);1954 for (int i = 0; i < nbNodes; ++i)1955 {1956 for (int j = 0; j < maxNb; ++j)1957 tmpVec[j] = nodeToFaces(j,i);1958 }1959 1960 1934 1961 1935 // faceToFaces connectivity 1962 1936 boost::unordered_map <int, int> mapFaces; // mapFaces = < hash(face1, face2), hash> (the mapped value is irrelevant) 1963 faceToFaces.resize(nvertex, nbFaces); 1964 for (int nn = 0; nn < nbNodes; ++nn) 1965 { 1966 int nf1 = 0; 1967 while (nodeToFaces(nf1+1, nn) != -1) 1968 { 1969 int nf2 = nf1+1; 1970 int face1 = nodeToFaces(nf1, nn); 1971 while (nodeToFaces(nf2, nn) != -1) 1972 { 1973 int face2 = nodeToFaces(nf2, nn); 1974 int hash = hashPairOrdered(face1, face2); 1975 if (mapFaces.count(hash) == 0) 1976 { 1977 faceToFaces(nbNghbFaces(face1), face1) = face2; 1978 faceToFaces(nbNghbFaces(face2), face2) = face1; 1979 ++nbNghbFaces(face1); 1980 ++nbNghbFaces(face2); 1981 } 1982 else 1983 mapFaces[hash] = hash; 1984 ++nf2; 1985 } 1986 ++nf1; 1937 int maxNb = 20; // some assumption on the max possible number of neighboring cells 1938 faceToFaces.resize(maxNb, nbFaces); 1939 CClientClientDHTSizet::Index2VectorInfoTypeMap::iterator it; 1940 for (it = nodeToFaces.begin(); it != nodeToFaces.end(); ++it) 1941 { 1942 int size = it->second.size(); 1943 for (int i = 0; i < (size-1); ++i) 1944 { 1945 int face1 = it->second[i]; 1946 for (int j = i+1; j < size; ++j) 1947 { 1948 int face2 = it->second[j]; 1949 if (face2 != face1) 1950 { 1951 int hashFace = hashPairOrdered(face1, face2); 1952 if (mapFaces.count(hashFace) == 0) 1953 { 1954 faceToFaces(nbNghbFaces(face1), face1) = face2; 1955 faceToFaces(nbNghbFaces(face2), face2) = face1; 1956 ++nbNghbFaces(face1); 1957 ++nbNghbFaces(face2); 1958 mapFaces[hashFace] = hashFace; 1959 } 1960 } 1961 } 1987 1962 } 1988 1963 } 1989 1990 } //getLocNghbFacesEdgeType 1964 } //getLocNghbFacesNodeType 1991 1965 1992 1966
Note: See TracChangeset
for help on using the changeset viewer.