Changeset 1642 for XIOS/dev/branch_openmp/src/node/mesh.cpp
- Timestamp:
- 01/23/19 10:31:44 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/src/node/mesh.cpp
r1545 r1642 6 6 7 7 #include "mesh.hpp" 8 using namespace ep_lib;9 8 #include <boost/functional/hash.hpp> 9 //#include <unordered_map> 10 10 11 11 namespace xios { … … 33 33 } 34 34 35 std::map <StdString, CMesh> *CMesh::meshList_ptr = 0;36 std::map <StdString, vector<int> > *CMesh::domainList_ptr = 0;35 std::map <StdString, CMesh> CMesh::meshList = std::map <StdString, CMesh>(); 36 std::map <StdString, vector<int> > CMesh::domainList = std::map <StdString, vector<int> >(); 37 37 38 38 ///--------------------------------------------------------------- … … 45 45 CMesh* CMesh::getMesh (StdString meshName, int nvertex) 46 46 { 47 if(CMesh::domainList_ptr == NULL) CMesh::domainList_ptr = new std::map <StdString, vector<int> >(); 48 if(CMesh::meshList_ptr == NULL) CMesh::meshList_ptr = new std::map <StdString, CMesh>(); 49 50 CMesh::domainList_ptr->at(meshName).push_back(nvertex); 51 52 if ( CMesh::meshList_ptr->begin() != CMesh::meshList_ptr->end() ) 53 { 54 for (std::map<StdString, CMesh>::iterator it=CMesh::meshList_ptr->begin(); it!=CMesh::meshList_ptr->end(); ++it) 47 CMesh::domainList[meshName].push_back(nvertex); 48 49 if ( CMesh::meshList.begin() != CMesh::meshList.end() ) 50 { 51 for (std::map<StdString, CMesh>::iterator it=CMesh::meshList.begin(); it!=CMesh::meshList.end(); ++it) 55 52 { 56 53 if (it->first == meshName) 57 return &meshList _ptr->at(meshName);54 return &meshList[meshName]; 58 55 else 59 56 { 60 57 CMesh newMesh; 61 CMesh::meshList _ptr->insert( make_pair(meshName, newMesh) );62 return &meshList _ptr->at(meshName);58 CMesh::meshList.insert( make_pair(meshName, newMesh) ); 59 return &meshList[meshName]; 63 60 } 64 61 } … … 67 64 { 68 65 CMesh newMesh; 69 CMesh::meshList _ptr->insert( make_pair(meshName, newMesh) );70 return &meshList _ptr->at(meshName);66 CMesh::meshList.insert( make_pair(meshName, newMesh) ); 67 return &meshList[meshName]; 71 68 } 72 69 } … … 227 224 * \param [in] bounds_lat Array of boundary latitudes. Its size depends on the element type. 228 225 */ 226 // void CMesh::createMesh(const CArray<double, 1>& lonvalue, const CArray<double, 1>& latvalue, 227 // const CArray<double, 2>& bounds_lon, const CArray<double, 2>& bounds_lat) 228 // { 229 // int nvertex = (bounds_lon.numElements() == 0) ? 1 : bounds_lon.rows(); 230 // 231 // if (nvertex == 1) 232 // { 233 // nbNodes_ = lonvalue.numElements(); 234 // node_lon.resizeAndPreserve(nbNodes_); 235 // node_lat.resizeAndPreserve(nbNodes_); 236 // for (int nn = 0; nn < nbNodes_; ++nn) 237 // { 238 // if (map_nodes.find(make_pair (lonvalue(nn), latvalue(nn))) == map_nodes.end()) 239 // { 240 // map_nodes[make_pair (lonvalue(nn), latvalue(nn))] = nn ; 241 // node_lon(nn) = lonvalue(nn); 242 // node_lat(nn) = latvalue(nn); 243 // } 244 // } 245 // } 246 // else if (nvertex == 2) 247 // { 248 // nbEdges_ = bounds_lon.shape()[1]; 249 // 250 // // Create nodes and edge_node connectivity 251 // node_lon.resizeAndPreserve(nbEdges_*nvertex); // Max possible number of nodes 252 // node_lat.resizeAndPreserve(nbEdges_*nvertex); 253 // edge_nodes.resizeAndPreserve(nvertex, nbEdges_); 254 // 255 // for (int ne = 0; ne < nbEdges_; ++ne) 256 // { 257 // for (int nv = 0; nv < nvertex; ++nv) 258 // { 259 // if (map_nodes.find(make_pair (bounds_lon(nv, ne), bounds_lat(nv ,ne))) == map_nodes.end()) 260 // { 261 // map_nodes[make_pair (bounds_lon(nv, ne), bounds_lat(nv, ne))] = nbNodes_ ; 262 // edge_nodes(nv,ne) = nbNodes_ ; 263 // node_lon(nbNodes_) = bounds_lon(nv, ne); 264 // node_lat(nbNodes_) = bounds_lat(nv, ne); 265 // ++nbNodes_ ; 266 // } 267 // else 268 // edge_nodes(nv,ne) = map_nodes[make_pair (bounds_lon(nv, ne), bounds_lat(nv ,ne))]; 269 // } 270 // } 271 // node_lon.resizeAndPreserve(nbNodes_); 272 // node_lat.resizeAndPreserve(nbNodes_); 273 // 274 // // Create edges 275 // edge_lon.resizeAndPreserve(nbEdges_); 276 // edge_lat.resizeAndPreserve(nbEdges_); 277 // 278 // for (int ne = 0; ne < nbEdges_; ++ne) 279 // { 280 // if (map_edges.find(make_ordered_pair (edge_nodes(0,ne), edge_nodes(1,ne))) == map_edges.end()) 281 // { 282 // map_edges[make_ordered_pair ( edge_nodes(0,ne), edge_nodes(1,ne) )] = ne ; 283 // edge_lon(ne) = lonvalue(ne); 284 // edge_lat(ne) = latvalue(ne); 285 // } 286 // 287 // } 288 // edgesAreWritten = true; 289 // } 290 // else 291 // { 292 // nbFaces_ = bounds_lon.shape()[1]; 293 // 294 // // Create nodes and face_node connectivity 295 // node_lon.resizeAndPreserve(nbFaces_*nvertex); // Max possible number of nodes 296 // node_lat.resizeAndPreserve(nbFaces_*nvertex); 297 // face_nodes.resize(nvertex, nbFaces_); 298 // 299 // for (int nf = 0; nf < nbFaces_; ++nf) 300 // { 301 // for (int nv = 0; nv < nvertex; ++nv) 302 // { 303 // if (map_nodes.find(make_pair (bounds_lon(nv, nf), bounds_lat(nv ,nf))) == map_nodes.end()) 304 // { 305 // map_nodes[make_pair (bounds_lon(nv, nf), bounds_lat(nv, nf))] = nbNodes_ ; 306 // face_nodes(nv,nf) = nbNodes_ ; 307 // node_lon(nbNodes_) = bounds_lon(nv, nf); 308 // node_lat(nbNodes_) = bounds_lat(nv ,nf); 309 // ++nbNodes_ ; 310 // } 311 // else 312 // { 313 // face_nodes(nv,nf) = map_nodes[make_pair (bounds_lon(nv, nf), bounds_lat(nv ,nf))]; 314 // } 315 // } 316 // } 317 // node_lon.resizeAndPreserve(nbNodes_); 318 // node_lat.resizeAndPreserve(nbNodes_); 319 // 320 // // Create edges and edge_nodes connectivity 321 // edge_lon.resizeAndPreserve(nbFaces_*nvertex); // Max possible number of edges 322 // edge_lat.resizeAndPreserve(nbFaces_*nvertex); 323 // edge_nodes.resizeAndPreserve(2, nbFaces_*nvertex); 324 // edge_faces.resize(2, nbFaces_*nvertex); 325 // face_edges.resize(nvertex, nbFaces_); 326 // face_faces.resize(nvertex, nbFaces_); 327 // 328 // vector<int> countEdges(nbFaces_*nvertex); // needed in case if edges have been already generated 329 // vector<int> countFaces(nbFaces_); 330 // countEdges.assign(nbFaces_*nvertex, 0); 331 // countFaces.assign(nbFaces_, 0); 332 // int edge; 333 // for (int nf = 0; nf < nbFaces_; ++nf) 334 // { 335 // for (int nv1 = 0; nv1 < nvertex; ++nv1) 336 // { 337 // int nv = 0; 338 // int nv2 = (nv1 < nvertex -1 ) ? (nv1 + 1) : (nv1 + 1 - nvertex); // cyclic rotation 339 // if (map_edges.find(make_ordered_pair (face_nodes(nv1,nf), face_nodes(nv2,nf))) == map_edges.end()) 340 // { 341 // map_edges[make_ordered_pair (face_nodes(nv1,nf), face_nodes(nv2,nf))] = nbEdges_ ; 342 // face_edges(nv1,nf) = map_edges[make_ordered_pair (face_nodes(nv1,nf), face_nodes(nv2,nf))]; 343 // edge_faces(0,nbEdges_) = nf; 344 // edge_faces(1,nbEdges_) = -999; 345 // face_faces(nv1,nf) = 999999; 346 // edge_nodes(Range::all(),nbEdges_) = face_nodes(nv1,nf), face_nodes(nv2,nf); 347 // edge_lon(nbEdges_) = ( abs( node_lon(face_nodes(nv1,nf)) - node_lon(face_nodes(nv2,nf))) < 180.) ? 348 // (( node_lon(face_nodes(nv1,nf)) + node_lon(face_nodes(nv2,nf))) * 0.5) : 349 // (( node_lon(face_nodes(nv1,nf)) + node_lon(face_nodes(nv2,nf))) * 0.5 -180.); 350 // edge_lat(nbEdges_) = ( node_lat(face_nodes(nv1,nf)) + node_lat(face_nodes(nv2,nf)) ) * 0.5; 351 // ++nbEdges_; 352 // } 353 // else 354 // { 355 // edge = map_edges[make_ordered_pair (face_nodes(nv1,nf), face_nodes(nv2,nf))]; 356 // face_edges(nv1,nf) = edge; 357 // if (edgesAreWritten) 358 // { 359 // edge_faces(countEdges[edge], edge) = nf; 360 // if (countEdges[edge]==0) 361 // { 362 // face_faces(nv1,nf) = 999999; 363 // } 364 // else 365 // { 366 // int face1 = nf; // = edge_faces(1,edge) 367 // int face2 = edge_faces(0,edge); 368 // face_faces(countFaces[face1], face1) = face2; 369 // face_faces(countFaces[face2], face2) = face1; 370 // ++(countFaces[face1]); 371 // ++(countFaces[face2]); 372 // } 373 // } 374 // else 375 // { 376 // edge_faces(1,edge) = nf; 377 // int face1 = nf; // = edge_faces(1,edge) 378 // int face2 = edge_faces(0,edge); 379 // face_faces(countFaces[face1], face1) = face2; 380 // face_faces(countFaces[face2], face2) = face1; 381 // ++(countFaces[face1]); 382 // ++(countFaces[face2]); 383 // } 384 // ++(countEdges[edge]); 385 // } 386 // } 387 // } 388 // edge_nodes.resizeAndPreserve(2, nbEdges_); 389 // edge_faces.resizeAndPreserve(2, nbEdges_); 390 // edge_lon.resizeAndPreserve(nbEdges_); 391 // edge_lat.resizeAndPreserve(nbEdges_); 392 // 393 // // Create faces 394 // face_lon.resize(nbFaces_); 395 // face_lat.resize(nbFaces_); 396 // face_lon = lonvalue; 397 // face_lat = latvalue; 398 // facesAreWritten = true; 399 // 400 // } // nvertex > 2 401 // 402 // } // createMesh() 229 403 230 404 ///---------------------------------------------------------------- … … 240 414 * \param [in] bounds_lat Array of boundary latitudes. Its size depends on the element type. 241 415 */ 242 void CMesh::createMeshEpsilon(const MPI_Comm& comm,416 void CMesh::createMeshEpsilon(const ep_lib::MPI_Comm& comm, 243 417 const CArray<double, 1>& lonvalue, const CArray<double, 1>& latvalue, 244 418 const CArray<double, 2>& bounds_lon, const CArray<double, 2>& bounds_lat) … … 247 421 int nvertex = (bounds_lon.numElements() == 0) ? 1 : bounds_lon.rows(); 248 422 int mpiRank, mpiSize; 249 MPI_Comm_rank(comm, &mpiRank);250 MPI_Comm_size(comm, &mpiSize);423 ep_lib::MPI_Comm_rank(comm, &mpiRank); 424 ep_lib::MPI_Comm_size(comm, &mpiSize); 251 425 double prec = 1e-11; // used in calculations of edge_lon/lat 252 426 … … 286 460 unsigned long nbEdgesOnProc = nbEdges_; 287 461 unsigned long nbEdgesAccum; 288 MPI_Scan(&nbEdgesOnProc, &nbEdgesAccum, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm);462 ep_lib::MPI_Scan(&nbEdgesOnProc, &nbEdgesAccum, 1, EP_UNSIGNED_LONG, EP_SUM, comm); 289 463 nbEdgesAccum -= nbEdges_; 290 464 … … 416 590 unsigned long nodeCount = nodeIdx2Idx.size(); 417 591 unsigned long nodeStart, nbNodes; 418 MPI_Scan(&nodeCount, &nodeStart, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm);592 ep_lib::MPI_Scan(&nodeCount, &nodeStart, 1, EP_UNSIGNED_LONG, EP_SUM, comm); 419 593 int nNodes = nodeStart; 420 MPI_Bcast(&nNodes, 1, MPI_UNSIGNED_LONG, mpiSize-1, comm);594 ep_lib::MPI_Bcast(&nNodes, 1, EP_UNSIGNED_LONG, mpiSize-1, comm); 421 595 nbNodesGlo = nNodes; 422 596 … … 509 683 unsigned long nbFacesOnProc = nbFaces_; 510 684 unsigned long nbFacesAccum; 511 MPI_Scan(&nbFacesOnProc, &nbFacesAccum, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm);685 ep_lib::MPI_Scan(&nbFacesOnProc, &nbFacesAccum, 1, EP_UNSIGNED_LONG, EP_SUM, comm); 512 686 nbFacesAccum -= nbFaces_; 513 687 … … 633 807 634 808 unsigned long edgeStart, nbEdges; 635 MPI_Scan(&edgeCount, &edgeStart, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm);809 ep_lib::MPI_Scan(&edgeCount, &edgeStart, 1, EP_UNSIGNED_LONG, EP_SUM, comm); 636 810 int nEdges = edgeStart; 637 MPI_Bcast(&nEdges, 1, MPI_UNSIGNED_LONG, mpiSize-1, comm);811 ep_lib::MPI_Bcast(&nEdges, 1, EP_UNSIGNED_LONG, mpiSize-1, comm); 638 812 nbEdgesGlo = nEdges; 639 813 … … 854 1028 unsigned long edgeCount = edgeIdx2Idx.size(); 855 1029 unsigned long edgeStart, nbEdges; 856 MPI_Scan(&edgeCount, &edgeStart, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm);1030 ep_lib::MPI_Scan(&edgeCount, &edgeStart, 1, EP_UNSIGNED_LONG, EP_SUM, comm); 857 1031 int nEdges = edgeStart; 858 MPI_Bcast(&nEdges, 1, MPI_UNSIGNED_LONG, mpiSize-1, comm);1032 ep_lib::MPI_Bcast(&nEdges, 1, EP_UNSIGNED_LONG, mpiSize-1, comm); 859 1033 nbEdgesGlo = nEdges; 860 1034 … … 1124 1298 unsigned long nodeCount = nodeIdx2Idx.size(); 1125 1299 unsigned long nodeStart, nbNodes; 1126 MPI_Scan(&nodeCount, &nodeStart, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm);1300 ep_lib::MPI_Scan(&nodeCount, &nodeStart, 1, EP_UNSIGNED_LONG, EP_SUM, comm); 1127 1301 int nNodes = nodeStart; 1128 MPI_Bcast(&nNodes, 1, MPI_UNSIGNED_LONG, mpiSize-1, comm);1302 ep_lib::MPI_Bcast(&nNodes, 1, EP_UNSIGNED_LONG, mpiSize-1, comm); 1129 1303 nbNodesGlo = nNodes; 1130 1304 … … 1244 1418 unsigned long edgeCount = edgeIdx2Idx.size(); 1245 1419 unsigned long edgeStart, nbEdges; 1246 MPI_Scan(&edgeCount, &edgeStart, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm);1420 ep_lib::MPI_Scan(&edgeCount, &edgeStart, 1, EP_UNSIGNED_LONG, EP_SUM, comm); 1247 1421 int nEdges = edgeStart; 1248 MPI_Bcast(&nEdges, 1, MPI_UNSIGNED_LONG, mpiSize-1, comm);1422 ep_lib::MPI_Bcast(&nEdges, 1, EP_UNSIGNED_LONG, mpiSize-1, comm); 1249 1423 nbEdgesGlo = nEdges; 1250 1424 … … 1440 1614 */ 1441 1615 1442 void CMesh::getGloNghbFacesNodeType(const MPI_Comm& comm, const CArray<int, 1>& face_idx,1616 void CMesh::getGloNghbFacesNodeType(const ep_lib::MPI_Comm& comm, const CArray<int, 1>& face_idx, 1443 1617 const CArray<double, 2>& bounds_lon, const CArray<double, 2>& bounds_lat, 1444 1618 CArray<int, 2>& nghbFaces) … … 1449 1623 1450 1624 int mpiRank, mpiSize; 1451 MPI_Comm_rank(comm, &mpiRank);1452 MPI_Comm_size(comm, &mpiSize);1625 ep_lib::MPI_Comm_rank(comm, &mpiRank); 1626 ep_lib::MPI_Comm_size(comm, &mpiSize); 1453 1627 1454 1628 // (1) Generating unique node indexes … … 1596 1770 */ 1597 1771 1598 void CMesh::getGloNghbFacesEdgeType(const MPI_Comm& comm, const CArray<int, 1>& face_idx,1772 void CMesh::getGloNghbFacesEdgeType(const ep_lib::MPI_Comm& comm, const CArray<int, 1>& face_idx, 1599 1773 const CArray<double, 2>& bounds_lon, const CArray<double, 2>& bounds_lat, 1600 1774 CArray<int, 2>& nghbFaces) … … 1605 1779 1606 1780 int mpiRank, mpiSize; 1607 MPI_Comm_rank(comm, &mpiRank);1608 MPI_Comm_size(comm, &mpiSize);1781 ep_lib::MPI_Comm_rank(comm, &mpiRank); 1782 ep_lib::MPI_Comm_size(comm, &mpiSize); 1609 1783 1610 1784 // (1) Generating unique node indexes … … 1777 1951 */ 1778 1952 1779 void CMesh::getGlobalNghbFaces(const int nghbType, const MPI_Comm& comm,1953 void CMesh::getGlobalNghbFaces(const int nghbType, const ep_lib::MPI_Comm& comm, 1780 1954 const CArray<int, 1>& face_idx, 1781 1955 const CArray<double, 2>& bounds_lon, const CArray<double, 2>& bounds_lat,
Note: See TracChangeset
for help on using the changeset viewer.