1017 int i, region1ID, region2ID;
1020 map<int, int> BregionToVertMap;
1024 for (
auto &it : bregions)
1029 if (locBCond->GetBoundaryConditionType() !=
1035 it.second->begin()->second->m_geomVec[0]->GetGlobalID();
1037 BregionToVertMap[it.first] = id;
1042 int n = vComm->GetSize();
1043 int p = vComm->GetRank();
1046 nregions[p] = BregionToVertMap.size();
1053 for (i = 1; i < n; ++i)
1055 regOffset[i] = regOffset[i - 1] + nregions[i - 1];
1062 for (
auto &iit : BregionToVertMap)
1064 bregid[i] = iit.first;
1065 bregmap[i++] = iit.second;
1066 islocal.insert(iit.first);
1072 for (
int i = 0; i < totRegions; ++i)
1074 BregionToVertMap[bregid[i]] = bregmap[i];
1078 for (
auto &it : bregions)
1083 if (locBCond->GetBoundaryConditionType() !=
1090 region1ID = it.first;
1092 std::static_pointer_cast<
1094 ->m_connectedBoundaryRegion;
1096 ASSERTL0(BregionToVertMap.count(region1ID) != 0,
1097 "Cannot determine vertex of region1ID");
1099 ASSERTL0(BregionToVertMap.count(region2ID) != 0,
1100 "Cannot determine vertex of region2ID");
1104 islocal.count(region2ID) != 0);
1112 int region1ID, region2ID, i, j, k, cnt;
1116 m_graph->GetCompositeOrdering();
1118 m_graph->GetBndRegionOrdering();
1125 map<int, int> perComps;
1126 map<int, vector<int>> allVerts;
1128 map<int, pair<int, StdRegions::Orientation>> allEdges;
1131 for (i = 0; i < (*m_exp).size(); ++i)
1133 for (j = 0; j < (*m_exp)[i]->GetNverts(); ++j)
1135 int id = (*m_exp)[i]->GetGeom()->GetVid(j);
1136 locVerts.insert(
id);
1141 for (
auto &it : bregions)
1146 if (locBCond->GetBoundaryConditionType() !=
1153 region1ID = it.first;
1155 std::static_pointer_cast<
1157 ->m_connectedBoundaryRegion;
1162 if (vComm->GetSize() == 1)
1164 cId1 = it.second->begin()->first;
1165 cId2 = bregions.find(region2ID)->second->begin()->first;
1169 cId1 = bndRegOrder.find(region1ID)->second[0];
1170 cId2 = bndRegOrder.find(region2ID)->second[0];
1174 "Boundary region " + std::to_string(region1ID) +
1175 " should only contain 1 composite.");
1177 vector<unsigned int> tmpOrder;
1182 it.second->begin()->second;
1184 for (i = 0; i < c->m_geomVec.size(); ++i)
1189 ASSERTL0(segGeom,
"Unable to cast to SegGeom*");
1192 m_graph->GetElementsFromEdge(segGeom);
1194 "The periodic boundaries belong to "
1195 "more than one element of the mesh");
1201 allEdges[c->m_geomVec[i]->GetGlobalID()] =
1202 make_pair(elmt->at(0).second,
1207 if (vComm->GetSize() == 1)
1209 tmpOrder.push_back(c->m_geomVec[i]->GetGlobalID());
1212 vector<int> vertList(2);
1213 vertList[0] = segGeom->
GetVid(0);
1214 vertList[1] = segGeom->
GetVid(1);
1215 allVerts[c->m_geomVec[i]->GetGlobalID()] = vertList;
1218 if (vComm->GetSize() == 1)
1220 compOrder[it.second->begin()->first] = tmpOrder;
1225 if (perComps.count(cId1) == 0)
1227 if (perComps.count(cId2) == 0)
1229 perComps[cId1] = cId2;
1233 std::stringstream ss;
1234 ss <<
"Boundary region " << cId2 <<
" should be "
1235 <<
"periodic with " << perComps[cId2] <<
" but "
1236 <<
"found " << cId1 <<
" instead!";
1237 ASSERTL0(perComps[cId2] == cId1, ss.str());
1242 std::stringstream ss;
1243 ss <<
"Boundary region " << cId1 <<
" should be "
1244 <<
"periodic with " << perComps[cId1] <<
" but "
1245 <<
"found " << cId2 <<
" instead!";
1246 ASSERTL0(perComps[cId1] == cId1, ss.str());
1253 for (
auto &cIt : perComps)
1255 idmax =
max(idmax, cIt.first);
1256 idmax =
max(idmax, cIt.second);
1261 for (
auto &cIt : perComps)
1263 perid[cIt.first] = cIt.second;
1267 for (
int i = 0; i < idmax; ++i)
1273 if (perComps.count(perid[i]))
1277 perComps[i] = perid[i];
1283 int n = vComm->GetSize();
1284 int p = vComm->GetRank();
1290 edgecounts[p] = allEdges.size();
1294 for (i = 1; i < n; ++i)
1296 edgeoffset[i] = edgeoffset[i - 1] + edgecounts[i - 1];
1305 auto sIt = allEdges.begin();
1307 for (i = 0; sIt != allEdges.end(); ++sIt)
1309 edgeIds[edgeoffset[p] + i] = sIt->first;
1310 edgeIdx[edgeoffset[p] + i] = sIt->second.first;
1311 edgeOrient[edgeoffset[p] + i] = sIt->second.second;
1312 edgeVerts[edgeoffset[p] + i++] = allVerts[sIt->first].size();
1335 for (i = 0; i < n; ++i)
1337 if (edgecounts[i] > 0)
1340 edgeVerts + edgeoffset[i], 1);
1349 for (i = 1; i < n; ++i)
1351 vertoffset[i] = vertoffset[i - 1] + procVerts[i - 1];
1355 for (i = 0, sIt = allEdges.begin(); sIt != allEdges.end(); ++sIt)
1357 for (j = 0; j < allVerts[sIt->first].size(); ++j)
1359 traceIds[vertoffset[p] + i++] = allVerts[sIt->first][j];
1366 map<int, StdRegions::Orientation> orientMap;
1367 map<int, vector<int>> vertMap;
1369 for (cnt = i = 0; i < totEdges; ++i)
1371 ASSERTL0(orientMap.count(edgeIds[i]) == 0,
1372 "Already found edge in orientation map!");
1392 orientMap[edgeIds[i]] = o;
1394 vector<int> verts(edgeVerts[i]);
1396 for (j = 0; j < edgeVerts[i]; ++j)
1398 verts[j] = traceIds[cnt++];
1400 vertMap[edgeIds[i]] = verts;
1407 map<int, int> allCompPairs;
1416 for (
auto &cIt : perComps)
1419 const int id1 = cIt.first;
1420 const int id2 = cIt.second;
1421 std::string id1s = std::to_string(id1);
1422 std::string id2s = std::to_string(id2);
1424 if (compMap.count(id1) > 0)
1426 c[0] = compMap[id1];
1429 if (compMap.count(id2) > 0)
1431 c[1] = compMap[id2];
1437 map<int, int> compPairs;
1440 "Unable to find composite " + id1s +
" in order map.");
1442 "Unable to find composite " + id2s +
" in order map.");
1444 compOrder[id1].size() == compOrder[id2].size(),
1445 "Periodic composites " + id1s +
" and " + id2s +
1446 " should have the same number of elements. Have " +
1447 std::to_string(compOrder[id1].size()) +
" vs " +
1448 std::to_string(compOrder[id2].size()));
1449 ASSERTL0(compOrder[id1].size() > 0,
"Periodic composites " +
1450 id1s +
" and " + id2s +
1454 for (i = 0; i < compOrder[id1].size(); ++i)
1456 int eId1 = compOrder[id1][i];
1457 int eId2 = compOrder[id2][i];
1459 ASSERTL0(compPairs.count(eId1) == 0,
"Already paired.");
1461 if (compPairs.count(eId2) != 0)
1463 ASSERTL0(compPairs[eId2] == eId1,
"Pairing incorrect");
1465 compPairs[eId1] = eId2;
1471 for (i = 0; i < 2; ++i)
1478 if (c[i]->m_geomVec.size() > 0)
1480 for (j = 0; j < c[i]->m_geomVec.size(); ++j)
1482 locEdges.insert(c[i]->m_geomVec[j]->GetGlobalID());
1488 for (
auto &pIt : compPairs)
1490 int ids[2] = {pIt.first, pIt.second};
1491 bool local[2] = {locEdges.count(pIt.first) > 0,
1492 locEdges.count(pIt.second) > 0};
1494 ASSERTL0(orientMap.count(ids[0]) > 0 &&
1495 orientMap.count(ids[1]) > 0,
1496 "Unable to find edge in orientation map.");
1498 allCompPairs[pIt.first] = pIt.second;
1499 allCompPairs[pIt.second] = pIt.first;
1501 for (i = 0; i < 2; ++i)
1508 int other = (i + 1) % 2;
1511 orientMap[ids[i]] == orientMap[ids[other]]
1519 for (i = 0; i < 2; ++i)
1521 int other = (i + 1) % 2;
1524 orientMap[ids[i]] == orientMap[ids[other]]
1529 vector<int> perVerts1 = vertMap[ids[i]];
1530 vector<int> perVerts2 = vertMap[ids[other]];
1532 map<int, pair<int, bool>> tmpMap;
1535 tmpMap[perVerts1[0]] = make_pair(
1536 perVerts2[0], locVerts.count(perVerts2[0]) > 0);
1537 tmpMap[perVerts1[1]] = make_pair(
1538 perVerts2[1], locVerts.count(perVerts2[1]) > 0);
1542 tmpMap[perVerts1[0]] = make_pair(
1543 perVerts2[1], locVerts.count(perVerts2[1]) > 0);
1544 tmpMap[perVerts1[1]] = make_pair(
1545 perVerts2[0], locVerts.count(perVerts2[0]) > 0);
1548 for (
auto &mIt : tmpMap)
1554 auto perIt = periodicVerts.find(mIt.first);
1556 if (perIt == periodicVerts.end())
1558 periodicVerts[mIt.first].push_back(ent2);
1559 perIt = periodicVerts.find(mIt.first);
1564 for (j = 0; j < perIt->second.size(); ++j)
1566 if (perIt->second[j].id == mIt.second.first)
1575 perIt->second.push_back(ent2);
1586 for (cnt = i = 0; i < totEdges; ++i)
1588 int edgeId = edgeIds[i];
1590 ASSERTL0(allCompPairs.count(edgeId) > 0,
1591 "Unable to find matching periodic edge.");
1593 int perEdgeId = allCompPairs[edgeId];
1595 for (j = 0; j < edgeVerts[i]; ++j, ++cnt)
1597 int vId = traceIds[cnt];
1599 auto perId = periodicVerts.find(vId);
1601 if (perId == periodicVerts.end())
1610 orientMap[edgeId] == orientMap[perEdgeId]
1611 ? vertMap[perEdgeId][(j + 1) % 2]
1612 : vertMap[perEdgeId][j];
1616 locVerts.count(perVertexId) > 0);
1618 periodicVerts[vId].push_back(ent);
1625 for (
auto &perIt : periodicVerts)
1628 for (i = 0; i < perIt.second.size(); ++i)
1630 auto perIt2 = periodicVerts.find(perIt.second[i].id);
1631 ASSERTL0(perIt2 != periodicVerts.end(),
1632 "Couldn't find periodic vertex.");
1634 for (j = 0; j < perIt2->second.size(); ++j)
1636 if (perIt2->second[j].id == perIt.first)
1642 for (k = 0; k < perIt.second.size(); ++k)
1644 if (perIt2->second[j].id == perIt.second[k].id)
1653 perIt.second.push_back(perIt2->second[j]);
1661 for (
auto &perIt : periodicVerts)
1663 if (locVerts.count(perIt.first) > 0)
1673 m_graph->GetCompositeOrdering();
1675 m_graph->GetBndRegionOrdering();
1690 map<int, RotPeriodicInfo> rotComp;
1691 map<int, int> perComps;
1692 map<int, vector<int>> allVerts;
1693 map<int, std::vector<SpatialDomains::PointGeom *>> allCoord;
1694 map<int, vector<int>> allEdges;
1695 map<int, vector<StdRegions::Orientation>> allOrient;
1700 int region1ID, region2ID, i, j, k, cnt;
1704 for (i = 0; i < (*m_exp).size(); ++i)
1706 for (j = 0; j < (*m_exp)[i]->GetNverts(); ++j)
1708 int id = (*m_exp)[i]->GetGeom()->GetVid(j);
1709 locVerts.insert(
id);
1712 for (j = 0; j < (*m_exp)[i]->GetGeom()->GetNumEdges(); ++j)
1714 int id = (*m_exp)[i]->GetGeom()->GetEid(j);
1715 locEdges.insert(
id);
1722 for (
auto &it : bregions)
1728 if (locBCond->GetBoundaryConditionType() !=
1735 region1ID = it.first;
1737 std::static_pointer_cast<
1739 ->m_connectedBoundaryRegion;
1743 "Boundary region " + std::to_string(region1ID) +
1744 " should only contain 1 composite.");
1752 if (vComm->GetSize() == 1)
1754 cId1 = it.second->begin()->first;
1755 cId2 = bregions.find(region2ID)->second->begin()->first;
1759 cId1 = bndRegOrder.find(region1ID)->second[0];
1760 cId2 = bndRegOrder.find(region2ID)->second[0];
1764 if (boost::icontains(locBCond->GetUserDefined(),
"Rotated"))
1766 vector<string> tmpstr;
1768 boost::split(tmpstr, locBCond->GetUserDefined(),
1769 boost::is_any_of(
":"));
1771 if (boost::iequals(tmpstr[0],
"Rotated"))
1774 "Expected Rotated user defined string to "
1775 "contain direction and rotation angle "
1776 "and optionally a tolerance, "
1777 "i.e. Rotated:dir:PI/2:1e-6");
1779 ASSERTL1((tmpstr[1] ==
"x") || (tmpstr[1] ==
"y") ||
1782 "not specified as x,y or z");
1785 RotInfo.
m_dir = (tmpstr[1] ==
"x") ? 0
1786 : (tmpstr[1] ==
"y") ? 1
1793 if (tmpstr.size() == 4)
1797 RotInfo.
m_tol = std::stod(tmpstr[3]);
1802 "failed to cast tolerance input "
1803 "to a double value in Rotated"
1804 "boundary information");
1809 RotInfo.
m_tol = 1e-8;
1811 rotComp[cId1] = RotInfo;
1816 it.second->begin()->second;
1818 vector<unsigned int> tmpOrder;
1826 for (i = 0; i < c->m_geomVec.size(); ++i)
1831 ASSERTL1(faceGeom,
"Unable to cast to Geometry2D*");
1834 int faceId = c->m_geomVec[i]->GetGlobalID();
1835 locFaces.insert(faceId);
1839 if (vComm->GetSize() == 1)
1841 tmpOrder.push_back(c->m_geomVec[i]->GetGlobalID());
1846 vector<int> vertList, edgeList;
1847 std::vector<SpatialDomains::PointGeom *> coordVec;
1848 vector<StdRegions::Orientation> orientVec;
1851 vertList.push_back(faceGeom->
GetVid(j));
1852 edgeList.push_back(faceGeom->
GetEid(j));
1853 coordVec.push_back(faceGeom->
GetVertex(j));
1854 orientVec.push_back(faceGeom->
GetEorient(j));
1857 allVerts[faceId] = vertList;
1858 allEdges[faceId] = edgeList;
1859 allCoord[faceId] = coordVec;
1860 allOrient[faceId] = orientVec;
1865 if (vComm->GetSize() == 1)
1867 compOrder[it.second->begin()->first] = tmpOrder;
1873 if (perComps.count(cId1) == 0)
1875 if (perComps.count(cId2) == 0)
1877 perComps[cId1] = cId2;
1881 std::stringstream ss;
1882 ss <<
"Boundary region " << cId2 <<
" should be "
1883 <<
"periodic with " << perComps[cId2] <<
" but "
1884 <<
"found " << cId1 <<
" instead!";
1885 ASSERTL0(perComps[cId2] == cId1, ss.str());
1890 std::stringstream ss;
1891 ss <<
"Boundary region " << cId1 <<
" should be "
1892 <<
"periodic with " << perComps[cId1] <<
" but "
1893 <<
"found " << cId2 <<
" instead!";
1894 ASSERTL0(perComps[cId1] == cId1, ss.str());
1901 for (
auto &cIt : perComps)
1903 idmax =
max(idmax, cIt.first);
1904 idmax =
max(idmax, cIt.second);
1909 for (
auto &cIt : perComps)
1911 perid[cIt.first] = cIt.second;
1915 for (
int i = 0; i < idmax; ++i)
1921 if (perComps.count(perid[i]))
1925 perComps[i] = perid[i];
1932 int n = vComm->GetSize();
1933 int p = vComm->GetRank();
1943 rotcounts[p] = rotComp.size();
1949 for (i = 1; i < n; ++i)
1951 rotoffset[i] = rotoffset[i - 1] + rotcounts[i - 1];
1960 auto rIt = rotComp.begin();
1962 for (i = 0; rIt != rotComp.end(); ++rIt)
1964 compid[rotoffset[p] + i] = rIt->first;
1965 rotdir[rotoffset[p] + i] = rIt->second.m_dir;
1966 rotangle[rotoffset[p] + i] = rIt->second.m_angle;
1967 rottol[rotoffset[p] + i++] = rIt->second.m_tol;
1976 for (i = 0; i < totrot; ++i)
1980 rotComp[compid[i]] = rinfo;
1985 facecounts[p] = locFaces.size();
1991 for (i = 1; i < n; ++i)
1993 faceoffset[i] = faceoffset[i - 1] + facecounts[i - 1];
2007 auto sIt = locFaces.begin();
2008 for (i = 0; sIt != locFaces.end(); ++sIt)
2010 faceIds[faceoffset[p] + i] = *sIt;
2011 faceVerts[faceoffset[p] + i++] = allVerts[*sIt].size();
2034 for (i = 0; i < n; ++i)
2036 if (facecounts[i] > 0)
2039 faceVerts + faceoffset[i], 1);
2050 for (i = 1; i < n; ++i)
2052 vertoffset[i] = vertoffset[i - 1] + procVerts[i - 1];
2066 for (cnt = 0, sIt = locFaces.begin(); sIt != locFaces.end(); ++sIt)
2068 for (j = 0; j < allVerts[*sIt].size(); ++j)
2070 int vertId = allVerts[*sIt][j];
2071 vertIds[vertoffset[p] + cnt] = vertId;
2072 vertX[vertoffset[p] + cnt] = (*allCoord[*sIt][j])(0);
2073 vertY[vertoffset[p] + cnt] = (*allCoord[*sIt][j])(1);
2074 vertZ[vertoffset[p] + cnt] = (*allCoord[*sIt][j])(2);
2075 edgeIds[vertoffset[p] + cnt] = allEdges[*sIt][j];
2076 edgeOrt[vertoffset[p] + cnt++] = allOrient[*sIt][j];
2091 map<int, vector<int>> vertMap;
2092 map<int, vector<int>> edgeMap;
2093 map<int, std::vector<SpatialDomains::PointGeom *>> coordMap;
2099 map<int, SpatialDomains::PointGeomUniquePtr> vCoMap;
2100 map<int, pair<int, int>> eIdMap;
2102 for (cnt = i = 0; i < totFaces; ++i)
2104 vector<int> edges(faceVerts[i]);
2105 vector<int> verts(faceVerts[i]);
2106 std::vector<SpatialDomains::PointGeom *> coord(faceVerts[i]);
2111 for (j = 0; j < faceVerts[i]; ++j, ++cnt)
2113 edges[j] = edgeIds[cnt];
2114 verts[j] = vertIds[cnt];
2116 auto vIt = vCoMap.find(vertIds[cnt]);
2118 if (vIt == vCoMap.end())
2122 vertY[cnt], vertZ[cnt]);
2123 coord[j] = pt.get();
2124 vCoMap[vertIds[cnt]] = std::move(pt);
2128 coord[j] = vIt->second.get();
2132 auto testIns = eIdMap.insert(make_pair(
2134 make_pair(vertIds[tmp + j],
2135 vertIds[tmp + ((j + 1) % faceVerts[i])])));
2137 if (testIns.second ==
false)
2160 swap(testIns.first->second.first,
2161 testIns.first->second.second);
2165 vertMap[faceIds[i]] = verts;
2166 edgeMap[faceIds[i]] = edges;
2167 coordMap[faceIds[i]] = coord;
2185 map<int, map<StdRegions::Orientation, vector<int>>> vmap;
2186 map<int, map<StdRegions::Orientation, vector<int>>> emap;
2188 map<StdRegions::Orientation, vector<int>> quadVertMap;
2198 map<StdRegions::Orientation, vector<int>> quadEdgeMap;
2208 map<StdRegions::Orientation, vector<int>> triVertMap;
2212 map<StdRegions::Orientation, vector<int>> triEdgeMap;
2216 vmap[3] = triVertMap;
2217 vmap[4] = quadVertMap;
2218 emap[3] = triEdgeMap;
2219 emap[4] = quadEdgeMap;
2221 map<int, int> allCompPairs;
2225 map<int, int> fIdToCompId;
2230 for (
auto &cIt : perComps)
2233 const int id1 = cIt.first;
2234 const int id2 = cIt.second;
2235 std::string id1s = std::to_string(id1);
2236 std::string id2s = std::to_string(id2);
2238 if (compMap.count(id1) > 0)
2240 c[0] = compMap[id1];
2243 if (compMap.count(id2) > 0)
2245 c[1] = compMap[id2];
2251 map<int, int> compPairs;
2254 "Unable to find composite " + id1s +
" in order map.");
2256 "Unable to find composite " + id2s +
" in order map.");
2258 compOrder[id1].size() == compOrder[id2].size(),
2259 "Periodic composites " + id1s +
" and " + id2s +
2260 " should have the same number of elements. Have " +
2261 std::to_string(compOrder[id1].size()) +
" vs " +
2262 std::to_string(compOrder[id2].size()));
2263 ASSERTL0(compOrder[id1].size() > 0,
"Periodic composites " +
2264 id1s +
" and " + id2s +
2268 for (i = 0; i < compOrder[id1].size(); ++i)
2270 int eId1 = compOrder[id1][i];
2271 int eId2 = compOrder[id2][i];
2273 ASSERTL0(compPairs.count(eId1) == 0,
"Already paired.");
2276 if (compPairs.count(eId2) != 0)
2278 ASSERTL0(compPairs[eId2] == eId1,
"Pairing incorrect");
2280 compPairs[eId1] = eId2;
2283 fIdToCompId[eId1] = id1;
2284 fIdToCompId[eId2] = id2;
2290 for (
auto &pIt : compPairs)
2292 int ids[2] = {pIt.first, pIt.second};
2293 bool local[2] = {locFaces.count(pIt.first) > 0,
2294 locFaces.count(pIt.second) > 0};
2296 ASSERTL0(coordMap.count(ids[0]) > 0 &&
2297 coordMap.count(ids[1]) > 0,
2298 "Unable to find face in coordinate map");
2300 allCompPairs[pIt.first] = pIt.second;
2301 allCompPairs[pIt.second] = pIt.first;
2305 std::vector<SpatialDomains::PointGeom *> tmpVec[2] = {
2306 coordMap[ids[0]], coordMap[ids[1]]};
2308 ASSERTL0(tmpVec[0].size() == tmpVec[1].size(),
2309 "Two periodic faces have different number "
2318 bool rotbnd =
false;
2325 if (rotComp.count(fIdToCompId[pIt.first]))
2328 dir = rotComp[fIdToCompId[pIt.first]].m_dir;
2329 angle = rotComp[fIdToCompId[pIt.first]].m_angle;
2330 tol = rotComp[fIdToCompId[pIt.first]].m_tol;
2334 for (i = 0; i < 2; ++i)
2342 int other = (i + 1) % 2;
2345 sign = (i == 0) ? 1.0 : -1.0;
2348 if (tmpVec[0].size() == 3)
2351 {tmpVec[i][0], tmpVec[i][1], tmpVec[i][2]},
2352 {tmpVec[other][0], tmpVec[other][1],
2354 rotbnd, dir,
sign * angle, tol);
2359 {tmpVec[i][0], tmpVec[i][1], tmpVec[i][2],
2361 {tmpVec[other][0], tmpVec[other][1],
2362 tmpVec[other][2], tmpVec[other][3]},
2363 rotbnd, dir,
sign * angle, tol);
2372 int nFaceVerts = vertMap[ids[0]].size();
2375 for (i = 0; i < 2; ++i)
2377 int other = (i + 1) % 2;
2380 sign = (i == 0) ? 1.0 : -1.0;
2383 if (tmpVec[0].size() == 3)
2386 {tmpVec[i][0], tmpVec[i][1], tmpVec[i][2]},
2387 {tmpVec[other][0], tmpVec[other][1],
2389 rotbnd, dir,
sign * angle, tol);
2394 {tmpVec[i][0], tmpVec[i][1], tmpVec[i][2],
2396 {tmpVec[other][0], tmpVec[other][1],
2397 tmpVec[other][2], tmpVec[other][3]},
2398 rotbnd, dir,
sign * angle, tol);
2401 if (nFaceVerts == 3)
2406 "Unsupported face orientation for face " +
2407 std::to_string(ids[i]));
2411 vector<int> per1 = vertMap[ids[i]];
2412 vector<int> per2 = vertMap[ids[other]];
2416 map<int, pair<int, bool>> tmpMap;
2420 for (j = 0; j < nFaceVerts; ++j)
2422 int v = vmap[nFaceVerts][o][j];
2424 make_pair(per2[v], locVerts.count(per2[v]) > 0);
2428 for (
auto &mIt : tmpMap)
2435 auto perIt = periodicVerts.find(mIt.first);
2437 if (perIt == periodicVerts.end())
2441 periodicVerts[mIt.first].push_back(ent2);
2442 perIt = periodicVerts.find(mIt.first);
2449 for (k = 0; k < perIt->second.size(); ++k)
2451 if (perIt->second[k].id == mIt.second.first)
2457 if (k == perIt->second.size())
2459 perIt->second.push_back(ent2);
2467 for (i = 0; i < 2; ++i)
2469 int other = (i + 1) % 2;
2472 sign = (i == 0) ? 1.0 : -1.0;
2474 if (tmpVec[0].size() == 3)
2477 {tmpVec[i][0], tmpVec[i][1], tmpVec[i][2]},
2478 {tmpVec[other][0], tmpVec[other][1],
2480 rotbnd, dir,
sign * angle, tol);
2485 {tmpVec[i][0], tmpVec[i][1], tmpVec[i][2],
2487 {tmpVec[other][0], tmpVec[other][1],
2488 tmpVec[other][2], tmpVec[other][3]},
2489 rotbnd, dir,
sign * angle, tol);
2492 vector<int> per1 = edgeMap[ids[i]];
2493 vector<int> per2 = edgeMap[ids[other]];
2495 map<int, pair<int, bool>> tmpMap;
2497 for (j = 0; j < nFaceVerts; ++j)
2499 int e = emap[nFaceVerts][o][j];
2501 make_pair(per2[e], locEdges.count(per2[e]) > 0);
2504 for (
auto &mIt : tmpMap)
2511 auto perIt = periodicEdges.find(mIt.first);
2513 if (perIt == periodicEdges.end())
2515 periodicEdges[mIt.first].push_back(ent2);
2516 perIt = periodicEdges.find(mIt.first);
2520 for (k = 0; k < perIt->second.size(); ++k)
2522 if (perIt->second[k].id == mIt.second.first)
2528 if (k == perIt->second.size())
2530 perIt->second.push_back(ent2);
2540 ASSERTL1(allCompPairs.size() == fIdToCompId.size(),
2541 "At this point the size of allCompPairs "
2542 "should have been the same as fIdToCompId");
2546 map<int, int> eIdToCompId;
2552 for (cnt = i = 0; i < totFaces; ++i)
2554 bool rotbnd =
false;
2559 int faceId = faceIds[i];
2561 ASSERTL0(allCompPairs.count(faceId) > 0,
2562 "Unable to find matching periodic face. faceId = " +
2563 std::to_string(faceId));
2565 int perFaceId = allCompPairs[faceId];
2568 ASSERTL1((rotComp.size() == 0) || fIdToCompId.count(faceId) > 0,
2569 "Face " + std::to_string(faceId) +
2570 " not found in fIdtoCompId map");
2571 if (rotComp.count(fIdToCompId[faceId]))
2574 dir = rotComp[fIdToCompId[faceId]].m_dir;
2575 angle = rotComp[fIdToCompId[faceId]].m_angle;
2576 tol = rotComp[fIdToCompId[faceId]].m_tol;
2579 for (j = 0; j < faceVerts[i]; ++j, ++cnt)
2581 int vId = vertIds[cnt];
2583 auto perId = periodicVerts.find(vId);
2585 if (perId == periodicVerts.end())
2593 std::vector<SpatialDomains::PointGeom *> tmpVec[2] = {
2594 coordMap[faceId], coordMap[perFaceId]};
2596 int nFaceVerts = tmpVec[0].size();
2600 {tmpVec[0][0], tmpVec[0][1],
2602 {tmpVec[1][0], tmpVec[1][1],
2604 rotbnd, dir, angle, tol)
2606 {tmpVec[0][0], tmpVec[0][1], tmpVec[0][2],
2608 {tmpVec[1][0], tmpVec[1][1], tmpVec[1][2],
2610 rotbnd, dir, angle, tol);
2615 vertMap[perFaceId][vmap[nFaceVerts][o][j]];
2619 locVerts.count(perVertexId) > 0);
2621 periodicVerts[vId].push_back(ent);
2624 int eId = edgeIds[cnt];
2626 perId = periodicEdges.find(eId);
2632 eIdToCompId[eId] = fIdToCompId[faceId];
2635 if (perId == periodicEdges.end())
2642 std::vector<SpatialDomains::PointGeom *> tmpVec[2] = {
2643 coordMap[faceId], coordMap[perFaceId]};
2645 int nFaceEdges = tmpVec[0].size();
2649 {tmpVec[0][0], tmpVec[0][1],
2651 {tmpVec[1][0], tmpVec[1][1],
2653 rotbnd, dir, angle, tol)
2655 {tmpVec[0][0], tmpVec[0][1], tmpVec[0][2],
2657 {tmpVec[1][0], tmpVec[1][1], tmpVec[1][2],
2659 rotbnd, dir, angle, tol);
2664 edgeMap[perFaceId][emap[nFaceEdges][o][j]];
2667 locEdges.count(perEdgeId) > 0);
2669 periodicEdges[eId].push_back(ent);
2675 eIdToCompId[perEdgeId] = fIdToCompId[perFaceId];
2683 for (
auto &perIt : periodicVerts)
2686 for (i = 0; i < perIt.second.size(); ++i)
2689 auto perIt2 = periodicVerts.find(perIt.second[i].id);
2690 ASSERTL0(perIt2 != periodicVerts.end(),
2691 "Couldn't find periodic vertex.");
2696 for (j = 0; j < perIt2->second.size(); ++j)
2698 if (perIt2->second[j].id == perIt.first)
2703 for (k = 0; k < perIt.second.size(); ++k)
2705 if (perIt2->second[j].id == perIt.second[k].id)
2711 if (k == perIt.second.size())
2713 perIt.second.push_back(perIt2->second[j]);
2719 for (
auto &perIt : periodicEdges)
2721 for (i = 0; i < perIt.second.size(); ++i)
2723 auto perIt2 = periodicEdges.find(perIt.second[i].id);
2724 ASSERTL0(perIt2 != periodicEdges.end(),
2725 "Couldn't find periodic edge.");
2727 for (j = 0; j < perIt2->second.size(); ++j)
2729 if (perIt2->second[j].id == perIt.first)
2734 for (k = 0; k < perIt.second.size(); ++k)
2736 if (perIt2->second[j].id == perIt.second[k].id)
2742 if (k == perIt.second.size())
2744 perIt.second.push_back(perIt2->second[j]);
2751 for (
auto &perIt : periodicEdges)
2753 bool rotbnd =
false;
2759 auto eIt = eIdMap.find(perIt.first);
2761 *vCoMap[eIt->second.second]};
2764 if (rotComp.count(eIdToCompId[perIt.first]))
2767 dir = rotComp[eIdToCompId[perIt.first]].m_dir;
2768 angle = rotComp[eIdToCompId[perIt.first]].m_angle;
2769 tol = rotComp[eIdToCompId[perIt.first]].m_tol;
2775 for (i = 0; i < perIt.second.size(); ++i)
2777 eIt = eIdMap.find(perIt.second[i].id);
2780 *vCoMap[eIt->second.first],
2781 *vCoMap[eIt->second.second]};
2783 int vMap[2] = {-1, -1};
2789 r.
Rotate(v[0], dir, angle);
2791 if (r.
dist(w[0]) < tol)
2797 r.
Rotate(v[1], dir, angle);
2798 if (r.
dist(w[0]) < tol)
2805 "Unable to align rotationally "
2806 "periodic edge vertex");
2813 0.5 * (w[0](0) - v[0](0) + w[1](0) - v[1](0));
2815 0.5 * (w[0](1) - v[0](1) + w[1](1) - v[1](1));
2817 0.5 * (w[0](2) - v[0](2) + w[1](2) - v[1](2));
2819 for (j = 0; j < 2; ++j)
2824 for (k = 0; k < 2; ++k)
2830 if (
sqrt((x1 - x) * (x1 - x) +
2831 (y1 - y) * (y1 - y) +
2832 (z1 - z) * (z1 - z)) < 1e-8)
2841 ASSERTL0(vMap[0] >= 0 && vMap[1] >= 0,
2842 "Unable to align periodic edge vertex.");
2843 ASSERTL0((vMap[0] == 0 || vMap[0] == 1) &&
2844 (vMap[1] == 0 || vMap[1] == 1) &&
2845 (vMap[0] != vMap[1]),
2846 "Unable to align periodic edge vertex.");
2860 for (
auto &perIt : periodicVerts)
2862 if (locVerts.count(perIt.first) > 0)
2868 for (
auto &perIt : periodicEdges)
2870 if (locEdges.count(perIt.first) > 0)
2878 ASSERTL1(
false,
"Not setup for this expansion");