43 #include <boost/config.hpp>
44 #include <boost/graph/adjacency_list.hpp>
45 #include <boost/graph/cuthill_mckee_ordering.hpp>
46 #include <boost/graph/properties.hpp>
47 #include <boost/graph/bandwidth.hpp>
51 namespace MultiRegions
71 const std::string variable):
74 pSession->LoadParameter(
82 const bool checkIfSystemSingular,
88 set<int> &extraDirVerts,
89 set<int> &extraDirEdges,
90 int &firstNonDirGraphVertId,
97 int meshVertId, meshEdgeId, meshFaceId;
98 int meshVertId2, meshEdgeId2;
104 PeriodicMap::const_iterator pIt;
109 for(i = 0; i < bndCondExp.num_elements(); i++)
113 for(k = 0; k < bndConditions.num_elements(); ++k)
115 if (bndConditions[k][i]->GetBoundaryConditionType() ==
120 if (bndConditions[k][i]->GetBoundaryConditionType() !=
129 for (j = 0; j < bndCondExp[i]->GetNumElmts(); ++j)
132 for (k = 0; k < bndExp->GetNverts(); ++k)
134 if (vMaxVertId < bndExp->GetGeom()->GetVid(k))
136 vMaxVertId = bndExp->
GetGeom()->GetVid(k);
143 if(cnt == bndConditions.num_elements())
145 for(j = 0; j < bndCondExp[i]->GetNumElmts(); j++)
147 bndExp = bndCondExp[i]->GetExp(j);
149 for (k = 0; k < bndExp->GetNverts(); k++)
151 meshVertId = bndExp->GetGeom()->GetVid(k);
152 if (graph[0].count(meshVertId) == 0)
154 graph[0][meshVertId] = graphVertId++;
158 for (k = 0; k < bndExp->GetNedges(); k++)
160 meshEdgeId = bndExp->GetGeom()->GetEid(k);
161 if (graph[1].count(meshEdgeId) == 0)
163 graph[1][meshEdgeId] = graphVertId++;
168 meshFaceId = bndExp->GetGeom()->GetGlobalID();
169 const int bndDim = bndExp->GetNumBases();
170 if (graph[bndDim].count(meshFaceId) == 0)
172 graph[bndDim][meshFaceId] = graphVertId++;
207 int n = vComm->GetSize();
208 int p = vComm->GetRank();
217 vertcounts[p] = graph[0].size();
218 edgecounts[p] = graph[1].size();
222 for (i = 1; i < n; ++i)
224 vertoffsets[i] = vertoffsets[i-1] + vertcounts[i-1];
225 edgeoffsets[i] = edgeoffsets[i-1] + edgecounts[i-1];
236 for (it = graph[0].begin(), i = 0;
237 it != graph[0].end();
240 vertlist[vertoffsets[p] + i] = it->first;
244 for (it = graph[1].begin(), i = 0;
245 it != graph[1].end();
248 edgelist[edgeoffsets[p] + i] = it->first;
256 map<int, int> extraDirVertIds, extraDirEdgeIds;
266 for (i = 0; i < n; ++i)
273 for(j = 0; j < locExpVector.size(); j++)
277 for(k = 0; k < exp->GetNverts(); k++)
279 meshVertId = exp->GetGeom()->GetVid(k);
280 if(graph[0].count(meshVertId) == 0)
282 for (l = 0; l < vertcounts[i]; ++l)
284 if (vertlist[vertoffsets[i]+l] == meshVertId)
286 extraDirVertIds[meshVertId] = i;
287 graph[0][meshVertId] = graphVertId++;
294 for(k = 0; k < exp->GetNedges(); k++)
296 meshEdgeId = exp->GetGeom()->GetEid(k);
297 if(graph[1].count(meshEdgeId) == 0)
299 for (l = 0; l < edgecounts[i]; ++l)
301 if (edgelist[edgeoffsets[i]+l] == meshEdgeId)
303 extraDirEdgeIds[meshEdgeId] = i;
304 graph[1][meshEdgeId] = graphVertId++;
305 nExtraDirichlet += exp->GetEdgeNcoeffs(k)-2;
315 map<int, int>::const_iterator mapConstIt;
317 for (mapConstIt = extraDirEdgeIds.begin(), i = 0;
318 mapConstIt != extraDirEdgeIds.end(); mapConstIt++)
320 meshEdgeId = mapConstIt->first;
330 for (i = 0; i < n; ++i)
338 vertcounts[p] = extraDirVertIds.size();
339 edgecounts[p] = extraDirEdgeIds.size();
345 vertoffsets[0] = edgeoffsets[0] = 0;
347 for (i = 1; i < n; ++i)
349 vertoffsets[i] = vertoffsets[i-1] + vertcounts[i-1];
350 edgeoffsets[i] = edgeoffsets[i-1] + edgecounts[i-1];
358 for (it = extraDirVertIds.begin(), i = 0;
359 it != extraDirVertIds.end(); ++it, ++i)
361 vertids [vertoffsets[p]+i] = it->first;
362 vertprocs[vertoffsets[p]+i] = it->second;
365 for (it = extraDirEdgeIds.begin(), i = 0;
366 it != extraDirEdgeIds.end(); ++it, ++i)
368 edgeids [edgeoffsets[p]+i] = it->first;
369 edgeprocs[edgeoffsets[p]+i] = it->second;
379 for (i = 0; i < nTotVerts; ++i)
381 if (vComm->GetRank() == vertprocs[i])
383 extraDirVerts.insert(vertids[i]);
388 for (i = 0; i < nTotEdges; ++i)
390 if (vComm->GetRank() == edgeprocs[i])
392 extraDirEdges.insert(edgeids[i]);
403 bcminvertid[p] = vMaxVertId;
418 if (
m_session->DefinesParameter(
"SingularVertex"))
420 m_session->LoadParameter(
"SingularVertex", meshVertId);
422 else if (vMaxVertId == -1)
425 meshVertId = locExpVector[0]->GetGeom()->GetVid(0);
431 meshVertId = bcminvertid[p];
434 if (graph[0].count(meshVertId) == 0)
436 graph[0][meshVertId] = graphVertId++;
452 for (i = 0; i < locExpVector.size(); ++i)
454 for (j = 0; j < locExpVector[i]->GetNverts(); ++j)
456 if (locExpVector[i]->GetGeom()->GetVid(j) !=
462 if (graph[0].count(meshVertId) == 0)
464 graph[0][meshVertId] =
480 if (graph[0].count(meshVertId) == 0)
486 gId = graph[0][meshVertId];
489 for (pIt = periodicVerts.begin();
490 pIt != periodicVerts.end(); ++pIt)
497 if (pIt->first == meshVertId)
499 graph[0][meshVertId] = gId < 0 ? graphVertId++ : gId;
501 for (i = 0; i < pIt->second.size(); ++i)
503 if (pIt->second[i].isLocal)
505 graph[0][pIt->second[i].id] = gId;
512 for (i = 0; i < pIt->second.size(); ++i)
514 if (pIt->second[i].id == meshVertId)
523 graph[0][pIt->first] = gId < 0 ? graphVertId++ : gId;
525 for (i = 0; i < pIt->second.size(); ++i)
527 if (pIt->second[i].isLocal)
529 graph[0][pIt->second[i].id] = gId;
539 firstNonDirGraphVertId = graphVertId;
541 typedef boost::adjacency_list<
542 boost::setS, boost::vecS, boost::undirectedS> BoostGraph;
543 BoostGraph boostGraphObj;
545 vector<map<int,int> > tempGraph(3);
546 map<int, int> vwgts_map;
551 int tempGraphVertId = 0;
552 int localVertOffset = 0;
553 int localEdgeOffset = 0;
554 int localFaceOffset = 0;
572 map<int,int> EdgeSize;
573 map<int,int> FaceSize;
576 for(i = 0; i < locExpVector.size(); ++i)
579 nTotalVerts += exp->GetNverts();
580 nTotalEdges += exp->GetNedges();
581 nTotalFaces += exp->GetNfaces();
583 nEdges = exp->GetNedges();
584 for(j = 0; j < nEdges; ++j)
586 meshEdgeId = exp->GetGeom()->GetEid(j);
587 EdgeSize[meshEdgeId] = exp->GetEdgeNcoeffs(j) - 2;
590 nFaces = exp->GetNfaces();
592 for(j = 0; j < nFaces; ++j)
594 meshFaceId = exp->GetGeom()->GetFid(j);
595 FaceSize[meshFaceId] = exp->GetFaceIntNcoeffs(j);
600 for (pIt = periodicVerts.begin(); pIt != periodicVerts.end(); ++pIt)
602 meshVertId = pIt->first;
605 if (graph[0].count(pIt->first) != 0)
607 for (i = 0; i < pIt->second.size(); ++i)
609 meshVertId2 = pIt->second[i].id;
610 if (graph[0].count(meshVertId2) == 0 &&
611 pIt->second[i].isLocal)
613 graph[0][meshVertId2] =
614 graph[0][meshVertId];
621 bool isDirichlet =
false;
622 for (i = 0; i < pIt->second.size(); ++i)
624 if (!pIt->second[i].isLocal)
629 meshVertId2 = pIt->second[i].id;
630 if (graph[0].count(meshVertId2) > 0)
639 graph[0][meshVertId] =
640 graph[0][pIt->second[i].id];
642 for (j = 0; j < pIt->second.size(); ++j)
644 meshVertId2 = pIt->second[i].id;
645 if (j == i || !pIt->second[j].isLocal ||
646 graph[0].count(meshVertId2) > 0)
651 graph[0][meshVertId2] =
652 graph[0][pIt->second[i].id];
659 for (i = 0; i < pIt->second.size(); ++i)
661 if (!pIt->second[i].isLocal)
666 if (tempGraph[0].count(pIt->second[i].id) > 0)
672 if (i == pIt->second.size())
674 tempGraph[0][meshVertId] = tempGraphVertId++;
679 tempGraph[0][meshVertId] = tempGraph[0][pIt->second[i].id];
690 for(i = 0; i < locExpVector.size(); ++i)
692 exp = locExpVector[i];
694 nVerts = exp->GetNverts();
695 for(j = 0; j < nVerts; ++j)
697 meshVertId = exp->GetGeom()->GetVid(j);
698 if(graph[0].count(meshVertId) == 0)
700 if(tempGraph[0].count(meshVertId) == 0)
702 boost::add_vertex(boostGraphObj);
703 tempGraph[0][meshVertId] = tempGraphVertId++;
706 localVerts[localVertOffset+vertCnt++] = tempGraph[0][meshVertId];
707 vwgts_map[ tempGraph[0][meshVertId] ] = 1;
711 localVertOffset+=nVerts;
715 for (pIt = periodicEdges.begin(); pIt != periodicEdges.end(); ++pIt)
717 meshEdgeId = pIt->first;
720 if (graph[1].count(pIt->first) != 0)
722 for (i = 0; i < pIt->second.size(); ++i)
724 meshEdgeId2 = pIt->second[i].id;
725 if (graph[1].count(meshEdgeId2) == 0 &&
726 pIt->second[i].isLocal)
728 graph[1][meshEdgeId2] =
729 graph[1][meshEdgeId];
736 bool isDirichlet =
false;
737 for (i = 0; i < pIt->second.size(); ++i)
739 if (!pIt->second[i].isLocal)
744 meshEdgeId2 = pIt->second[i].id;
745 if (graph[1].count(meshEdgeId2) > 0)
754 graph[1][meshEdgeId] =
755 graph[1][pIt->second[i].id];
757 for (j = 0; j < pIt->second.size(); ++j)
759 meshEdgeId2 = pIt->second[i].id;
760 if (j == i || !pIt->second[j].isLocal ||
761 graph[1].count(meshEdgeId2) > 0)
766 graph[1][meshEdgeId2] =
767 graph[1][pIt->second[i].id];
774 for (i = 0; i < pIt->second.size(); ++i)
776 if (!pIt->second[i].isLocal)
781 if (tempGraph[1].count(pIt->second[i].id) > 0)
787 if (i == pIt->second.size())
789 tempGraph[1][meshEdgeId] = tempGraphVertId++;
795 tempGraph[1][meshEdgeId] = tempGraph[1][pIt->second[i].id];
799 int nEdgeIntCoeffs, nFaceIntCoeffs;
802 for(i = 0; i < locExpVector.size(); ++i)
804 exp = locExpVector[i];
806 nEdges = exp->GetNedges();
808 for(j = 0; j < nEdges; ++j)
810 nEdgeIntCoeffs = exp->GetEdgeNcoeffs(j) - 2;
811 meshEdgeId = exp->GetGeom()->GetEid(j);
812 if(graph[1].count(meshEdgeId) == 0)
814 if(tempGraph[1].count(meshEdgeId) == 0)
816 boost::add_vertex(boostGraphObj);
817 tempGraph[1][meshEdgeId] = tempGraphVertId++;
822 localEdges[localEdgeOffset+edgeCnt++] = tempGraph[1][meshEdgeId];
823 vwgts_map[ tempGraph[1][meshEdgeId] ] = nEdgeIntCoeffs;
827 localEdgeOffset+=nEdges;
831 for (pIt = periodicFaces.begin(); pIt != periodicFaces.end(); ++pIt)
833 if (!pIt->second[0].isLocal)
836 meshFaceId = pIt->first;
837 ASSERTL0(graph[2].count(meshFaceId) == 0,
838 "This periodic boundary edge has been specified before");
839 tempGraph[2][meshFaceId] = tempGraphVertId++;
840 nFaceIntCoeffs = FaceSize[meshFaceId];
844 else if (pIt->first < pIt->second[0].id)
846 ASSERTL0(graph[2].count(pIt->first) == 0,
847 "This periodic boundary face has been specified before");
848 ASSERTL0(graph[2].count(pIt->second[0].id) == 0,
849 "This periodic boundary face has been specified before");
851 tempGraph[2][pIt->first] = tempGraphVertId;
852 tempGraph[2][pIt->second[0].id] = tempGraphVertId++;
853 nFaceIntCoeffs = FaceSize[pIt->first];
860 for(i = 0; i < locExpVector.size(); ++i)
862 exp = locExpVector[i];
863 nFaces = exp->GetNfaces();
865 for(j = 0; j < nFaces; ++j)
867 nFaceIntCoeffs = exp->GetFaceIntNcoeffs(j);
868 meshFaceId = exp->GetGeom()->GetFid(j);
869 if(graph[2].count(meshFaceId) == 0)
871 if(tempGraph[2].count(meshFaceId) == 0)
873 boost::add_vertex(boostGraphObj);
874 tempGraph[2][meshFaceId] = tempGraphVertId++;
879 localFaces[localFaceOffset+faceCnt++] = tempGraph[2][meshFaceId];
880 vwgts_map[ tempGraph[2][meshFaceId] ] = nFaceIntCoeffs;
885 localFaceOffset+=nFaces;
891 for(i = 0; i < locExpVector.size(); ++i)
893 exp = locExpVector[i];
894 nVerts = exp->GetNverts();
895 nEdges = exp->GetNedges();
896 nFaces = exp->GetNfaces();
903 for(j = 0; j < nVerts; j++)
905 if(localVerts[j+localVertOffset]==-1)
910 for(k = 0; k < nVerts; k++)
912 if(localVerts[k+localVertOffset]==-1)
918 boost::add_edge( (
size_t) localVerts[j+localVertOffset],
919 (
size_t) localVerts[k+localVertOffset],boostGraphObj);
923 for(k = 0; k < nEdges; k++)
925 if(localEdges[k+localEdgeOffset]==-1)
929 boost::add_edge( (
size_t) localVerts[j+localVertOffset],
930 (
size_t) localEdges[k+localEdgeOffset],boostGraphObj);
933 for(k = 0; k < nFaces; k++)
935 if(localFaces[k+localFaceOffset]==-1)
939 boost::add_edge( (
size_t) localVerts[j+localVertOffset],
940 (
size_t) localFaces[k+localFaceOffset],boostGraphObj);
945 for(j = 0; j < nEdges; j++)
947 if(localEdges[j+localEdgeOffset]==-1)
952 for(k = 0; k < nEdges; k++)
954 if(localEdges[k+localEdgeOffset]==-1)
960 boost::add_edge( (
size_t) localEdges[j+localEdgeOffset],
961 (
size_t) localEdges[k+localEdgeOffset],boostGraphObj);
965 for(k = 0; k < nVerts; k++)
967 if(localVerts[k+localVertOffset]==-1)
971 boost::add_edge( (
size_t) localEdges[j+localEdgeOffset],
972 (
size_t) localVerts[k+localVertOffset],boostGraphObj);
975 for(k = 0; k < nFaces; k++)
977 if(localFaces[k+localFaceOffset]==-1)
981 boost::add_edge( (
size_t) localEdges[j+localEdgeOffset],
982 (
size_t) localFaces[k+localFaceOffset],boostGraphObj);
987 for(j = 0; j < nFaces; j++)
989 if(localFaces[j+localFaceOffset]==-1)
994 for(k = 0; k < nFaces; k++)
996 if(localFaces[k+localFaceOffset]==-1)
1002 boost::add_edge( (
size_t) localFaces[j+localFaceOffset],
1003 (
size_t) localFaces[k+localFaceOffset],boostGraphObj);
1007 for(k = 0; k < nVerts; k++)
1009 if(localVerts[k+localVertOffset]==-1)
1013 boost::add_edge( (
size_t) localFaces[j+localFaceOffset],
1014 (
size_t) localVerts[k+localVertOffset],boostGraphObj);
1017 for(k = 0; k < nEdges; k++)
1019 if(localEdges[k+localEdgeOffset]==-1)
1023 boost::add_edge( (
size_t) localFaces[j+localFaceOffset],
1024 (
size_t) localEdges[k+localEdgeOffset],boostGraphObj);
1028 localVertOffset+=nVerts;
1029 localEdgeOffset+=nEdges;
1030 localFaceOffset+=nFaces;
1040 vector<long> procVerts, procEdges, procFaces;
1041 set <int> foundVerts, foundEdges, foundFaces;
1046 for(i = cnt = 0; i < locExpVector.size(); ++i)
1049 exp = locExpVector[elmtid];
1050 for (j = 0; j < exp->GetNverts(); ++j)
1052 int vid = exp->GetGeom()->GetVid(j)+1;
1053 if (foundVerts.count(vid) == 0)
1055 procVerts.push_back(vid);
1056 foundVerts.insert(vid);
1060 for (j = 0; j < exp->GetNedges(); ++j)
1062 int eid = exp->GetGeom()->GetEid(j)+1;
1064 if (foundEdges.count(eid) == 0)
1066 procEdges.push_back(eid);
1067 foundEdges.insert(eid);
1071 for (j = 0; j < exp->GetNfaces(); ++j)
1073 int fid = exp->GetGeom()->GetFid(j)+1;
1075 if (foundFaces.count(fid) == 0)
1077 procFaces.push_back(fid);
1078 foundFaces.insert(fid);
1083 int unique_verts = foundVerts.size();
1084 int unique_edges = foundEdges.size();
1085 int unique_faces = foundFaces.size();
1098 if (unique_edges > 0)
1105 if (unique_faces > 0)
1114 for (i = 0; i < unique_verts; ++i)
1118 if (graph[0].count(procVerts[i]-1) == 0)
1120 partVerts.insert(tempGraph[0][procVerts[i]-1]);
1125 for (i = 0; i < unique_edges; ++i)
1129 if (graph[1].count(procEdges[i]-1) == 0)
1131 partVerts.insert(tempGraph[1][procEdges[i]-1]);
1136 for (i = 0; i < unique_faces; ++i)
1140 if (graph[2].count(procFaces[i]-1) == 0)
1142 partVerts.insert(tempGraph[2][procFaces[i]-1]);
1148 int nGraphVerts = tempGraphVertId;
1152 ASSERTL1(vwgts_map.size()==nGraphVerts,
"Non matching dimensions");
1153 for(i = 0; i < nGraphVerts; ++i)
1155 vwgts[i] = vwgts_map[i];
1186 boostGraphObj, perm, iperm, bottomUpGraph,
1187 partVerts, mdswitch);
1193 "Unrecognised solution type: " + std::string(
1218 for(mapIt = tempGraph[0].begin(); mapIt != tempGraph[0].end(); mapIt++)
1220 graph[0][mapIt->first] = iperm[mapIt->second] + graphVertId;
1222 for(mapIt = tempGraph[1].begin(); mapIt != tempGraph[1].end(); mapIt++)
1224 graph[1][mapIt->first] = iperm[mapIt->second] + graphVertId;
1226 for(mapIt = tempGraph[2].begin(); mapIt != tempGraph[2].end(); mapIt++)
1228 graph[2][mapIt->first] = iperm[mapIt->second] + graphVertId;
1239 const int numLocalCoeffs,
1243 const bool checkIfSystemSingular,
1244 const std::string variable,
1253 int meshVertId, meshEdgeId, meshFaceId;
1255 int nEdgeInteriorCoeffs;
1256 int nFaceInteriorCoeffs;
1257 int firstNonDirGraphVertId;
1267 PeriodicMap::const_iterator pIt;
1277 set<int> extraDirVerts, extraDirEdges;
1282 for (i = 0; i < locExpVector.size(); ++i)
1284 exp = locExpVector[i];
1286 for(j = 0; j < locExpVector[i]->GetNverts(); ++j)
1288 dofs[0][exp->GetGeom()->GetVid(j)] = 1;
1291 for(j = 0; j < locExpVector[i]->GetNedges(); ++j)
1293 dofs[1][exp->GetGeom()->GetEid(j)] =
1294 exp->GetEdgeNcoeffs(j) - 2;
1297 for(j = 0; j < locExpVector[i]->GetNfaces(); ++j)
1299 dofs[2][exp->GetGeom()->GetFid(j)] =
1300 exp->GetFaceIntNcoeffs(j);
1309 int nExtraDirichlet;
1312 checkIfSystemSingular, periodicVerts, periodicEdges,
1313 periodicFaces, graph, bottomUpGraph, extraDirVerts,
1314 extraDirEdges, firstNonDirGraphVertId,
1329 graph[0].size() + graph[1].size() + graph[2].size() + 1);
1331 graphVertOffset[0] = 0;
1333 for(i = 0; i < locExpVector.size(); ++i)
1337 for(j = 0; j < exp->GetNverts(); ++j)
1339 meshVertId = exp->GetGeom()->GetVid(j);
1340 graphVertOffset[graph[0][meshVertId]+1] = 1;
1343 for(j = 0; j < exp->GetNedges(); ++j)
1345 nEdgeInteriorCoeffs = exp->GetEdgeNcoeffs(j) - 2;
1346 meshEdgeId = exp->GetGeom()->GetEid(j);
1347 graphVertOffset[graph[1][meshEdgeId]+1]
1348 = nEdgeInteriorCoeffs;
1350 bType = exp->GetEdgeBasisType(j);
1354 if(nEdgeInteriorCoeffs >= 2 &&
1362 for(j = 0; j < exp->GetNfaces(); ++j)
1364 nFaceInteriorCoeffs = exp->GetFaceIntNcoeffs(j);
1365 meshFaceId = exp->GetGeom()->GetFid(j);
1366 graphVertOffset[graph[2][meshFaceId]+1] = nFaceInteriorCoeffs;
1370 for(i = 1; i < graphVertOffset.num_elements(); i++)
1372 graphVertOffset[i] += graphVertOffset[i-1];
1397 m_numLocalIntCoeffsPerPatch[i] = (
unsigned int)
1414 for(i = 0; i < locExpVector.size(); ++i)
1416 exp = locExpVector[i];
1418 for(j = 0; j < exp->GetNverts(); ++j)
1420 meshVertId = exp->GetGeom()->GetVid(j);
1424 graphVertOffset[graph[0][meshVertId]];
1427 for(j = 0; j < exp->GetNedges(); ++j)
1429 nEdgeInteriorCoeffs = exp->GetEdgeNcoeffs(j)-2;
1430 edgeOrient = exp->GetGeom()->GetEorient(j);
1431 meshEdgeId = exp->GetGeom()->GetEid(j);
1433 pIt = periodicEdges.find(meshEdgeId);
1438 if (pIt != periodicEdges.end())
1440 pair<int, StdRegions::Orientation> idOrient =
1442 meshEdgeId, edgeOrient, pIt->second);
1443 edgeOrient = idOrient.second;
1446 exp->GetEdgeInteriorMap(j,edgeOrient,edgeInteriorMap,edgeInteriorSign);
1449 for(k = 0; k < nEdgeInteriorCoeffs; ++k)
1452 graphVertOffset[graph[1][meshEdgeId]]+k;
1458 for(k = 0; k < nEdgeInteriorCoeffs; ++k)
1465 for(j = 0; j < exp->GetNfaces(); ++j)
1467 nFaceInteriorCoeffs = exp->GetFaceIntNcoeffs(j);
1468 faceOrient = exp->GetGeom()->GetForient(j);
1469 meshFaceId = exp->GetGeom()->GetFid(j);
1471 pIt = periodicFaces.find(meshFaceId);
1473 if (pIt != periodicFaces.end() &&
1474 meshFaceId == min(meshFaceId, pIt->second[0].id))
1479 exp->GetFaceInteriorMap(j,faceOrient,faceInteriorMap,faceInteriorSign);
1482 for(k = 0; k < nFaceInteriorCoeffs; ++k)
1485 graphVertOffset[graph[2][meshFaceId]]+k;
1490 for(k = 0; k < nFaceInteriorCoeffs; ++k)
1501 for(i = 0; i < bndCondExp.num_elements(); i++)
1503 set<int> foundExtraVerts, foundExtraEdges;
1504 for(j = 0; j < bndCondExp[i]->GetNumElmts(); j++)
1506 bndExp = bndCondExp[i]->GetExp(j);
1507 cnt = offset + bndCondExp[i]->GetCoeff_Offset(j);
1508 for(k = 0; k < bndExp->GetNverts(); k++)
1510 meshVertId = bndExp->GetGeom()->GetVid(k);
1511 m_bndCondCoeffsToGlobalCoeffsMap[cnt+bndExp->GetVertexMap(k)] = graphVertOffset[graph[0][meshVertId]];
1513 if (bndConditions[i]->GetBoundaryConditionType() !=
1520 if (iter != extraDirVerts.end() &&
1521 foundExtraVerts.count(meshVertId) == 0)
1523 int loc = bndCondExp[i]->GetCoeff_Offset(j) +
1524 bndExp->GetVertexMap(k);
1525 int gid = graphVertOffset[
1526 graph[0][meshVertId]];
1529 foundExtraVerts.insert(meshVertId);
1533 for(k = 0; k < bndExp->GetNedges(); k++)
1535 nEdgeInteriorCoeffs = bndExp->GetEdgeNcoeffs(k)-2;
1536 edgeOrient = bndExp->GetGeom()->GetEorient(k);
1537 meshEdgeId = bndExp->GetGeom()->GetEid(k);
1539 pIt = periodicEdges.find(meshEdgeId);
1544 if (pIt != periodicEdges.end())
1546 pair<int, StdRegions::Orientation> idOrient =
1548 meshEdgeId, edgeOrient, pIt->second);
1549 edgeOrient = idOrient.second;
1552 bndExp->GetEdgeInteriorMap(
1553 k,edgeOrient,edgeInteriorMap,edgeInteriorSign);
1555 for(l = 0; l < nEdgeInteriorCoeffs; ++l)
1557 m_bndCondCoeffsToGlobalCoeffsMap[cnt+edgeInteriorMap[l]] =
1558 graphVertOffset[graph[1][meshEdgeId]]+l;
1564 for(l = 0; l < nEdgeInteriorCoeffs; ++l)
1570 if (bndConditions[i]->GetBoundaryConditionType() !=
1577 if (iter != extraDirEdges.end() &&
1578 foundExtraEdges.count(meshEdgeId) == 0 &&
1579 nEdgeInteriorCoeffs > 0)
1581 for(l = 0; l < nEdgeInteriorCoeffs; ++l)
1583 int loc = bndCondExp[i]->GetCoeff_Offset(j) +
1585 int gid = graphVertOffset[
1586 graph[1][meshEdgeId]]+l;
1590 foundExtraEdges.insert(meshEdgeId);
1594 meshFaceId = bndExp->GetGeom()->GetGlobalID();
1596 for(k = 0; k < bndExp->GetNcoeffs(); k++)
1598 if(m_bndCondCoeffsToGlobalCoeffsMap[cnt+k] == -1)
1600 m_bndCondCoeffsToGlobalCoeffsMap[cnt+k] =
1601 graphVertOffset[graph[bndExp->GetNumBases()][meshFaceId]]+intDofCnt;
1606 offset += bndCondExp[i]->GetNcoeffs();
1646 map<int, vector<ExtraDirDof> >
::iterator Tit;
1651 for (i = 0; i < Tit->second.size(); ++i)
1653 valence[Tit->second[i].get<1>()] = 1.0;
1662 for (i = 0; i < Tit->second.size(); ++i)
1664 boost::get<2>(Tit->second.at(i)) /= valence[Tit->second.at(i).get<1>()];
1678 dofs[0].size() + dofs[1].size() + dofs[2].size()
1679 - firstNonDirGraphVertId);
1681 for (i = 0; i < locExpVector.size(); ++i)
1685 for (j = 0; j < exp->GetNverts(); ++j)
1687 meshVertId = exp->GetGeom()->GetVid(j);
1689 if (graph[0][meshVertId] >= firstNonDirGraphVertId)
1691 vwgts_perm[graph[0][meshVertId] -
1692 firstNonDirGraphVertId] =
1693 dofs[0][meshVertId];
1697 for (j = 0; j < exp->GetNedges(); ++j)
1699 meshEdgeId = exp->GetGeom()->GetEid(j);
1701 if (graph[1][meshEdgeId] >= firstNonDirGraphVertId)
1703 vwgts_perm[graph[1][meshEdgeId] -
1704 firstNonDirGraphVertId] =
1705 dofs[1][meshEdgeId];
1709 for (j = 0; j < exp->GetNfaces(); ++j)
1711 meshFaceId = exp->GetGeom()->GetFid(j);
1713 if (graph[2][meshFaceId] >= firstNonDirGraphVertId)
1715 vwgts_perm[graph[2][meshFaceId] -
1716 firstNonDirGraphVertId] =
1717 dofs[2][meshFaceId];
1722 bottomUpGraph->ExpandGraphWithVertexWeights(vwgts_perm);
1769 const vector<PeriodicEntity> &periodicEdges)
1771 int minId = periodicEdges[0].id;
1775 for (k = 1; k < periodicEdges.size(); ++k)
1777 if (periodicEdges[k].
id < minId)
1779 minId = min(minId, periodicEdges[k].
id);
1784 minId = min(minId, meshEdgeId);
1786 if (meshEdgeId != minId)
1796 return make_pair(minId, edgeOrient);
1822 int tmp1 = (int)faceOrient - 5;
1823 int tmp2 = (int)perFaceOrient - 5;
1825 int flipDir1Map [8] = {2,3,0,1,6,7,4,5};
1826 int flipDir2Map [8] = {1,0,3,2,5,4,7,6};
1827 int transposeMap[8] = {4,5,6,7,0,2,1,3};
1832 tmp1 = transposeMap[tmp1];
1836 if (tmp2 == 2 || tmp2 == 3 || tmp2 == 6 || tmp2 == 7)
1838 tmp1 = flipDir1Map[tmp1];
1844 tmp1 = flipDir2Map[tmp1];
1878 int maxBndGlobalId = 0;
1886 PeriodicMap::const_iterator pIt;
1897 for(i = 0; i < locExpVector.size(); ++i)
1899 exp = locExpVector[i];
1900 nVert += exp->GetNverts();
1901 nEdge += exp->GetNedges();
1902 nFace += exp->GetNfaces();
1904 for(j = 0; j < exp->GetNedges(); ++j)
1906 dof = exp->GetEdgeNcoeffs(j)-2;
1907 maxEdgeDof = (dof > maxEdgeDof ? dof : maxEdgeDof);
1909 for(j = 0; j < exp->GetNfaces(); ++j)
1911 dof = exp->GetFaceIntNcoeffs(j);
1912 maxFaceDof = (dof > maxFaceDof ? dof : maxFaceDof);
1914 exp->GetInteriorMap(interiorMap);
1915 dof = interiorMap.num_elements();
1916 maxIntDof = (dof > maxIntDof ? dof : maxIntDof);
1928 for(i = 0; i < locExpVector.size(); ++i)
1930 exp = locExpVector[i];
1934 for(j = 0; j < exp->GetNverts(); ++j)
1936 meshVertId = exp->GetGeom()->GetVid(j);
1939 pIt = perVerts.find(meshVertId);
1940 if (pIt != perVerts.end())
1942 for (k = 0; k < pIt->second.size(); ++k)
1944 meshVertId = min(meshVertId, pIt->second[k].id);
1950 maxBndGlobalId = (vGlobalId > maxBndGlobalId ? vGlobalId : maxBndGlobalId);
1954 for(j = 0; j < exp->GetNedges(); ++j)
1956 meshEdgeId = exp->GetGeom()->GetEid(j);
1957 pIt = perEdges.find(meshEdgeId);
1958 edgeOrient = exp->GetGeom()->GetEorient(j);
1960 if (pIt != perEdges.end())
1962 pair<int, StdRegions::Orientation> idOrient =
1964 meshEdgeId, edgeOrient, pIt->second);
1965 meshEdgeId = idOrient.first;
1966 edgeOrient = idOrient.second;
1969 exp->GetEdgeInteriorMap(j,edgeOrient,edgeInteriorMap,edgeInteriorSign);
1970 dof = exp->GetEdgeNcoeffs(j)-2;
1973 for(k = 0; k < dof; ++k)
1977 = nVert + meshEdgeId * maxEdgeDof + k + 1;
1979 maxBndGlobalId = (vGlobalId > maxBndGlobalId ? vGlobalId : maxBndGlobalId);
1984 for(j = 0; j < exp->GetNfaces(); ++j)
1986 faceOrient = exp->GetGeom()->GetForient(j);
1988 meshFaceId = exp->GetGeom()->GetFid(j);
1990 pIt = perFaces.find(meshFaceId);
1991 if (pIt != perFaces.end())
1993 if(meshFaceId == min(meshFaceId, pIt->second[0].id))
1997 meshFaceId = min(meshFaceId, pIt->second[0].id);
2001 exp->GetFaceInteriorMap(j,faceOrient,faceInteriorMap,faceInteriorSign);
2002 dof = exp->GetFaceIntNcoeffs(j);
2005 for(k = 0; k < dof; ++k)
2009 = nVert + nEdge*maxEdgeDof + meshFaceId * maxFaceDof
2013 maxBndGlobalId = (vGlobalId > maxBndGlobalId ? vGlobalId : maxBndGlobalId);
2018 exp->GetInteriorMap(interiorMap);
2019 dof = interiorMap.num_elements();
2020 elementId = (exp->GetGeom())->GetGlobalID();
2021 for (k = 0; k < dof; ++k)
2025 = nVert + nEdge*maxEdgeDof + nFace*maxFaceDof + elementId*maxIntDof + k + 1;
2046 m_globalToUniversalMapUnique[i] = (tmp[i] >= 0 ? 1 : 0);
2050 m_globalToUniversalBndMapUnique[i] = (tmp2[i] >= 0 ? 1 : 0);
2069 const boost::shared_ptr<LocalRegions::ExpansionVector> exp
2071 int nelmts = exp->size();
2076 returnval->m_solnType = solnType;
2077 returnval->m_preconType =
eNull;
2078 returnval->m_maxStaticCondLevel = 0;
2079 returnval->m_signChange =
false;
2080 returnval->m_comm =
m_comm;
2083 for (i = 0; i < nelmts; ++i)
2085 nverts += (*exp)[i]->GetNverts();
2088 returnval->m_numLocalCoeffs = nverts;
2099 for (i = 0; i < nelmts; ++i)
2101 for (j = 0; j < (*exp)[i]->GetNverts(); ++j)
2103 returnval->m_localToGlobalMap[cnt] =
2104 returnval->m_localToGlobalBndMap[cnt] =
2106 GlobCoeffs[returnval->m_localToGlobalMap[cnt]] = 1;
2109 if ((returnval->m_localToGlobalMap[cnt]) <
2112 returnval->m_numLocalDirBndCoeffs++;
2116 cnt1 += (*exp)[i]->GetNcoeffs();
2123 if (GlobCoeffs[i] != -1)
2125 GlobCoeffs[i] = cnt++;
2130 returnval->m_numGlobalCoeffs = cnt;
2135 if (GlobCoeffs[i] != -1)
2137 returnval->m_numGlobalDirBndCoeffs++;
2146 int nglocoeffs = returnval->m_numGlobalCoeffs;
2147 returnval->m_globalToUniversalMap
2149 returnval->m_globalToUniversalMapUnique
2153 for (i = 0; i < nverts; ++i)
2155 cnt = returnval->m_localToGlobalMap[i];
2156 returnval->m_localToGlobalMap[i] = GlobCoeffs[cnt];
2158 returnval->m_globalToUniversalMap[GlobCoeffs[cnt]] =
2164 for (
unsigned int i = 0; i < nglocoeffs; ++i)
2166 tmp[i] = returnval->m_globalToUniversalMap[i];
2168 returnval->m_gsh =
Gs::Init(tmp, vCommRow);
2170 for (
unsigned int i = 0; i < nglocoeffs; ++i)
2172 returnval->m_globalToUniversalMapUnique[i]
2173 = (tmp[i] >= 0 ? 1 : 0);
2178 for (i = 0; i < nverts; ++i)
2180 cnt = returnval->m_localToGlobalMap[i];
2181 returnval->m_localToGlobalMap[i] = GlobCoeffs[cnt];
2214 for(j = 0; j < locSize; j++)
2229 bwidth = (bwidth>(maxId-minId))?bwidth:(maxId-minId);
2294 if(global.data() == loc.data())
2329 if(global.data() == loc.data())
2361 if(global.data() == loc.data())
#define ASSERTL0(condition, msg)
bool m_systemSingular
Flag indicating if the system is singular or not.
bool m_signChange
Flag indicating if modes require sign reversal.
AssemblyMapCG(const LibUtilities::SessionReaderSharedPtr &pSession, const std::string variable="DefaultVar")
Default constructor.
virtual void v_LocalToGlobal(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global) const
int m_numGlobalBndCoeffs
Total number of global boundary coefficients.
int GetCoeff_Offset(int n) const
Get the start offset position for a global list of m_coeffs correspoinding to element n...
void MultiLevelBisectionReordering(const BoostGraph &graph, Array< OneD, int > &perm, Array< OneD, int > &iperm, BottomUpSubStructuredGraphSharedPtr &substructgraph, std::set< int > partVerts, int mdswitch)
LibUtilities::CommSharedPtr m_comm
Communicator.
static void Gather(Nektar::Array< OneD, NekDouble > pU, gs_op pOp, gs_data *pGsh, Nektar::Array< OneD, NekDouble > pBuffer=NullNekDouble1DArray)
Performs a gather-scatter operation of the provided values.
int m_maxStaticCondLevel
Maximum static condensation level.
void Gathr(int n, const T *x, const int *y, T *z)
Gather vector z[i] = x[y[i]].
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
std::map< int, vector< PeriodicEntity > > PeriodicMap
boost::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
virtual int v_GetNumNonDirEdgeModes() const
Array< OneD, int > m_globalToUniversalMapUnique
Integer map of unique process coeffs to universal space (signed)
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
Array< OneD, int > m_extraDirEdges
Extra dirichlet edges in parallel.
void SetUpUniversalC0ContMap(const ExpList &locExp, const PeriodicMap &perVerts=NullPeriodicMap, const PeriodicMap &perEdges=NullPeriodicMap, const PeriodicMap &perFaces=NullPeriodicMap)
virtual int v_GetNumNonDirFaceModes() const
static gs_data * Init(const Nektar::Array< OneD, long > pId, const LibUtilities::CommSharedPtr &pComm)
Initialise Gather-Scatter map.
const boost::shared_ptr< LocalRegions::ExpansionVector > GetExp() const
This function returns the vector of elements in the expansion.
int m_numNonDirVertexModes
Number of non Dirichlet vertex modes.
Principle Modified Functions .
boost::shared_ptr< BottomUpSubStructuredGraph > BottomUpSubStructuredGraphSharedPtr
int CreateGraph(const ExpList &locExp, const BndCondExp &bndCondExp, const Array< OneD, const BndCond > &bndConditions, const bool checkIfSystemSingular, const PeriodicMap &periodicVerts, const PeriodicMap &periodicEdges, const PeriodicMap &periodicFaces, DofGraph &graph, BottomUpSubStructuredGraphSharedPtr &bottomUpGraph, set< int > &extraDirVerts, set< int > &extraDirEdges, int &firstNonDirGraphVertId, int &nExtraDirichlet, int mdswitch=1)
Array< OneD, int > m_globalToUniversalMap
Integer map of process coeffs to universal space.
int m_numNonDirEdges
Number of Dirichlet edges.
int m_numLocalCoeffs
Total number of local coefficients.
vector< map< int, int > > DofGraph
void CuthillMckeeReordering(const BoostGraph &graph, Array< OneD, int > &perm, Array< OneD, int > &iperm)
int m_numLocalBndCondCoeffs
Number of local boundary condition coefficients.
virtual void v_Assemble(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global) const
virtual void v_GlobalToLocal(const Array< OneD, const NekDouble > &global, Array< OneD, NekDouble > &loc) const
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
int Imax(int n, const T *x, const int incx)
Return the index of the maximum element in x.
void CalculateFullSystemBandWidth()
Calculate the bandwith of the full matrix system.
std::vector< ExpansionSharedPtr > ExpansionVector
Array< OneD, int > m_localToGlobalMap
Integer map of local coeffs to global space.
virtual const Array< OneD, const int > & v_GetLocalToGlobalMap()
AssemblyMapSharedPtr m_nextLevelLocalToGlobalMap
Map from the patches of the previous level to the patches of the current level.
Base class for constructing local to global mapping of degrees of freedom.
const char *const GlobalSysSolnTypeMap[]
int m_numNonDirFaceModes
Number of non Dirichlet face modes.
size_t m_hash
Hash for map.
void UniversalAssemble(Array< OneD, NekDouble > &pGlobal) const
Base class for all multi-elemental spectral/hp expansions.
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
map< int, vector< ExtraDirDof > > m_extraDirDofs
Map indicating degrees of freedom which are Dirichlet but whose value is stored on another processor...
Array< OneD, unsigned int > m_numLocalBndCoeffsPerPatch
The number of bnd dofs per patch.
virtual int v_GetNumDirFaces() const
GlobalSysSolnType m_solnType
The solution type of the global system.
Array< OneD, NekDouble > m_bndCondCoeffsToGlobalCoeffsSign
Integer map of bnd cond coeffs to global coefficients.
boost::tuple< int, int, NekDouble > ExtraDirDof
virtual AssemblyMapSharedPtr v_LinearSpaceMap(const ExpList &locexp, GlobalSysSolnType solnType)
Construct an AssemblyMapCG object which corresponds to the linear space of the current object...
int m_numGlobalDirBndCoeffs
Number of Global Dirichlet Boundary Coefficients.
Principle Modified Functions .
StdRegions::Orientation DeterminePeriodicFaceOrient(StdRegions::Orientation faceOrient, StdRegions::Orientation perFaceOrient)
Determine relative orientation between two faces.
void GlobalToLocal(const Array< OneD, const NekDouble > &global, Array< OneD, NekDouble > &loc) const
int m_numDirFaces
Number of Dirichlet faces.
virtual int v_GetNumDirEdges() const
void Scatr(int n, const T *x, const int *y, T *z)
Scatter vector z[y[i]] = x[i].
static void Unique(const Nektar::Array< OneD, long > pId, const LibUtilities::CommSharedPtr &pComm)
Updates pId to negate all-but-one references to each universal ID.
virtual int v_GetNumNonDirFaces() const
void Assmb(int n, const T *x, const int *y, T *z)
Assemble z[y[i]] += x[i]; z should be zero'd first.
pair< int, StdRegions::Orientation > DeterminePeriodicEdgeOrientId(int meshEdgeId, StdRegions::Orientation edgeOrient, const vector< PeriodicEntity > &periodicEdges)
Determine orientation of an edge to its periodic equivalents, as well as the ID of the representative...
void LocalToGlobal(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global) const
virtual int v_GetFullSystemBandWidth() const
Array< OneD, unsigned int > m_numLocalIntCoeffsPerPatch
The number of int dofs per patch.
virtual void v_UniversalAssemble(Array< OneD, NekDouble > &pGlobal) const
int m_lowestStaticCondLevel
Lowest static condensation level.
void CalculateBndSystemBandWidth()
Calculates the bandwidth of the boundary system.
Array< OneD, int > m_localToGlobalBndMap
Integer map of local boundary coeffs to global space.
int m_numLocalDirBndCoeffs
Number of Local Dirichlet Boundary Coefficients.
No Solution type specified.
virtual const Array< OneD, const int > & v_GetExtraDirEdges()
Array< OneD, int > m_bndCondCoeffsToGlobalCoeffsMap
Integer map of bnd cond coeffs to global coefficients.
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
int m_numLocalBndCoeffs
Number of local boundary coefficients.
int m_numDirEdges
Number of Dirichlet edges.
int m_staticCondLevel
The level of recursion in the case of multi-level static condensation.
Array< OneD, NekDouble > m_localToGlobalBndSign
Integer sign of local boundary coeffs to global space.
SpatialDomains::GeometrySharedPtr GetGeom() const
Array< OneD, NekDouble > m_localToGlobalSign
Integer sign of local coeffs to global space.
int GetOffset_Elmt_Id(int n) const
Get the element id associated with the n th consecutive block of data in m_phys and m_coeffs...
boost::shared_ptr< Expansion > ExpansionSharedPtr
int m_numNonDirEdgeModes
Number of non Dirichlet edge modes.
virtual int v_GetNumNonDirVertexModes() const
LibUtilities::SessionReaderSharedPtr m_session
Session object.
Array< OneD, int > m_globalToUniversalBndMap
Integer map of process coeffs to universal space.
Array< OneD, int > m_globalToUniversalBndMapUnique
Integer map of unique process coeffs to universal space (signed)
virtual ~AssemblyMapCG()
Destructor.
void UniversalAssembleBnd(Array< OneD, NekDouble > &pGlobal) const
int m_numGlobalCoeffs
Total number of global coefficients.
int m_numNonDirFaces
Number of Dirichlet faces.
virtual const Array< OneD, NekDouble > & v_GetLocalToGlobalSign() const
virtual const Array< OneD, const int > & v_GetGlobalToUniversalMapUnique()
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
void Zero(int n, T *x, const int incx)
Zero vector.
virtual int v_GetNumNonDirEdges() const
boost::shared_ptr< AssemblyMapCG > AssemblyMapCGSharedPtr
virtual const Array< OneD, const int > & v_GetGlobalToUniversalMap()
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
int m_fullSystemBandWidth
Bandwith of the full matrix system (no static condensation).
void Assemble(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global) const
Array< OneD, DataType > & GetPtr()
int m_numPatches
The number of patches (~elements) in the current level.
void NoReordering(const BoostGraph &graph, Array< OneD, int > &perm, Array< OneD, int > &iperm)