1021 int i, region1ID, region2ID;
1024 map<int, int> BregionToVertMap;
1028 for (
auto &it : bregions)
1033 if (locBCond->GetBoundaryConditionType() !=
1039 it.second->begin()->second->m_geomVec[0]->GetGlobalID();
1041 BregionToVertMap[it.first] = id;
1046 int n = vComm->GetSize();
1047 int p = vComm->GetRank();
1050 nregions[p] = BregionToVertMap.size();
1057 for (i = 1; i < n; ++i)
1059 regOffset[i] = regOffset[i - 1] + nregions[i - 1];
1066 for (
auto &iit : BregionToVertMap)
1068 bregid[i] = iit.first;
1069 bregmap[i++] = iit.second;
1070 islocal.insert(iit.first);
1076 for (
int i = 0; i < totRegions; ++i)
1078 BregionToVertMap[bregid[i]] = bregmap[i];
1082 for (
auto &it : bregions)
1087 if (locBCond->GetBoundaryConditionType() !=
1094 region1ID = it.first;
1096 std::static_pointer_cast<
1098 ->m_connectedBoundaryRegion;
1100 ASSERTL0(BregionToVertMap.count(region1ID) != 0,
1101 "Cannot determine vertex of region1ID");
1103 ASSERTL0(BregionToVertMap.count(region2ID) != 0,
1104 "Cannot determine vertex of region2ID");
1108 islocal.count(region2ID) != 0);
1116 int region1ID, region2ID, i, j, k, cnt;
1120 m_graph->GetCompositeOrdering();
1122 m_graph->GetBndRegionOrdering();
1129 map<int, int> perComps;
1130 map<int, vector<int>> allVerts;
1132 map<int, pair<int, StdRegions::Orientation>> allEdges;
1135 for (i = 0; i < (*m_exp).size(); ++i)
1137 for (j = 0; j < (*m_exp)[i]->GetNverts(); ++j)
1139 int id = (*m_exp)[i]->GetGeom()->GetVid(j);
1140 locVerts.insert(
id);
1145 for (
auto &it : bregions)
1150 if (locBCond->GetBoundaryConditionType() !=
1157 region1ID = it.first;
1159 std::static_pointer_cast<
1161 ->m_connectedBoundaryRegion;
1166 if (vComm->GetSize() == 1)
1168 cId1 = it.second->begin()->first;
1169 cId2 = bregions.find(region2ID)->second->begin()->first;
1173 cId1 = bndRegOrder.find(region1ID)->second[0];
1174 cId2 = bndRegOrder.find(region2ID)->second[0];
1178 "Boundary region " + std::to_string(region1ID) +
1179 " should only contain 1 composite.");
1181 vector<unsigned int> tmpOrder;
1186 it.second->begin()->second;
1188 for (i = 0; i < c->m_geomVec.size(); ++i)
1193 ASSERTL0(segGeom,
"Unable to cast to SegGeom*");
1196 m_graph->GetElementsFromEdge(segGeom);
1198 "The periodic boundaries belong to "
1199 "more than one element of the mesh");
1205 allEdges[c->m_geomVec[i]->GetGlobalID()] =
1206 make_pair(elmt->at(0).second,
1211 if (vComm->GetSize() == 1)
1213 tmpOrder.push_back(c->m_geomVec[i]->GetGlobalID());
1216 vector<int> vertList(2);
1217 vertList[0] = segGeom->
GetVid(0);
1218 vertList[1] = segGeom->
GetVid(1);
1219 allVerts[c->m_geomVec[i]->GetGlobalID()] = vertList;
1222 if (vComm->GetSize() == 1)
1224 compOrder[it.second->begin()->first] = tmpOrder;
1229 if (perComps.count(cId1) == 0)
1231 if (perComps.count(cId2) == 0)
1233 perComps[cId1] = cId2;
1237 std::stringstream ss;
1238 ss <<
"Boundary region " << cId2 <<
" should be "
1239 <<
"periodic with " << perComps[cId2] <<
" but "
1240 <<
"found " << cId1 <<
" instead!";
1241 ASSERTL0(perComps[cId2] == cId1, ss.str());
1246 std::stringstream ss;
1247 ss <<
"Boundary region " << cId1 <<
" should be "
1248 <<
"periodic with " << perComps[cId1] <<
" but "
1249 <<
"found " << cId2 <<
" instead!";
1250 ASSERTL0(perComps[cId1] == cId1, ss.str());
1257 for (
auto &cIt : perComps)
1259 idmax =
max(idmax, cIt.first);
1260 idmax =
max(idmax, cIt.second);
1265 for (
auto &cIt : perComps)
1267 perid[cIt.first] = cIt.second;
1271 for (
int i = 0; i < idmax; ++i)
1277 if (perComps.count(perid[i]))
1281 perComps[i] = perid[i];
1287 int n = vComm->GetSize();
1288 int p = vComm->GetRank();
1294 edgecounts[p] = allEdges.size();
1298 for (i = 1; i < n; ++i)
1300 edgeoffset[i] = edgeoffset[i - 1] + edgecounts[i - 1];
1309 auto sIt = allEdges.begin();
1311 for (i = 0; sIt != allEdges.end(); ++sIt)
1313 edgeIds[edgeoffset[p] + i] = sIt->first;
1314 edgeIdx[edgeoffset[p] + i] = sIt->second.first;
1315 edgeOrient[edgeoffset[p] + i] = sIt->second.second;
1316 edgeVerts[edgeoffset[p] + i++] = allVerts[sIt->first].size();
1339 for (i = 0; i < n; ++i)
1341 if (edgecounts[i] > 0)
1344 edgeVerts + edgeoffset[i], 1);
1353 for (i = 1; i < n; ++i)
1355 vertoffset[i] = vertoffset[i - 1] + procVerts[i - 1];
1359 for (i = 0, sIt = allEdges.begin(); sIt != allEdges.end(); ++sIt)
1361 for (j = 0; j < allVerts[sIt->first].size(); ++j)
1363 traceIds[vertoffset[p] + i++] = allVerts[sIt->first][j];
1370 map<int, StdRegions::Orientation> orientMap;
1371 map<int, vector<int>> vertMap;
1373 for (cnt = i = 0; i < totEdges; ++i)
1375 ASSERTL0(orientMap.count(edgeIds[i]) == 0,
1376 "Already found edge in orientation map!");
1396 orientMap[edgeIds[i]] = o;
1398 vector<int> verts(edgeVerts[i]);
1400 for (j = 0; j < edgeVerts[i]; ++j)
1402 verts[j] = traceIds[cnt++];
1404 vertMap[edgeIds[i]] = verts;
1411 map<int, int> allCompPairs;
1420 for (
auto &cIt : perComps)
1423 const int id1 = cIt.first;
1424 const int id2 = cIt.second;
1425 std::string id1s = std::to_string(id1);
1426 std::string id2s = std::to_string(id2);
1428 if (compMap.count(id1) > 0)
1430 c[0] = compMap[id1];
1433 if (compMap.count(id2) > 0)
1435 c[1] = compMap[id2];
1441 map<int, int> compPairs;
1444 "Unable to find composite " + id1s +
" in order map.");
1446 "Unable to find composite " + id2s +
" in order map.");
1448 compOrder[id1].size() == compOrder[id2].size(),
1449 "Periodic composites " + id1s +
" and " + id2s +
1450 " should have the same number of elements. Have " +
1451 std::to_string(compOrder[id1].size()) +
" vs " +
1452 std::to_string(compOrder[id2].size()));
1453 ASSERTL0(compOrder[id1].size() > 0,
"Periodic composites " +
1454 id1s +
" and " + id2s +
1458 for (i = 0; i < compOrder[id1].size(); ++i)
1460 int eId1 = compOrder[id1][i];
1461 int eId2 = compOrder[id2][i];
1463 ASSERTL0(compPairs.count(eId1) == 0,
"Already paired.");
1465 if (compPairs.count(eId2) != 0)
1467 ASSERTL0(compPairs[eId2] == eId1,
"Pairing incorrect");
1469 compPairs[eId1] = eId2;
1475 for (i = 0; i < 2; ++i)
1482 if (c[i]->m_geomVec.size() > 0)
1484 for (j = 0; j < c[i]->m_geomVec.size(); ++j)
1486 locEdges.insert(c[i]->m_geomVec[j]->GetGlobalID());
1492 for (
auto &pIt : compPairs)
1494 int ids[2] = {pIt.first, pIt.second};
1495 bool local[2] = {locEdges.count(pIt.first) > 0,
1496 locEdges.count(pIt.second) > 0};
1498 ASSERTL0(orientMap.count(ids[0]) > 0 &&
1499 orientMap.count(ids[1]) > 0,
1500 "Unable to find edge in orientation map.");
1502 allCompPairs[pIt.first] = pIt.second;
1503 allCompPairs[pIt.second] = pIt.first;
1505 for (i = 0; i < 2; ++i)
1512 int other = (i + 1) % 2;
1515 orientMap[ids[i]] == orientMap[ids[other]]
1523 for (i = 0; i < 2; ++i)
1525 int other = (i + 1) % 2;
1528 orientMap[ids[i]] == orientMap[ids[other]]
1533 vector<int> perVerts1 = vertMap[ids[i]];
1534 vector<int> perVerts2 = vertMap[ids[other]];
1536 map<int, pair<int, bool>> tmpMap;
1539 tmpMap[perVerts1[0]] = make_pair(
1540 perVerts2[0], locVerts.count(perVerts2[0]) > 0);
1541 tmpMap[perVerts1[1]] = make_pair(
1542 perVerts2[1], locVerts.count(perVerts2[1]) > 0);
1546 tmpMap[perVerts1[0]] = make_pair(
1547 perVerts2[1], locVerts.count(perVerts2[1]) > 0);
1548 tmpMap[perVerts1[1]] = make_pair(
1549 perVerts2[0], locVerts.count(perVerts2[0]) > 0);
1552 for (
auto &mIt : tmpMap)
1558 auto perIt = periodicVerts.find(mIt.first);
1560 if (perIt == periodicVerts.end())
1562 periodicVerts[mIt.first].push_back(ent2);
1563 perIt = periodicVerts.find(mIt.first);
1568 for (j = 0; j < perIt->second.size(); ++j)
1570 if (perIt->second[j].id == mIt.second.first)
1579 perIt->second.push_back(ent2);
1590 for (cnt = i = 0; i < totEdges; ++i)
1592 int edgeId = edgeIds[i];
1594 ASSERTL0(allCompPairs.count(edgeId) > 0,
1595 "Unable to find matching periodic edge.");
1597 int perEdgeId = allCompPairs[edgeId];
1599 for (j = 0; j < edgeVerts[i]; ++j, ++cnt)
1601 int vId = traceIds[cnt];
1603 auto perId = periodicVerts.find(vId);
1605 if (perId == periodicVerts.end())
1614 orientMap[edgeId] == orientMap[perEdgeId]
1615 ? vertMap[perEdgeId][(j + 1) % 2]
1616 : vertMap[perEdgeId][j];
1620 locVerts.count(perVertexId) > 0);
1622 periodicVerts[vId].push_back(ent);
1629 for (
auto &perIt : periodicVerts)
1632 for (i = 0; i < perIt.second.size(); ++i)
1634 auto perIt2 = periodicVerts.find(perIt.second[i].id);
1635 ASSERTL0(perIt2 != periodicVerts.end(),
1636 "Couldn't find periodic vertex.");
1638 for (j = 0; j < perIt2->second.size(); ++j)
1640 if (perIt2->second[j].id == perIt.first)
1646 for (k = 0; k < perIt.second.size(); ++k)
1648 if (perIt2->second[j].id == perIt.second[k].id)
1657 perIt.second.push_back(perIt2->second[j]);
1665 for (
auto &perIt : periodicVerts)
1667 if (locVerts.count(perIt.first) > 0)
1677 m_graph->GetCompositeOrdering();
1679 m_graph->GetBndRegionOrdering();
1694 map<int, RotPeriodicInfo> rotComp;
1695 map<int, int> perComps;
1696 map<int, vector<int>> allVerts;
1697 map<int, std::vector<SpatialDomains::PointGeom *>> allCoord;
1698 map<int, vector<int>> allEdges;
1699 map<int, vector<StdRegions::Orientation>> allOrient;
1704 int region1ID, region2ID, i, j, k, cnt;
1708 for (i = 0; i < (*m_exp).size(); ++i)
1710 for (j = 0; j < (*m_exp)[i]->GetNverts(); ++j)
1712 int id = (*m_exp)[i]->GetGeom()->GetVid(j);
1713 locVerts.insert(
id);
1716 for (j = 0; j < (*m_exp)[i]->GetGeom()->GetNumEdges(); ++j)
1718 int id = (*m_exp)[i]->GetGeom()->GetEid(j);
1719 locEdges.insert(
id);
1726 for (
auto &it : bregions)
1732 if (locBCond->GetBoundaryConditionType() !=
1739 region1ID = it.first;
1741 std::static_pointer_cast<
1743 ->m_connectedBoundaryRegion;
1747 "Boundary region " + std::to_string(region1ID) +
1748 " should only contain 1 composite.");
1756 if (vComm->GetSize() == 1)
1758 cId1 = it.second->begin()->first;
1759 cId2 = bregions.find(region2ID)->second->begin()->first;
1763 cId1 = bndRegOrder.find(region1ID)->second[0];
1764 cId2 = bndRegOrder.find(region2ID)->second[0];
1768 if (boost::icontains(locBCond->GetUserDefined(),
"Rotated"))
1770 vector<string> tmpstr;
1772 boost::split(tmpstr, locBCond->GetUserDefined(),
1773 boost::is_any_of(
":"));
1775 if (boost::iequals(tmpstr[0],
"Rotated"))
1778 "Expected Rotated user defined string to "
1779 "contain direction and rotation angle "
1780 "and optionally a tolerance, "
1781 "i.e. Rotated:dir:PI/2:1e-6");
1783 ASSERTL1((tmpstr[1] ==
"x") || (tmpstr[1] ==
"y") ||
1786 "not specified as x,y or z");
1789 RotInfo.
m_dir = (tmpstr[1] ==
"x") ? 0
1790 : (tmpstr[1] ==
"y") ? 1
1797 if (tmpstr.size() == 4)
1801 RotInfo.
m_tol = std::stod(tmpstr[3]);
1806 "failed to cast tolerance input "
1807 "to a double value in Rotated"
1808 "boundary information");
1813 RotInfo.
m_tol = 1e-8;
1815 rotComp[cId1] = RotInfo;
1820 it.second->begin()->second;
1822 vector<unsigned int> tmpOrder;
1830 for (i = 0; i < c->m_geomVec.size(); ++i)
1835 ASSERTL1(faceGeom,
"Unable to cast to Geometry2D*");
1838 int faceId = c->m_geomVec[i]->GetGlobalID();
1839 locFaces.insert(faceId);
1843 if (vComm->GetSize() == 1)
1845 tmpOrder.push_back(c->m_geomVec[i]->GetGlobalID());
1850 vector<int> vertList, edgeList;
1851 std::vector<SpatialDomains::PointGeom *> coordVec;
1852 vector<StdRegions::Orientation> orientVec;
1855 vertList.push_back(faceGeom->
GetVid(j));
1856 edgeList.push_back(faceGeom->
GetEid(j));
1857 coordVec.push_back(faceGeom->
GetVertex(j));
1858 orientVec.push_back(faceGeom->
GetEorient(j));
1861 allVerts[faceId] = vertList;
1862 allEdges[faceId] = edgeList;
1863 allCoord[faceId] = coordVec;
1864 allOrient[faceId] = orientVec;
1869 if (vComm->GetSize() == 1)
1871 compOrder[it.second->begin()->first] = tmpOrder;
1877 if (perComps.count(cId1) == 0)
1879 if (perComps.count(cId2) == 0)
1881 perComps[cId1] = cId2;
1885 std::stringstream ss;
1886 ss <<
"Boundary region " << cId2 <<
" should be "
1887 <<
"periodic with " << perComps[cId2] <<
" but "
1888 <<
"found " << cId1 <<
" instead!";
1889 ASSERTL0(perComps[cId2] == cId1, ss.str());
1894 std::stringstream ss;
1895 ss <<
"Boundary region " << cId1 <<
" should be "
1896 <<
"periodic with " << perComps[cId1] <<
" but "
1897 <<
"found " << cId2 <<
" instead!";
1898 ASSERTL0(perComps[cId1] == cId1, ss.str());
1905 for (
auto &cIt : perComps)
1907 idmax =
max(idmax, cIt.first);
1908 idmax =
max(idmax, cIt.second);
1913 for (
auto &cIt : perComps)
1915 perid[cIt.first] = cIt.second;
1919 for (
int i = 0; i < idmax; ++i)
1925 if (perComps.count(perid[i]))
1929 perComps[i] = perid[i];
1936 int n = vComm->GetSize();
1937 int p = vComm->GetRank();
1947 rotcounts[p] = rotComp.size();
1953 for (i = 1; i < n; ++i)
1955 rotoffset[i] = rotoffset[i - 1] + rotcounts[i - 1];
1964 auto rIt = rotComp.begin();
1966 for (i = 0; rIt != rotComp.end(); ++rIt)
1968 compid[rotoffset[p] + i] = rIt->first;
1969 rotdir[rotoffset[p] + i] = rIt->second.m_dir;
1970 rotangle[rotoffset[p] + i] = rIt->second.m_angle;
1971 rottol[rotoffset[p] + i++] = rIt->second.m_tol;
1980 for (i = 0; i < totrot; ++i)
1984 rotComp[compid[i]] = rinfo;
1989 facecounts[p] = locFaces.size();
1995 for (i = 1; i < n; ++i)
1997 faceoffset[i] = faceoffset[i - 1] + facecounts[i - 1];
2011 auto sIt = locFaces.begin();
2012 for (i = 0; sIt != locFaces.end(); ++sIt)
2014 faceIds[faceoffset[p] + i] = *sIt;
2015 faceVerts[faceoffset[p] + i++] = allVerts[*sIt].size();
2038 for (i = 0; i < n; ++i)
2040 if (facecounts[i] > 0)
2043 faceVerts + faceoffset[i], 1);
2054 for (i = 1; i < n; ++i)
2056 vertoffset[i] = vertoffset[i - 1] + procVerts[i - 1];
2070 for (cnt = 0, sIt = locFaces.begin(); sIt != locFaces.end(); ++sIt)
2072 for (j = 0; j < allVerts[*sIt].size(); ++j)
2074 int vertId = allVerts[*sIt][j];
2075 vertIds[vertoffset[p] + cnt] = vertId;
2076 vertX[vertoffset[p] + cnt] = (*allCoord[*sIt][j])(0);
2077 vertY[vertoffset[p] + cnt] = (*allCoord[*sIt][j])(1);
2078 vertZ[vertoffset[p] + cnt] = (*allCoord[*sIt][j])(2);
2079 edgeIds[vertoffset[p] + cnt] = allEdges[*sIt][j];
2080 edgeOrt[vertoffset[p] + cnt++] = allOrient[*sIt][j];
2095 map<int, vector<int>> vertMap;
2096 map<int, vector<int>> edgeMap;
2097 map<int, std::vector<SpatialDomains::PointGeom *>> coordMap;
2103 map<int, SpatialDomains::PointGeomUniquePtr> vCoMap;
2104 map<int, pair<int, int>> eIdMap;
2106 for (cnt = i = 0; i < totFaces; ++i)
2108 vector<int> edges(faceVerts[i]);
2109 vector<int> verts(faceVerts[i]);
2110 std::vector<SpatialDomains::PointGeom *> coord(faceVerts[i]);
2115 for (j = 0; j < faceVerts[i]; ++j, ++cnt)
2117 edges[j] = edgeIds[cnt];
2118 verts[j] = vertIds[cnt];
2120 auto vIt = vCoMap.find(vertIds[cnt]);
2122 if (vIt == vCoMap.end())
2126 vertY[cnt], vertZ[cnt]);
2127 coord[j] = pt.get();
2128 vCoMap[vertIds[cnt]] = std::move(pt);
2132 coord[j] = vIt->second.get();
2136 auto testIns = eIdMap.insert(make_pair(
2138 make_pair(vertIds[tmp + j],
2139 vertIds[tmp + ((j + 1) % faceVerts[i])])));
2141 if (testIns.second ==
false)
2164 swap(testIns.first->second.first,
2165 testIns.first->second.second);
2169 vertMap[faceIds[i]] = verts;
2170 edgeMap[faceIds[i]] = edges;
2171 coordMap[faceIds[i]] = coord;
2189 map<int, map<StdRegions::Orientation, vector<int>>> vmap;
2190 map<int, map<StdRegions::Orientation, vector<int>>> emap;
2192 map<StdRegions::Orientation, vector<int>> quadVertMap;
2202 map<StdRegions::Orientation, vector<int>> quadEdgeMap;
2212 map<StdRegions::Orientation, vector<int>> triVertMap;
2216 map<StdRegions::Orientation, vector<int>> triEdgeMap;
2220 vmap[3] = triVertMap;
2221 vmap[4] = quadVertMap;
2222 emap[3] = triEdgeMap;
2223 emap[4] = quadEdgeMap;
2225 map<int, int> allCompPairs;
2229 map<int, int> fIdToCompId;
2234 for (
auto &cIt : perComps)
2237 const int id1 = cIt.first;
2238 const int id2 = cIt.second;
2239 std::string id1s = std::to_string(id1);
2240 std::string id2s = std::to_string(id2);
2242 if (compMap.count(id1) > 0)
2244 c[0] = compMap[id1];
2247 if (compMap.count(id2) > 0)
2249 c[1] = compMap[id2];
2255 map<int, int> compPairs;
2258 "Unable to find composite " + id1s +
" in order map.");
2260 "Unable to find composite " + id2s +
" in order map.");
2262 compOrder[id1].size() == compOrder[id2].size(),
2263 "Periodic composites " + id1s +
" and " + id2s +
2264 " should have the same number of elements. Have " +
2265 std::to_string(compOrder[id1].size()) +
" vs " +
2266 std::to_string(compOrder[id2].size()));
2267 ASSERTL0(compOrder[id1].size() > 0,
"Periodic composites " +
2268 id1s +
" and " + id2s +
2272 for (i = 0; i < compOrder[id1].size(); ++i)
2274 int eId1 = compOrder[id1][i];
2275 int eId2 = compOrder[id2][i];
2277 ASSERTL0(compPairs.count(eId1) == 0,
"Already paired.");
2280 if (compPairs.count(eId2) != 0)
2282 ASSERTL0(compPairs[eId2] == eId1,
"Pairing incorrect");
2284 compPairs[eId1] = eId2;
2287 fIdToCompId[eId1] = id1;
2288 fIdToCompId[eId2] = id2;
2294 for (
auto &pIt : compPairs)
2296 int ids[2] = {pIt.first, pIt.second};
2297 bool local[2] = {locFaces.count(pIt.first) > 0,
2298 locFaces.count(pIt.second) > 0};
2300 ASSERTL0(coordMap.count(ids[0]) > 0 &&
2301 coordMap.count(ids[1]) > 0,
2302 "Unable to find face in coordinate map");
2304 allCompPairs[pIt.first] = pIt.second;
2305 allCompPairs[pIt.second] = pIt.first;
2309 std::vector<SpatialDomains::PointGeom *> tmpVec[2] = {
2310 coordMap[ids[0]], coordMap[ids[1]]};
2312 ASSERTL0(tmpVec[0].size() == tmpVec[1].size(),
2313 "Two periodic faces have different number "
2322 bool rotbnd =
false;
2329 if (rotComp.count(fIdToCompId[pIt.first]))
2332 dir = rotComp[fIdToCompId[pIt.first]].m_dir;
2333 angle = rotComp[fIdToCompId[pIt.first]].m_angle;
2334 tol = rotComp[fIdToCompId[pIt.first]].m_tol;
2338 for (i = 0; i < 2; ++i)
2346 int other = (i + 1) % 2;
2349 sign = (i == 0) ? 1.0 : -1.0;
2352 if (tmpVec[0].size() == 3)
2355 {tmpVec[i][0], tmpVec[i][1], tmpVec[i][2]},
2356 {tmpVec[other][0], tmpVec[other][1],
2358 rotbnd, dir,
sign * angle, tol);
2363 {tmpVec[i][0], tmpVec[i][1], tmpVec[i][2],
2365 {tmpVec[other][0], tmpVec[other][1],
2366 tmpVec[other][2], tmpVec[other][3]},
2367 rotbnd, dir,
sign * angle, tol);
2376 int nFaceVerts = vertMap[ids[0]].size();
2379 for (i = 0; i < 2; ++i)
2381 int other = (i + 1) % 2;
2384 sign = (i == 0) ? 1.0 : -1.0;
2387 if (tmpVec[0].size() == 3)
2390 {tmpVec[i][0], tmpVec[i][1], tmpVec[i][2]},
2391 {tmpVec[other][0], tmpVec[other][1],
2393 rotbnd, dir,
sign * angle, tol);
2398 {tmpVec[i][0], tmpVec[i][1], tmpVec[i][2],
2400 {tmpVec[other][0], tmpVec[other][1],
2401 tmpVec[other][2], tmpVec[other][3]},
2402 rotbnd, dir,
sign * angle, tol);
2405 if (nFaceVerts == 3)
2410 "Unsupported face orientation for face " +
2411 std::to_string(ids[i]));
2415 vector<int> per1 = vertMap[ids[i]];
2416 vector<int> per2 = vertMap[ids[other]];
2420 map<int, pair<int, bool>> tmpMap;
2424 for (j = 0; j < nFaceVerts; ++j)
2426 int v = vmap[nFaceVerts][o][j];
2428 make_pair(per2[v], locVerts.count(per2[v]) > 0);
2432 for (
auto &mIt : tmpMap)
2439 auto perIt = periodicVerts.find(mIt.first);
2441 if (perIt == periodicVerts.end())
2445 periodicVerts[mIt.first].push_back(ent2);
2446 perIt = periodicVerts.find(mIt.first);
2453 for (k = 0; k < perIt->second.size(); ++k)
2455 if (perIt->second[k].id == mIt.second.first)
2461 if (k == perIt->second.size())
2463 perIt->second.push_back(ent2);
2471 for (i = 0; i < 2; ++i)
2473 int other = (i + 1) % 2;
2476 sign = (i == 0) ? 1.0 : -1.0;
2478 if (tmpVec[0].size() == 3)
2481 {tmpVec[i][0], tmpVec[i][1], tmpVec[i][2]},
2482 {tmpVec[other][0], tmpVec[other][1],
2484 rotbnd, dir,
sign * angle, tol);
2489 {tmpVec[i][0], tmpVec[i][1], tmpVec[i][2],
2491 {tmpVec[other][0], tmpVec[other][1],
2492 tmpVec[other][2], tmpVec[other][3]},
2493 rotbnd, dir,
sign * angle, tol);
2496 vector<int> per1 = edgeMap[ids[i]];
2497 vector<int> per2 = edgeMap[ids[other]];
2499 map<int, pair<int, bool>> tmpMap;
2501 for (j = 0; j < nFaceVerts; ++j)
2503 int e = emap[nFaceVerts][o][j];
2505 make_pair(per2[e], locEdges.count(per2[e]) > 0);
2508 for (
auto &mIt : tmpMap)
2515 auto perIt = periodicEdges.find(mIt.first);
2517 if (perIt == periodicEdges.end())
2519 periodicEdges[mIt.first].push_back(ent2);
2520 perIt = periodicEdges.find(mIt.first);
2524 for (k = 0; k < perIt->second.size(); ++k)
2526 if (perIt->second[k].id == mIt.second.first)
2532 if (k == perIt->second.size())
2534 perIt->second.push_back(ent2);
2544 ASSERTL1(allCompPairs.size() == fIdToCompId.size(),
2545 "At this point the size of allCompPairs "
2546 "should have been the same as fIdToCompId");
2550 map<int, int> eIdToCompId;
2556 for (cnt = i = 0; i < totFaces; ++i)
2558 bool rotbnd =
false;
2563 int faceId = faceIds[i];
2565 ASSERTL0(allCompPairs.count(faceId) > 0,
2566 "Unable to find matching periodic face. faceId = " +
2567 std::to_string(faceId));
2569 int perFaceId = allCompPairs[faceId];
2572 ASSERTL1((rotComp.size() == 0) || fIdToCompId.count(faceId) > 0,
2573 "Face " + std::to_string(faceId) +
2574 " not found in fIdtoCompId map");
2575 if (rotComp.count(fIdToCompId[faceId]))
2578 dir = rotComp[fIdToCompId[faceId]].m_dir;
2579 angle = rotComp[fIdToCompId[faceId]].m_angle;
2580 tol = rotComp[fIdToCompId[faceId]].m_tol;
2583 for (j = 0; j < faceVerts[i]; ++j, ++cnt)
2585 int vId = vertIds[cnt];
2587 auto perId = periodicVerts.find(vId);
2589 if (perId == periodicVerts.end())
2597 std::vector<SpatialDomains::PointGeom *> tmpVec[2] = {
2598 coordMap[faceId], coordMap[perFaceId]};
2600 int nFaceVerts = tmpVec[0].size();
2604 {tmpVec[0][0], tmpVec[0][1],
2606 {tmpVec[1][0], tmpVec[1][1],
2608 rotbnd, dir, angle, tol)
2610 {tmpVec[0][0], tmpVec[0][1], tmpVec[0][2],
2612 {tmpVec[1][0], tmpVec[1][1], tmpVec[1][2],
2614 rotbnd, dir, angle, tol);
2619 vertMap[perFaceId][vmap[nFaceVerts][o][j]];
2623 locVerts.count(perVertexId) > 0);
2625 periodicVerts[vId].push_back(ent);
2628 int eId = edgeIds[cnt];
2630 perId = periodicEdges.find(eId);
2636 eIdToCompId[eId] = fIdToCompId[faceId];
2639 if (perId == periodicEdges.end())
2646 std::vector<SpatialDomains::PointGeom *> tmpVec[2] = {
2647 coordMap[faceId], coordMap[perFaceId]};
2649 int nFaceEdges = tmpVec[0].size();
2653 {tmpVec[0][0], tmpVec[0][1],
2655 {tmpVec[1][0], tmpVec[1][1],
2657 rotbnd, dir, angle, tol)
2659 {tmpVec[0][0], tmpVec[0][1], tmpVec[0][2],
2661 {tmpVec[1][0], tmpVec[1][1], tmpVec[1][2],
2663 rotbnd, dir, angle, tol);
2668 edgeMap[perFaceId][emap[nFaceEdges][o][j]];
2671 locEdges.count(perEdgeId) > 0);
2673 periodicEdges[eId].push_back(ent);
2679 eIdToCompId[perEdgeId] = fIdToCompId[perFaceId];
2687 for (
auto &perIt : periodicVerts)
2690 for (i = 0; i < perIt.second.size(); ++i)
2693 auto perIt2 = periodicVerts.find(perIt.second[i].id);
2694 ASSERTL0(perIt2 != periodicVerts.end(),
2695 "Couldn't find periodic vertex.");
2700 for (j = 0; j < perIt2->second.size(); ++j)
2702 if (perIt2->second[j].id == perIt.first)
2707 for (k = 0; k < perIt.second.size(); ++k)
2709 if (perIt2->second[j].id == perIt.second[k].id)
2715 if (k == perIt.second.size())
2717 perIt.second.push_back(perIt2->second[j]);
2723 for (
auto &perIt : periodicEdges)
2725 for (i = 0; i < perIt.second.size(); ++i)
2727 auto perIt2 = periodicEdges.find(perIt.second[i].id);
2728 ASSERTL0(perIt2 != periodicEdges.end(),
2729 "Couldn't find periodic edge.");
2731 for (j = 0; j < perIt2->second.size(); ++j)
2733 if (perIt2->second[j].id == perIt.first)
2738 for (k = 0; k < perIt.second.size(); ++k)
2740 if (perIt2->second[j].id == perIt.second[k].id)
2746 if (k == perIt.second.size())
2748 perIt.second.push_back(perIt2->second[j]);
2755 for (
auto &perIt : periodicEdges)
2757 bool rotbnd =
false;
2763 auto eIt = eIdMap.find(perIt.first);
2765 *vCoMap[eIt->second.second]};
2768 if (rotComp.count(eIdToCompId[perIt.first]))
2771 dir = rotComp[eIdToCompId[perIt.first]].m_dir;
2772 angle = rotComp[eIdToCompId[perIt.first]].m_angle;
2773 tol = rotComp[eIdToCompId[perIt.first]].m_tol;
2779 for (i = 0; i < perIt.second.size(); ++i)
2781 eIt = eIdMap.find(perIt.second[i].id);
2784 *vCoMap[eIt->second.first],
2785 *vCoMap[eIt->second.second]};
2787 int vMap[2] = {-1, -1};
2793 r.
Rotate(v[0], dir, angle);
2795 if (r.
dist(w[0]) < tol)
2801 r.
Rotate(v[1], dir, angle);
2802 if (r.
dist(w[0]) < tol)
2809 "Unable to align rotationally "
2810 "periodic edge vertex");
2817 0.5 * (w[0](0) - v[0](0) + w[1](0) - v[1](0));
2819 0.5 * (w[0](1) - v[0](1) + w[1](1) - v[1](1));
2821 0.5 * (w[0](2) - v[0](2) + w[1](2) - v[1](2));
2823 for (j = 0; j < 2; ++j)
2828 for (k = 0; k < 2; ++k)
2834 if (
sqrt((x1 - x) * (x1 - x) +
2835 (y1 - y) * (y1 - y) +
2836 (z1 - z) * (z1 - z)) < 1e-8)
2845 ASSERTL0(vMap[0] >= 0 && vMap[1] >= 0,
2846 "Unable to align periodic edge vertex.");
2847 ASSERTL0((vMap[0] == 0 || vMap[0] == 1) &&
2848 (vMap[1] == 0 || vMap[1] == 1) &&
2849 (vMap[0] != vMap[1]),
2850 "Unable to align periodic edge vertex.");
2864 for (
auto &perIt : periodicVerts)
2866 if (locVerts.count(perIt.first) > 0)
2872 for (
auto &perIt : periodicEdges)
2874 if (locEdges.count(perIt.first) > 0)
2882 ASSERTL1(
false,
"Not setup for this expansion");