- Timestamp:
- 09/22/16 10:59:32 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/transformation/domain_algorithm_compute_connectivity.cpp
r934 r944 49 49 CArray<int,1>& nbNeighbor = compute_connectivityDomain->n_neighbor; 50 50 CArray<int,2>& localNeighbors = compute_connectivityDomain->local_neighbor; 51 int type = 1; // Edge type 51 52 switch (compute_connectivityDomain->type) 52 53 { 53 54 case CComputeConnectivityDomain::type_attr::node : 54 computeNodeConnectivity(domainDestination, 55 nbNeighborMax, 56 nbNeighbor, 57 localNeighbors); 55 type = 0; 58 56 break; 59 57 case CComputeConnectivityDomain::type_attr::edge : 60 computeEdgeConnectivity(domainDestination, 61 nbNeighborMax, 62 nbNeighbor, 63 localNeighbors); 58 type = 1; 64 59 break; 65 60 default: 66 61 break; 67 62 } 63 64 computeLocalConnectivity(type, domainDestination, nbNeighborMax, nbNeighbor, localNeighbors); 68 65 } 69 66 70 void CDomainAlgorithmComputeConnectivity::computeNodeConnectivity(CDomain* domain, 67 /*! 68 * Compute local connectivity of a domain 69 * \param[in] type type of connectivity (node or edge) 70 * \param[in] domain domain on which we calculate local connectivity 71 * \param[in/out] nbConnectivityMax maximum number of neighbor a cell of domain has 72 * \param[in/out] nbConnectivity number of neighbor a cell has 73 * \param[in/out] localConnectivity localConnectivity local index of neighbor of a cell 74 */ 75 void CDomainAlgorithmComputeConnectivity::computeLocalConnectivity(int type, 76 CDomain* domain, 71 77 int& nbConnectivityMax, 72 78 CArray<int,1>& nbConnectivity, 73 79 CArray<int,2>& localConnectivity) 74 80 { 81 75 82 CMesh mesh; 76 CArray<double,1>& lon = domain->lonvalue_1d; 77 CArray<double,1>& lat = domain->latvalue_1d; 83 78 84 CArray<double,2>& bounds_lon = domain->bounds_lon_1d; 79 85 CArray<double,2>& bounds_lat = domain->bounds_lat_1d; 80 mesh.createMesh(lon, lat, bounds_lon, bounds_lat); 81 CArray<int, 2>& face_nodes = mesh.face_nodes; 82 int nvertex = mesh.nvertex; 83 int nFaces = mesh.nbFaces; 84 int nNodes = mesh.nbNodes; 85 std::vector<std::vector<size_t> > nodeFaceConnectivity(nNodes, std::vector<size_t>()); 86 for (int nf = 0; nf < nFaces; ++nf) 87 { 88 for (int nv = 0; nv < nvertex; ++nv) 89 { 90 nodeFaceConnectivity[face_nodes(nv,nf)].push_back(nf); 91 } 92 } 86 int ncell = bounds_lon.shape()[1]; 87 CArray<int,1> localIndex(ncell); 88 for (int idx = 0; idx <ncell; ++idx) localIndex(idx) = idx; 93 89 94 if (nFaces != nbConnectivity.numElements()) nbConnectivity.resize(nFaces); 95 nbConnectivityMax = 1; 96 for (int nf = 0; nf < nFaces; ++nf) 97 { 98 std::set<size_t> neighFaces; 99 for (int nv = 0; nv < nvertex; ++nv) 100 { 101 std::vector<size_t>& tmpFaces = nodeFaceConnectivity[face_nodes(nv,nf)]; 102 for (int nFn = 0; nFn < tmpFaces.size(); ++nFn) 103 { 104 neighFaces.insert(tmpFaces[nFn]); 105 } 106 } 107 if (nbConnectivityMax < (neighFaces.size()-1)) nbConnectivityMax = neighFaces.size()-1; 108 } 109 if ((nbConnectivityMax != localConnectivity.shape()[0]) || (nFaces != localConnectivity.shape()[1])) 110 localConnectivity.resize(nbConnectivityMax, nFaces); 111 112 for (int nf = 0; nf < nFaces; ++nf) 113 { 114 std::set<size_t> neighFaces; 115 for (int nv = 0; nv < nvertex; ++nv) 116 { 117 std::vector<size_t>& tmpFaces = nodeFaceConnectivity[face_nodes(nv,nf)]; 118 for (int nFn = 0; nFn < tmpFaces.size(); ++nFn) 119 { 120 neighFaces.insert(tmpFaces[nFn]); 121 } 122 } 123 124 neighFaces.erase(nf); 125 nbConnectivity(nf) = neighFaces.size(); 126 std::set<size_t>::iterator it = neighFaces.begin(), ite = neighFaces.end(); 127 for (int idx = 0; it != ite; ++it, ++idx) 128 { 129 localConnectivity(idx, nf) = *it; 130 } 131 } 90 mesh.getLocalNghbFaces(type, localIndex, bounds_lon, bounds_lat, localConnectivity, nbConnectivity); 91 nbConnectivityMax = 0; 92 for (int idx =0; idx < nbConnectivity.numElements(); ++idx) 93 if (nbConnectivityMax < nbConnectivity(idx)) nbConnectivityMax = nbConnectivity(idx); 132 94 } 133 95 134 void CDomainAlgorithmComputeConnectivity::computeEdgeConnectivity(CDomain* domain,135 int& nbConnectivityMax,136 CArray<int,1>& nbConnectivity,137 CArray<int,2>& localConnectivity)138 {139 CMesh mesh;140 CArray<double,1>& lon = domain->lonvalue_1d;141 CArray<double,1>& lat = domain->latvalue_1d;142 CArray<double,2>& bounds_lon = domain->bounds_lon_1d;143 CArray<double,2>& bounds_lat = domain->bounds_lat_1d;144 mesh.createMesh(lon, lat, bounds_lon, bounds_lat);145 96 146 CArray<int, 2>& face_edges = mesh.face_edges;147 int nvertex = mesh.nvertex;148 int nFaces = mesh.nbFaces;149 int nEdges = mesh.nbEdges;150 std::vector<std::vector<size_t> > edgeFaceConnectivity(nEdges, std::vector<size_t>());151 for (int nf = 0; nf < nFaces; ++nf)152 {153 for (int nv = 0; nv < nvertex; ++nv)154 {155 edgeFaceConnectivity[face_edges(nv,nf)].push_back(nf);156 }157 }158 159 if (nFaces != nbConnectivity.numElements()) nbConnectivity.resize(nFaces);160 nbConnectivityMax = 1;161 for (int nf = 0; nf < nFaces; ++nf)162 {163 std::set<size_t> neighFaces;164 for (int nv = 0; nv < nvertex; ++nv)165 {166 std::vector<size_t>& tmpFaces = edgeFaceConnectivity[face_edges(nv,nf)];167 for (int nFn = 0; nFn < tmpFaces.size(); ++nFn)168 {169 neighFaces.insert(tmpFaces[nFn]);170 }171 }172 if (nbConnectivityMax < (neighFaces.size()-1)) nbConnectivityMax = neighFaces.size() - 1;173 }174 if ((nbConnectivityMax != localConnectivity.shape()[0]) || (nFaces != localConnectivity.shape()[1]))175 localConnectivity.resize(nbConnectivityMax, nFaces);176 177 for (int nf = 0; nf < nFaces; ++nf)178 {179 std::set<size_t> neighFaces;180 for (int nv = 0; nv < nvertex; ++nv)181 {182 std::vector<size_t>& tmpFaces = edgeFaceConnectivity[face_edges(nv,nf)];183 for (int nFn = 0; nFn < tmpFaces.size(); ++nFn)184 {185 neighFaces.insert(tmpFaces[nFn]);186 }187 }188 189 neighFaces.erase(nf);190 nbConnectivity(nf) = neighFaces.size();191 std::set<size_t>::iterator it = neighFaces.begin(), ite = neighFaces.end();192 for (int idx = 0; it != ite; ++it, ++idx)193 {194 localConnectivity(idx, nf) = *it;195 }196 }197 198 }199 97 200 98 /*! … … 203 101 void CDomainAlgorithmComputeConnectivity::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 204 102 { 205 206 103 } 207 104
Note: See TracChangeset
for help on using the changeset viewer.