46 #include <boost/assign/std/vector.hpp>
47 #include <boost/tuple/tuple.hpp>
54 namespace MultiRegions
66 DisContField3D::DisContField3D() :
68 m_bndCondExpansions (),
81 const std::string &variable,
82 const bool SetUpJustDG)
83 :
ExpList3D (pSession, graph3D, variable),
84 m_bndCondExpansions(),
89 if (variable.compare(
"DefaultVar") != 0)
116 for(f = 0; f < locExpList->GetExpSize(); ++f)
119 = (*m_exp)[ElmtID[cnt+f]]->
120 as<LocalRegions::Expansion3D>();
122 = locExpList->GetExp(f)->
123 as<LocalRegions::Expansion2D>();
125 exp3d->SetFaceExp(FaceID[cnt+f],exp2d);
126 exp2d->SetAdjacentElementExp(FaceID[cnt+f],exp3d);
140 const std::string &variable,
141 const bool SetUpJustDG)
171 for(f = 0; f < locExpList->GetExpSize(); ++f)
174 = (*m_exp)[ElmtID[cnt+f]]->
175 as<LocalRegions::Expansion3D>();
177 = locExpList->GetExp(f)->
178 as<LocalRegions::Expansion2D>();
180 exp3d->SetFaceExp(FaceID[cnt+f],exp2d);
181 exp2d->SetAdjacentElementExp(FaceID[cnt+f],exp3d);
216 for(f = 0; f < locExpList->GetExpSize(); ++f)
219 = (*m_exp)[ElmtID[cnt+f]]->
220 as<LocalRegions::Expansion3D>();
222 = locExpList->GetExp(f)->
223 as<LocalRegions::Expansion2D>();
225 exp3d->SetFaceExp(FaceID[cnt+f], exp2d);
226 exp2d->SetAdjacentElementExp(FaceID[cnt+f], exp3d);
232 if (
m_session->DefinesSolverInfo(
"PROJECTION"))
234 std::string ProjectStr =
236 if (ProjectStr ==
"MixedCGDG" ||
237 ProjectStr ==
"Mixed_CG_Discontinuous")
259 m_bndCondExpansions (In.m_bndCondExpansions),
260 m_bndConditions (In.m_bndConditions),
261 m_globalBndMat (In.m_globalBndMat),
262 m_trace (In.m_trace),
263 m_traceMap (In.m_traceMap),
264 m_locTraceToTraceMap (In.m_locTraceToTraceMap),
265 m_periodicFaces (In.m_periodicFaces),
266 m_periodicEdges (In.m_periodicEdges),
267 m_periodicVerts (In.m_periodicVerts)
282 "Routine currently only tested for HybridDGHelmholtz");
285 "The local to global map is not set up for the requested "
294 (*m_globalBndMat)[mkey] = glo_matrix;
298 glo_matrix = matrixIter->second;
325 bool UseGenSegExp =
true;
336 if (
m_session->DefinesCmdLineArgument(
"verbose"))
349 for (
int i = 0; i <
m_exp->size(); ++i)
351 for (
int j = 0; j < (*m_exp)[i]->GetNfaces(); ++j)
357 exp3d->SetFaceExp (j, exp2d);
366 for (
int i = 0; i <
m_trace->GetExpSize(); ++i)
371 int offset =
m_trace->GetPhys_Offset(i);
372 int traceGeomId = traceEl->GetGeom2D()->GetGlobalID();
378 if (traceGeomId != min(pIt->second[0].id, traceGeomId))
380 traceEl->GetLeftAdjacentElementExp()->NegateFaceNormal(
381 traceEl->GetLeftAdjacentElementFace());
384 else if (
m_traceMap->GetTraceToUniversalMapUnique(offset) < 0)
386 traceEl->GetLeftAdjacentElementExp()->NegateFaceNormal(
387 traceEl->GetLeftAdjacentElementFace());
402 m_traceMap->GetBndCondTraceToGlobalTraceMap(cnt+e));
409 boost::unordered_map<int,pair<int,int> > perFaceToExpMap;
410 boost::unordered_map<int,pair<int,int> >
::iterator it2;
413 for (
int n = 0; n <
m_exp->size(); ++n)
416 for (
int e = 0; e < exp3d->GetNfaces(); ++e, ++cnt)
419 exp3d->GetGeom3D()->GetFid(e));
423 perFaceToExpMap[it->first] = make_pair(n, e);
431 for (
int i = 0; i <
m_exp->size(); ++i)
433 for (
int j = 0; j < (*m_exp)[i]->GetNfaces(); ++j, ++cnt)
441 for (
int n = 0; n <
m_exp->size(); ++n)
444 for (
int e = 0; e < exp3d->GetNfaces(); ++e, ++cnt)
446 int faceGeomId = exp3d->
GetGeom3D()->GetFid(e);
447 int offset =
m_trace->GetPhys_Offset(
448 elmtToTrace[n][e]->GetElmtId());
456 it2 = perFaceToExpMap.find(ent.
id);
458 if (it2 == perFaceToExpMap.end())
460 if (
m_session->GetComm()->GetSize() > 1 &&
467 ASSERTL1(
false,
"Periodic edge not found!");
472 "Periodic face in non-forward space?");
474 int offset2 =
m_trace->GetPhys_Offset(
475 elmtToTrace[it2->second.first][it2->second.second]->
480 int nquad1 = elmtToTrace[n][e]->GetNumPoints(0);
481 int nquad2 = elmtToTrace[n][e]->GetNumPoints(1);
483 vector<int> tmpBwd(nquad1*nquad2);
484 vector<int> tmpFwd(nquad1*nquad2);
491 for (
int i = 0; i < nquad2; ++i)
493 for (
int j = 0; j < nquad1; ++j)
495 tmpBwd[i*nquad1+j] = offset2 + i*nquad1+j;
496 tmpFwd[i*nquad1+j] = offset + j*nquad2+i;
502 for (
int i = 0; i < nquad2; ++i)
504 for (
int j = 0; j < nquad1; ++j)
506 tmpBwd[i*nquad1+j] = offset2 + i*nquad1+j;
507 tmpFwd[i*nquad1+j] = offset + i*nquad1+j;
518 for (
int i = 0; i < nquad2; ++i)
520 for (
int j = 0; j < nquad1/2; ++j)
522 swap(tmpFwd[i*nquad1 + j],
523 tmpFwd[i*nquad1 + nquad1-j-1]);
534 for (
int j = 0; j < nquad1; ++j)
536 for (
int i = 0; i < nquad2/2; ++i)
538 swap(tmpFwd[i*nquad1 + j],
539 tmpFwd[(nquad2-i-1)*nquad1 + j]);
544 for (
int i = 0; i < nquad1*nquad2; ++i)
570 bool returnval =
true;
590 int vSame = returnval ? 1 : 0;
611 const std::string &variable)
621 SpatialDomains::BoundaryRegionCollection::const_iterator it;
624 for (it = bregions.begin(); it != bregions.end(); ++it)
628 if (boundaryCondition->GetBoundaryConditionType() !=
641 for (it = bregions.begin(); it != bregions.end(); ++it)
644 bconditions, it->first, variable);
646 if(locBCond->GetBoundaryConditionType()
654 if(locBCond->GetBoundaryConditionType() !=
661 m_bndConditions[cnt++] = locBCond;
675 const std::string &variable)
682 = boost::dynamic_pointer_cast<
684 SpatialDomains::BoundaryRegionCollection::const_iterator it;
707 map<int,int> perComps;
708 map<int,vector<int> > allVerts;
709 map<int,SpatialDomains::PointGeomVector> allCoord;
710 map<int,vector<int> > allEdges;
711 map<int,vector<StdRegions::Orientation> > allOrient;
716 int region1ID, region2ID, i, j, k, cnt;
720 for(i = 0; i < (*m_exp).size(); ++i)
722 for(j = 0; j < (*m_exp)[i]->GetNverts(); ++j)
724 int id = (*m_exp)[i]->GetGeom()->GetVid(j);
728 for(j = 0; j < (*m_exp)[i]->GetNedges(); ++j)
730 int id = (*m_exp)[i]->GetGeom()->GetEid(j);
738 for (it = bregions.begin(); it != bregions.end(); ++it)
741 bconditions, it->first, variable);
743 if (locBCond->GetBoundaryConditionType()
750 region1ID = it->first;
751 region2ID = boost::static_pointer_cast<
753 locBCond)->m_connectedBoundaryRegion;
757 "Boundary region "+boost::lexical_cast<
string>(
758 region1ID)+
" should only contain 1 composite.");
766 if (vComm->GetSize() == 1)
768 cId1 = it->second->begin()->first;
769 cId2 = bregions.find(region2ID)->second->begin()->first;
773 cId1 = bndRegOrder.find(region1ID)->second[0];
774 cId2 = bndRegOrder.find(region2ID)->second[0];
778 vector<unsigned int> tmpOrder;
784 for (i = 0; i < c->size(); ++i)
787 boost::dynamic_pointer_cast<
789 ASSERTL1(faceGeom,
"Unable to cast to shared ptr");
792 int faceId = (*c)[i]->GetGlobalID();
793 locFaces.insert(faceId);
797 if (vComm->GetSize() == 1)
799 tmpOrder.push_back((*c)[i]->GetGlobalID());
804 vector<int> vertList, edgeList;
806 vector<StdRegions::Orientation> orientVec;
807 for (j = 0; j < faceGeom->GetNumVerts(); ++j)
809 vertList .push_back(faceGeom->GetVid (j));
810 edgeList .push_back(faceGeom->GetEid (j));
811 coordVec .push_back(faceGeom->GetVertex(j));
812 orientVec.push_back(faceGeom->GetEorient(j));
815 allVerts [faceId] = vertList;
816 allEdges [faceId] = edgeList;
817 allCoord [faceId] = coordVec;
818 allOrient[faceId] = orientVec;
823 if (vComm->GetSize() == 1)
825 compOrder[it->second->begin()->first] = tmpOrder;
831 if (perComps.count(cId1) == 0)
833 if (perComps.count(cId2) == 0)
835 perComps[cId1] = cId2;
839 std::stringstream ss;
840 ss <<
"Boundary region " << cId2 <<
" should be "
841 <<
"periodic with " << perComps[cId2] <<
" but "
842 <<
"found " << cId1 <<
" instead!";
843 ASSERTL0(perComps[cId2] == cId1, ss.str());
848 std::stringstream ss;
849 ss <<
"Boundary region " << cId1 <<
" should be "
850 <<
"periodic with " << perComps[cId1] <<
" but "
851 <<
"found " << cId2 <<
" instead!";
852 ASSERTL0(perComps[cId1] == cId1, ss.str());
858 int n = vComm->GetSize();
859 int p = vComm->GetRank();
867 facecounts[
p] = locFaces.size();
873 for (i = 1; i < n; ++i)
875 faceoffset[i] = faceoffset[i-1] + facecounts[i-1];
890 for (i = 0, sIt = locFaces.begin(); sIt != locFaces.end(); ++sIt)
892 faceIds [faceoffset[
p] + i ] = *sIt;
893 faceVerts[faceoffset[
p] + i++] = allVerts[*sIt].size();
916 for (i = 0; i < n; ++i)
918 if (facecounts[i] > 0)
921 facecounts[i], faceVerts + faceoffset[i], 1);
932 for (i = 1; i < n; ++i)
934 vertoffset[i] = vertoffset[i-1] + procVerts[i-1];
948 for (cnt = 0, sIt = locFaces.begin();
949 sIt != locFaces.end(); ++sIt)
951 for (j = 0; j < allVerts[*sIt].size(); ++j)
953 int vertId = allVerts[*sIt][j];
954 vertIds[vertoffset[
p] + cnt ] = vertId;
955 vertX [vertoffset[
p] + cnt ] = (*allCoord[*sIt][j])(0);
956 vertY [vertoffset[
p] + cnt ] = (*allCoord[*sIt][j])(1);
957 vertZ [vertoffset[
p] + cnt ] = (*allCoord[*sIt][j])(2);
958 edgeIds[vertoffset[
p] + cnt ] = allEdges [*sIt][j];
959 edgeOrt[vertoffset[
p] + cnt++] = allOrient[*sIt][j];
974 map<int, vector<int> > vertMap;
975 map<int, vector<int> > edgeMap;
976 map<int, SpatialDomains::PointGeomVector> coordMap;
982 map<int, SpatialDomains::PointGeomSharedPtr> vCoMap;
983 map<int, pair<int, int> > eIdMap;
985 for (cnt = i = 0; i < totFaces; ++i)
987 vector<int> edges(faceVerts[i]);
988 vector<int> verts(faceVerts[i]);
994 for (j = 0; j < faceVerts[i]; ++j, ++cnt)
996 edges[j] = edgeIds[cnt];
997 verts[j] = vertIds[cnt];
1000 3, verts[j], vertX[cnt], vertY[cnt], vertZ[cnt]);
1001 vCoMap[vertIds[cnt]] = coord[j];
1004 pair<map<int, pair<int, int> >
::iterator,
bool> testIns =
1005 eIdMap.insert(make_pair(
1007 make_pair(vertIds[tmp+j],
1008 vertIds[tmp+((j+1) % faceVerts[i])])));
1010 if (testIns.second ==
false)
1022 swap(testIns.first->second.first,
1023 testIns.first->second.second);
1027 vertMap [faceIds[i]] = verts;
1028 edgeMap [faceIds[i]] = edges;
1029 coordMap[faceIds[i]] = coord;
1036 map<int,int>::const_iterator oIt;
1050 map<int, map<StdRegions::Orientation, vector<int> > > vmap;
1051 map<int, map<StdRegions::Orientation, vector<int> > > emap;
1053 map<StdRegions::Orientation, vector<int> > quadVertMap;
1063 map<StdRegions::Orientation, vector<int> > quadEdgeMap;
1073 map<StdRegions::Orientation, vector<int> > triVertMap;
1077 map<StdRegions::Orientation, vector<int> > triEdgeMap;
1081 vmap[3] = triVertMap;
1082 vmap[4] = quadVertMap;
1083 emap[3] = triEdgeMap;
1084 emap[4] = quadEdgeMap;
1086 map<int,int> allCompPairs;
1091 for (cIt = perComps.begin(); cIt != perComps.end(); ++cIt)
1094 const int id1 = cIt->first;
1095 const int id2 = cIt->second;
1096 std::string id1s = boost::lexical_cast<
string>(id1);
1097 std::string id2s = boost::lexical_cast<
string>(id2);
1099 if (compMap.count(id1) > 0)
1101 c[0] = compMap[id1];
1104 if (compMap.count(id2) > 0)
1106 c[1] = compMap[id2];
1110 "Neither composite not found on this process!");
1115 map<int,int> compPairs;
1118 "Unable to find composite "+id1s+
" in order map.");
1120 "Unable to find composite "+id2s+
" in order map.");
1121 ASSERTL0(compOrder[id1].size() == compOrder[id2].size(),
1122 "Periodic composites "+id1s+
" and "+id2s+
1123 " should have the same number of elements.");
1124 ASSERTL0(compOrder[id1].size() > 0,
1125 "Periodic composites "+id1s+
" and "+id2s+
1129 for (i = 0; i < compOrder[id1].size(); ++i)
1131 int eId1 = compOrder[id1][i];
1132 int eId2 = compOrder[id2][i];
1134 ASSERTL0(compPairs.count(eId1) == 0,
1138 if (compPairs.count(eId2) != 0)
1140 ASSERTL0(compPairs[eId2] == eId1,
"Pairing incorrect");
1142 compPairs[eId1] = eId2;
1148 for (pIt = compPairs.begin(); pIt != compPairs.end(); ++pIt)
1150 int ids [2] = {pIt->first, pIt->second};
1151 bool local[2] = {locFaces.count(pIt->first) > 0,
1152 locFaces.count(pIt->second) > 0};
1154 ASSERTL0(coordMap.count(ids[0]) > 0 &&
1155 coordMap.count(ids[1]) > 0,
1156 "Unable to find face in coordinate map");
1158 allCompPairs[pIt->first ] = pIt->second;
1159 allCompPairs[pIt->second] = pIt->first;
1164 = { coordMap[ids[0]], coordMap[ids[1]] };
1166 ASSERTL0(tmpVec[0].size() == tmpVec[1].size(),
1167 "Two periodic faces have different number "
1178 for (i = 0; i < 2; ++i)
1186 int other = (i+1) % 2;
1189 if (tmpVec[0].size() == 3)
1192 tmpVec[i], tmpVec[other]);
1197 tmpVec[i], tmpVec[other]);
1207 int nFaceVerts = vertMap[ids[0]].size();
1210 for (i = 0; i < 2; ++i)
1212 int other = (i+1) % 2;
1215 if (tmpVec[0].size() == 3)
1218 tmpVec[i], tmpVec[other]);
1223 tmpVec[i], tmpVec[other]);
1226 if (nFaceVerts == 3)
1231 "Unsupported face orientation for face "+
1232 boost::lexical_cast<string>(ids[i]));
1236 vector<int> per1 = vertMap[ids[i]];
1237 vector<int> per2 = vertMap[ids[other]];
1241 map<int, pair<int, bool> > tmpMap;
1246 for (j = 0; j < nFaceVerts; ++j)
1248 int v = vmap[nFaceVerts][o][j];
1249 tmpMap[per1[j]] = make_pair(
1250 per2[v], locVerts.count(per2[v]) > 0);
1254 for (mIt = tmpMap.begin(); mIt != tmpMap.end(); ++mIt)
1258 mIt->second.second);
1264 if (perIt == periodicVerts.end())
1268 periodicVerts[mIt->first].push_back(ent2);
1269 perIt = periodicVerts.find(mIt->first);
1276 for (k = 0; k < perIt->second.size(); ++k)
1278 if (perIt->second[k].id == mIt->second.first)
1284 if (k == perIt->second.size())
1286 perIt->second.push_back(ent2);
1294 for (i = 0; i < 2; ++i)
1296 int other = (i+1) % 2;
1298 if (tmpVec[0].size() == 3)
1301 tmpVec[i], tmpVec[other]);
1306 tmpVec[i], tmpVec[other]);
1309 vector<int> per1 = edgeMap[ids[i]];
1310 vector<int> per2 = edgeMap[ids[other]];
1312 map<int, pair<int, bool> > tmpMap;
1315 for (j = 0; j < nFaceVerts; ++j)
1317 int e = emap[nFaceVerts][o][j];
1318 tmpMap[per1[j]] = make_pair(
1319 per2[e], locEdges.count(per2[e]) > 0);
1322 for (mIt = tmpMap.begin(); mIt != tmpMap.end(); ++mIt)
1328 mIt->second.second);
1332 if (perIt == periodicEdges.end())
1334 periodicEdges[mIt->first].push_back(ent2);
1335 perIt = periodicEdges.find(mIt->first);
1339 for (k = 0; k < perIt->second.size(); ++k)
1341 if (perIt->second[k].id == mIt->second.first)
1347 if (k == perIt->second.size())
1349 perIt->second.push_back(ent2);
1358 pairSizes[
p] = allCompPairs.size();
1366 for (i = 1; i < n; ++i)
1368 pairOffsets[i] = pairOffsets[i-1] + pairSizes[i-1];
1374 cnt = pairOffsets[
p];
1376 for (pIt = allCompPairs.begin(); pIt != allCompPairs.end(); ++pIt)
1378 first [cnt ] = pIt->first;
1379 second[cnt++] = pIt->second;
1385 allCompPairs.clear();
1387 for(cnt = 0; cnt < totPairSizes; ++cnt)
1389 allCompPairs[first[cnt]] = second[cnt];
1396 for (cnt = i = 0; i < totFaces; ++i)
1398 int faceId = faceIds[i];
1400 ASSERTL0(allCompPairs.count(faceId) > 0,
1401 "Unable to find matching periodic face.");
1403 int perFaceId = allCompPairs[faceId];
1405 for (j = 0; j < faceVerts[i]; ++j, ++cnt)
1407 int vId = vertIds[cnt];
1411 if (perId == periodicVerts.end())
1419 = { coordMap[faceId], coordMap[perFaceId] };
1421 int nFaceVerts = tmpVec[0].size();
1424 tmpVec[0], tmpVec[1]) :
1426 tmpVec[0], tmpVec[1]);
1430 int perVertexId = vertMap[perFaceId][vmap[nFaceVerts][o][j]];
1435 locVerts.count(perVertexId) > 0);
1437 periodicVerts[vId].push_back(ent);
1440 int eId = edgeIds[cnt];
1442 perId = periodicEdges.find(eId);
1444 if (perId == periodicEdges.end())
1452 = { coordMap[faceId], coordMap[perFaceId] };
1454 int nFaceEdges = tmpVec[0].size();
1457 tmpVec[0], tmpVec[1]) :
1459 tmpVec[0], tmpVec[1]);
1463 int perEdgeId = edgeMap[perFaceId][emap[nFaceEdges][o][j]];
1468 locEdges.count(perEdgeId) > 0);
1470 periodicEdges[eId].push_back(ent);
1478 for (perIt = periodicVerts.begin();
1479 perIt != periodicVerts.end(); ++perIt)
1482 for (i = 0; i < perIt->second.size(); ++i)
1485 perIt2 = periodicVerts.find(perIt->second[i].id);
1486 ASSERTL0(perIt2 != periodicVerts.end(),
1487 "Couldn't find periodic vertex.");
1492 for (j = 0; j < perIt2->second.size(); ++j)
1494 if (perIt2->second[j].id == perIt->first)
1499 for (k = 0; k < perIt->second.size(); ++k)
1501 if (perIt2->second[j].id == perIt->second[k].id)
1507 if (k == perIt->second.size())
1509 perIt->second.push_back(perIt2->second[j]);
1515 for (perIt = periodicEdges.begin();
1516 perIt != periodicEdges.end(); ++perIt)
1518 for (i = 0; i < perIt->second.size(); ++i)
1520 perIt2 = periodicEdges.find(perIt->second[i].id);
1521 ASSERTL0(perIt2 != periodicEdges.end(),
1522 "Couldn't find periodic edge.");
1524 for (j = 0; j < perIt2->second.size(); ++j)
1526 if (perIt2->second[j].id == perIt->first)
1531 for (k = 0; k < perIt->second.size(); ++k)
1533 if (perIt2->second[j].id == perIt->second[k].id)
1539 if (k == perIt->second.size())
1541 perIt->second.push_back(perIt2->second[j]);
1548 for (perIt = periodicEdges.begin();
1549 perIt != periodicEdges.end(); perIt++)
1553 = eIdMap.find(perIt->first);
1555 *vCoMap[eIt->second.first],
1556 *vCoMap[eIt->second.second]
1562 for (i = 0; i < perIt->second.size(); ++i)
1564 eIt = eIdMap.find(perIt->second[i].id);
1567 *vCoMap[eIt->second.first],
1568 *vCoMap[eIt->second.second]
1571 NekDouble cx = 0.5*(w[0](0)-v[0](0)+w[1](0)-v[1](0));
1572 NekDouble cy = 0.5*(w[0](1)-v[0](1)+w[1](1)-v[1](1));
1573 NekDouble cz = 0.5*(w[0](2)-v[0](2)+w[1](2)-v[1](2));
1575 int vMap[2] = {-1,-1};
1576 for (j = 0; j < 2; ++j)
1581 for (k = 0; k < 2; ++k)
1587 if (sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y)+(z1-z)*(z1-z))
1597 ASSERTL0(vMap[0] >= 0 && vMap[1] >= 0,
1598 "Unable to align periodic vertices.");
1599 ASSERTL0((vMap[0] == 0 || vMap[0] == 1) &&
1600 (vMap[1] == 0 || vMap[1] == 1) &&
1601 (vMap[0] != vMap[1]),
1602 "Unable to align periodic vertices.");
1615 for (perIt = periodicVerts.begin();
1616 perIt != periodicVerts.end(); ++perIt)
1618 if (locVerts.count(perIt->first) > 0)
1624 for (perIt = periodicEdges.begin();
1625 perIt != periodicEdges.end(); ++perIt)
1627 if (locEdges.count(perIt->first) > 0)
1639 as<LocalRegions::Expansion2D>();
1641 int offset =
m_trace->GetPhys_Offset(traceEl->GetElmtId());
1644 if (traceEl->GetLeftAdjacentElementFace () == -1 ||
1645 traceEl->GetRightAdjacentElementFace() == -1)
1655 int traceGeomId = traceEl->GetGeom2D()->GetGlobalID();
1661 fwd = traceGeomId == min(traceGeomId,pIt->second[0].id);
1666 GetTraceToUniversalMapUnique(offset) >= 0;
1670 else if (traceEl->GetLeftAdjacentElementFace () != -1 &&
1671 traceEl->GetRightAdjacentElementFace() != -1)
1675 (traceEl->GetLeftAdjacentElementExp().get()) ==
1680 ASSERTL2(
false,
"Unconnected trace element!");
1722 int n, cnt,
npts, e;
1734 GetNFwdLocTracePts();
1750 id2 =
m_trace->GetPhys_Offset(
1751 m_traceMap->GetBndCondTraceToGlobalTraceMap(cnt+e));
1768 id2 =
m_trace->GetPhys_Offset(
1769 m_traceMap->GetBndCondTraceToGlobalTraceMap(cnt+e));
1784 ASSERTL0(
false,
"Method only set up for Dirichlet, Neumann "
1785 "and Robin conditions.");
1809 "Field is not in physical space.");
1819 Vmath::Zero(outarray.num_elements(), outarray, 1);
1827 m_traceMap->UniversalTraceAssemble(outarray);
1855 m_trace->IProductWRTBase(Fn, Fcoeffs);
1890 m_trace->IProductWRTBase(Fwd,Coeffs);
1892 m_trace->IProductWRTBase(Bwd,Coeffs);
1906 map<int,int> globalIdMap;
1921 globalIdMap[exp3d->GetGeom3D()->GetGlobalID()] = i;
1940 as<LocalRegions::Expansion2D>();
1943 graph3D->GetElementsFromFace(exp2d->GetGeom2D());
1946 m_Element->GetGlobalID()];
1947 m_BCtoFaceMap[cnt] = (*tmp)[0]->m_FaceIndx;
1956 boost::shared_ptr<ExpList> &result,
1957 const bool DeclareCoeffPhysArrays)
1960 int offsetOld, offsetNew;
1961 std::vector<unsigned int> eIDs;
1967 for (cnt = n = 0; n < i; ++n)
1975 eIDs.push_back(ElmtID[cnt+n]);
1981 (*
this, eIDs, DeclareCoeffPhysArrays);
1984 if (DeclareCoeffPhysArrays)
1987 for (n = 0; n < result->GetExpSize(); ++n)
1989 nq =
GetExp(ElmtID[cnt+n])->GetTotPoints();
1991 offsetNew = result->GetPhys_Offset(n);
1993 tmp2 = result->UpdatePhys()+ offsetNew, 1);
1995 nq =
GetExp(ElmtID[cnt+n])->GetNcoeffs();
1997 offsetNew = result->GetCoeff_Offset(n);
1999 tmp2 = result->UpdateCoeffs()+ offsetNew, 1);
2028 const bool PhysSpaceForcing)
2030 int i,j,n,cnt,cnt1,nbndry;
2041 if(PhysSpaceForcing)
2054 int GloBndDofs =
m_traceMap->GetNumGlobalBndCoeffs();
2055 int NumDirichlet =
m_traceMap->GetNumLocalDirBndCoeffs();
2073 int LocBndCoeffs =
m_traceMap->GetNumLocalBndCoeffs();
2082 for(cnt = cnt1 = n = 0; n < nexp; ++n)
2088 e_l = loc_lambda + cnt1;
2095 Floc =
Transpose(*(HDGLamToU->GetBlock(n,n)))*ElmtFce;
2113 id =
m_traceMap->GetBndCondCoeffsToGlobalCoeffsMap(cnt++);
2122 id =
m_traceMap->GetBndCondCoeffsToGlobalCoeffsMap(cnt++);
2132 if(GloBndDofs - NumDirichlet > 0)
2149 m_traceMap->GlobalToLocalBnd(BndSol,loc_lambda);
2152 out = (*InvHDGHelm)*F + (*HDGLamToU)*LocLambda;
2169 int LocBndCoeffs =
m_traceMap->GetNumLocalBndCoeffs();
2174 m_traceMap->GlobalToLocalBnd(inarray, loc_lambda);
2175 LocLambda = (*HDGHelm) * LocLambda;
2176 m_traceMap->AssembleBnd(loc_lambda,outarray);
2195 map<int, RobinBCInfoSharedPtr> returnval;
2210 int npoints = locExpList->GetNpoints();
2216 locExpList->GetCoords(x0, x1, x2);
2219 boost::static_pointer_cast<
2224 coeffeqn.
Evaluate(x0, x1, x2, 0.0, coeffphys);
2226 for(e = 0; e < locExpList->GetExpSize(); ++e)
2231 Array_tmp = coeffphys +
2232 locExpList->GetPhys_Offset(e));
2234 elmtid = ElmtID[cnt+e];
2236 if(returnval.count(elmtid) != 0)
2238 rInfo->next = returnval.find(elmtid)->second;
2240 returnval[elmtid] = rInfo;
2272 int i,cnt,f,ncoeff_face;
2277 int eid,nq_elmt, nm_elmt;
2278 int LocBndCoeffs =
m_traceMap->GetNumLocalBndCoeffs();
2283 face_lambda = loc_lambda;
2292 nq_elmt = (*m_exp)[eid]->GetTotPoints();
2293 nm_elmt = (*m_exp)[eid]->GetNcoeffs();
2297 out_tmp = force + nm_elmt;
2300 int num_points0 = (*m_exp)[eid]->GetBasis(0)->GetNumPoints();
2301 int num_points1 = (*m_exp)[eid]->GetBasis(1)->GetNumPoints();
2302 int num_points2 = (*m_exp)[eid]->GetBasis(2)->GetNumPoints();
2303 int num_modes0 = (*m_exp)[eid]->GetBasis(0)->GetNumModes();
2304 int num_modes1 = (*m_exp)[eid]->GetBasis(1)->GetNumModes();
2305 int num_modes2 = (*m_exp)[eid]->GetBasis(2)->GetNumModes();
2310 int nFaces = (*m_exp)[eid]->GetNfaces();
2312 for(f = 0; f < nFaces; ++f)
2314 ncoeff_face = elmtToTrace[eid][f]->GetNcoeffs();
2316 Vmath::Vcopy(ncoeff_face, face_lambda, 1, faceCoeffs[f], 1);
2317 exp->SetFaceToGeomOrientation(f, faceCoeffs[f]);
2318 face_lambda = face_lambda + ncoeff_face;
2362 ASSERTL0(
false,
"Wrong shape type, HDG postprocessing is not implemented");
2368 (*m_exp)[eid]->DGDeriv(
2370 elmtToTrace[eid], faceCoeffs, out_tmp);
2371 (*m_exp)[eid]->BwdTrans(out_tmp,qrhs);
2372 ppExp->IProductWRTDerivBase(0,qrhs,force);
2376 (*m_exp)[eid]->DGDeriv(
2378 elmtToTrace[eid], faceCoeffs, out_tmp);
2379 (*m_exp)[eid]->BwdTrans(out_tmp,qrhs);
2380 ppExp->IProductWRTDerivBase(1,qrhs,out_tmp);
2385 (*m_exp)[eid]->DGDeriv(
2387 elmtToTrace[eid], faceCoeffs, out_tmp);
2388 (*m_exp)[eid]->BwdTrans(out_tmp,qrhs);
2389 ppExp->IProductWRTDerivBase(2,qrhs,out_tmp);
2393 (*m_exp)[eid]->BwdTrans(
2395 force[0] = (*m_exp)[eid]->Integral(qrhs);
2409 ppExp->BwdTrans(out.
GetPtr(), work);
2410 (*m_exp)[eid]->FwdTrans(work,
2449 const std::string varName,
2458 for (i = 0; i < nbnd; ++i)
2463 npoints = locExpList->GetNpoints();
2470 locExpList->GetCoords(x0, x1, x2);
2479 string exprbcs = bcPtr->m_expr;
2484 valuesFile = locExpList->GetPhys();
2493 condition.
Evaluate(x0, x1, x2, time, valuesExp);
2496 Vmath::Vmul(npoints, valuesExp, 1, valuesFile, 1, locExpList->UpdatePhys(), 1);
2498 locExpList->FwdTrans_BndConstrained(
2499 locExpList->GetPhys(),
2500 locExpList->UpdateCoeffs());
2522 condition.
Evaluate(x0, x1, x2, time,
2523 locExpList->UpdatePhys());
2525 locExpList->IProductWRTBase(locExpList->GetPhys(),
2526 locExpList->UpdateCoeffs());
2548 condition.
Evaluate(x0, x1, x2, time,
2549 locExpList->UpdatePhys());
2553 locExpList->IProductWRTBase(locExpList->GetPhys(),
2554 locExpList->UpdateCoeffs());
2559 ASSERTL0(
false,
"This type of BC not implemented yet");
GlobalSysSolnType GetGlobalSysSolnType() const
Return the associated solution type.
const DNekScalBlkMatSharedPtr & GetBlockMatrix(const GlobalMatrixKey &gkey)
boost::shared_ptr< MeshGraph3D > MeshGraph3DSharedPtr
const Array< OneD, const NekDouble > & GetCoeffs() const
This function returns (a reference to) the array (implemented as m_coeffs) containing all local expa...
#define ASSERTL0(condition, msg)
virtual void v_Reset()
Reset geometry information, metrics, matrix managers and geometry information.
virtual ~DisContField3D()
Destructor.
GlobalLinSysSharedPtr GetGlobalBndLinSys(const GlobalLinSysKey &mkey)
boost::shared_ptr< ElementFaceVector > ElementFaceVectorSharedPtr
virtual void v_ExtractTracePhys(Array< OneD, NekDouble > &outarray)
void ExtractFileBCs(const std::string &fileName, LibUtilities::CommSharedPtr comm, const std::string &varName, const boost::shared_ptr< ExpList > locExpList)
Array< OneD, MultiRegions::ExpListSharedPtr > m_bndCondExpansions
An object which contains the discretised boundary conditions.
int GetCoeff_Offset(int n) const
Get the start offset position for a global list of m_coeffs correspoinding to element n...
static ExpListSharedPtr NullExpListSharedPtr
void EvaluateBoundaryConditions(const NekDouble time=0.0, const std::string varName="", const NekDouble=NekConstants::kNekUnsetDouble, const NekDouble=NekConstants::kNekUnsetDouble)
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
std::vector< PointGeomSharedPtr > PointGeomVector
void SetAdjacentElementExp(int face, Expansion3DSharedPtr &f)
bool isLocal
Flag specifying if this entity is local to this partition.
int GetPhys_Offset(int n) const
Get the start offset position for a global list of m_phys correspoinding to element n...
bool IsLeftAdjacentFace(const int n, const int e)
const BoundaryConditionCollection & GetBoundaryConditions(void) const
GlobalLinSysMapShPtr m_globalBndMat
boost::shared_ptr< RobinBCInfo > RobinBCInfoSharedPtr
SpatialDomains::Geometry3DSharedPtr GetGeom3D() const
virtual void v_GetBndElmtExpansion(int i, boost::shared_ptr< ExpList > &result, const bool DeclareCoeffPhysArrays)
const boost::shared_ptr< LocalRegions::ExpansionVector > GetExp() const
This function returns the vector of elements in the expansion.
std::vector< bool > m_leftAdjacentFaces
std::set< int > m_boundaryFaces
A set storing the global IDs of any boundary faces.
PeriodicMap m_periodicFaces
A map which identifies pairs of periodic faces.
virtual void v_GetFwdBwdTracePhys(Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd)
This method extracts the "forward" and "backward" trace data from the array field and puts the data i...
std::map< int, std::vector< unsigned int > > BndRegionOrdering
std::map< ConstFactorType, NekDouble > ConstFactorMap
void GetBoundaryToElmtMap(Array< OneD, int > &ElmtID, Array< OneD, int > &EdgeID)
Array< OneD, NekDouble > m_phys
The global expansion evaluated at the quadrature points.
void EvaluateHDGPostProcessing(Array< OneD, NekDouble > &outarray)
Evaluate HDG post-processing to increase polynomial order of solution.
std::map< int, std::vector< unsigned int > > CompositeOrdering
virtual void v_AddFwdBwdTraceIntegral(const Array< OneD, const NekDouble > &Fwd, const Array< OneD, const NekDouble > &Bwd, Array< OneD, NekDouble > &outarray)
Add trace contributions into elemental coefficient spaces.
void ApplyGeomInfo()
Apply geometry information to each expansion.
boost::shared_ptr< NeumannBoundaryCondition > NeumannBCShPtr
boost::shared_ptr< HexGeom > HexGeomSharedPtr
Array< OneD, NekDouble > m_coeffs
Concatenation of all local expansion coefficients.
int GetExpSize(void)
This function returns the number of elements in the expansion.
virtual void v_EvaluateBoundaryConditions(const NekDouble time=0.0, const std::string varName="", const NekDouble x2_in=NekConstants::kNekUnsetDouble, const NekDouble x3_in=NekConstants::kNekUnsetDouble)
This function evaluates the boundary conditions at a certain time-level.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
boost::shared_ptr< GlobalLinSys > GenGlobalBndLinSys(const GlobalLinSysKey &mkey, const AssemblyMapSharedPtr &locToGloMap)
Generate a GlobalLinSys from information provided by the key "mkey" and the mapping provided in LocTo...
boost::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
Gauss Radau pinned at x=-1, .
Principle Orthogonal Functions .
void FindPeriodicFaces(const SpatialDomains::BoundaryConditions &bcs, const std::string &variable)
Determine the periodic faces, edges and vertices for the given graph.
boost::shared_ptr< DirichletBoundaryCondition > DirichletBCShPtr
Array< OneD, int > m_coeff_offset
Offset of elemental data into the array m_coeffs.
virtual std::map< int, RobinBCInfoSharedPtr > v_GetRobinBCInfo()
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
static StdRegions::Orientation GetFaceOrientation(const QuadGeom &face1, const QuadGeom &face2)
Get the orientation of face1.
The base class for all shapes.
std::vector< int > m_periodicFwdCopy
A vector indicating degress of freedom which need to be copied from forwards to backwards space in ca...
std::vector< int > m_periodicBwdCopy
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
boost::shared_ptr< LocalRegions::ExpansionVector > m_exp
The list of local expansions.
DisContField3D()
Default constructor.
virtual const std::vector< bool > & v_GetLeftAdjacentFaces(void) const
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
boost::shared_ptr< Expansion3D > Expansion3DSharedPtr
LocTraceToTraceMapSharedPtr m_locTraceToTraceMap
Map of local trace (the points at the face of the element) to the trace space discretisation.
int id
Geometry ID of entity.
bool m_physState
The state of the array m_phys.
NekDouble Evaluate() const
int m_ncoeffs
The total number of local degrees of freedom. m_ncoeffs .
Array< OneD, int > m_offset_elmt_id
Array containing the element id m_offset_elmt_id[n] that the n^th consecutive block of data in m_coef...
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection
boost::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
boost::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
Principle Orthogonal Functions .
Principle Orthogonal Functions .
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)
SpatialDomains::MeshGraphSharedPtr m_graph
Mesh associated with this expansion list.
void GenerateBoundaryConditionExpansion(const SpatialDomains::MeshGraphSharedPtr &graph3D, const SpatialDomains::BoundaryConditions &bcs, const std::string &variable)
virtual void v_GeneralMatrixOp(const GlobalMatrixKey &gkey, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal)
Calculates the result of the multiplication of a global matrix of type specified by mkey with a vecto...
LibUtilities::SessionReaderSharedPtr m_session
Session.
Defines a specification for a set of points.
void Neg(int n, T *x, const int incx)
Negate x = -x.
void SetUpDG(const std::string="DefaultVar")
Set up all DG member variables and maps.
boost::shared_ptr< Expansion > ExpansionSharedPtr
bool SameTypeOfBoundaryConditions(const DisContField3D &In)
std::map< int, BoundaryConditionMapShPtr > BoundaryConditionCollection
boost::shared_ptr< ExpList2D > ExpList2DSharedPtr
Shared pointer to an ExpList2D object.
boost::shared_ptr< GeometryVector > Composite
std::map< int, std::vector< PeriodicEntity > > PeriodicMap
Describe a linear system.
std::map< int, Composite > CompositeMap
StdRegions::Orientation orient
Orientation of entity within higher dimensional entity.
StdRegions::MatrixType GetMatrixType() const
Return the matrix type.
Describes a matrix with ordering defined by a local to global map.
const Array< OneD, const NekDouble > & GetPhys() const
This function returns (a reference to) the array (implemented as m_phys) containing the function ev...
boost::shared_ptr< Geometry2D > Geometry2DSharedPtr
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
LibUtilities::CommSharedPtr m_comm
Communicator.
static AssemblyMapSharedPtr NullAssemblyMapSharedPtr
PeriodicMap m_periodicVerts
A map which identifies groups of periodic vertices.
virtual void v_GetBoundaryToElmtMap(Array< OneD, int > &ElmtID, Array< OneD, int > &FaceID)
Set up a list of elemeent IDs and edge IDs that link to the boundary conditions.
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed t...
virtual void v_Reset()
Reset this field, so that geometry information can be updated.
void IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal)
boost::shared_ptr< PrismGeom > PrismGeomSharedPtr
Gauss Radau pinned at x=-1, .
Array< OneD, SpatialDomains::BoundaryConditionShPtr > m_bndConditions
An array which contains the information about the boundary condition on the different boundary region...
int GetNcoeffs(void) const
Returns the total number of local degrees of freedom .
AssemblyMapDGSharedPtr m_traceMap
boost::shared_ptr< TetGeom > TetGeomSharedPtr
Abstraction of a three-dimensional multi-elemental expansion which is merely a collection of local ex...
static SpatialDomains::BoundaryConditionShPtr GetBoundaryCondition(const SpatialDomains::BoundaryConditionCollection &collection, unsigned int index, const std::string &variable)
boost::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
static StdRegions::Orientation GetFaceOrientation(const TriGeom &face1, const TriGeom &face2)
Array< OneD, int > m_BCtoElmMap
virtual void v_HelmSolve(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const FlagList &flags, const StdRegions::ConstFactorMap &factors, const StdRegions::VarCoeffMap &varcoeff, const Array< OneD, const NekDouble > &dirForcing, const bool PhysSpaceForcing)
const BoundaryRegionCollection & GetBoundaryRegions(void) const
Array< OneD, int > m_BCtoFaceMap
boost::shared_ptr< BoundaryConditionBase > BoundaryConditionShPtr
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.
boost::shared_ptr< StdExpansion > StdExpansionSharedPtr
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Describes the specification for a Basis.
Array< OneD, DataType > & GetPtr()
boost::shared_ptr< RobinBoundaryCondition > RobinBCShPtr
1D Gauss-Lobatto-Legendre quadrature points
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
virtual void v_AddTraceIntegral(const Array< OneD, const NekDouble > &Fn, Array< OneD, NekDouble > &outarray)
Add trace contributions into elemental coefficient spaces.
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
PeriodicMap m_periodicEdges
A map which identifies groups of periodic edges.
boost::shared_ptr< Expansion2D > Expansion2DSharedPtr