35 #include <boost/core/ignore_unused.hpp>
48 namespace LocalRegions
52 void Expansion3D::AddHDGHelmholtzFaceTerms(
61 int nquad_f = FaceExp->GetNumPoints(0)*FaceExp->GetNumPoints(1);
62 int order_f = FaceExp->GetNcoeffs();
63 int coordim = GetCoordim();
64 int ncoeffs = GetNcoeffs();
73 = GetTraceNormal(face);
81 GetBasisNumModes(0), GetBasisNumModes(1), GetBasisNumModes(2),
82 face, GetTraceOrient(face));
97 if ((x = varcoeffs.find(VarCoeff[0])) != varcoeffs.end())
99 GetPhysFaceVarCoeffsFromElement(face,FaceExp,x->second,varcoeff_work);
100 Vmath::Vmul(nquad_f,varcoeff_work,1,FaceExp->GetPhys(),1,FaceExp->UpdatePhys(),1);
107 FaceExp->IProductWRTBase(facePhys, outcoeff);
109 for(i = 0; i < order_f; ++i)
111 outarray[(*map)[i].index] += (*map)[i].sign*tau*outcoeff[i];
121 for(n = 0; n < coordim; ++n)
128 DetShapeType(), *
this,
132 invMass = *GetLocMatrix(invMasskey);
135 v_GetnFacecdotMF(n, face, FaceExp, normals, varcoeffs);
137 Vmath::Vmul(nquad_f, ncdotMF_f, 1, facePhys, 1, inval, 1);
140 Vmath::Vmul(nquad_f, normals[n], 1, facePhys, 1, inval, 1);
144 const NekDouble *data = invMass.GetRawPtr();
157 FaceExp->IProductWRTBase(inval, outcoeff);
160 for(i = 0; i < ncoeffs; ++i)
163 for(j = 0; j < order_f; ++j)
165 tmpcoeff[i] += scale*data[i+(*map)[j].index*ncoeffs]*(*map)[j].sign*outcoeff[j];
173 = v_GetMF(n,coordim,varcoeffs);
175 = v_GetMFDiv(n,varcoeffs);
178 DetShapeType(), *
this,
184 Coeffs = Coeffs + Dmat*Tmpcoeff;
189 Coeffs = Coeffs + Dmat*Tmpcoeff;
210 void Expansion3D::GetPhysFaceVarCoeffsFromElement(
220 FwdTrans(varcoeff, tmp);
226 GetTraceToElementMap(face, emap,
sign, GetTraceOrient(face));
228 for (
unsigned int i = 0; i < FaceExp->GetNcoeffs(); ++i)
230 facetmp[i] = tmp[emap[i]];
234 FaceExp->BwdTrans(facetmp, outarray);
242 void Expansion3D::AddNormTraceInt(
251 int nfaces = GetNtraces();
254 for(f = 0; f < nfaces; ++f)
256 order_f = FaceExp[f]->GetNcoeffs();
257 nquad_f = FaceExp[f]->GetNumPoints(0)*FaceExp[f]->GetNumPoints(1);
263 for(i = 0; i < order_f; ++i)
265 faceCoeffs[i] = inarray[i+cnt];
269 FaceExp[f]->BwdTrans(faceCoeffs, facePhys);
284 StdRegions::VarCoeffMap::const_iterator x;
289 v_GetnFacecdotMF(dir, f, FaceExp[f], normals,
303 AddFaceBoundaryInt(f, FaceExp[f], facePhys, outarray,
309 void Expansion3D::AddNormTraceInt(
316 int order_f, nquad_f;
317 int nfaces = GetNtraces();
320 for(f = 0; f < nfaces; ++f)
322 order_f = FaceExp[f]->GetNcoeffs();
323 nquad_f = FaceExp[f]->GetNumPoints(0)*FaceExp[f]->GetNumPoints(1);
331 FaceExp[f]->BwdTrans(faceCoeffs[f], facePhys);
333 Vmath::Vmul(nquad_f, normals[dir], 1, facePhys, 1, facePhys, 1);
335 AddFaceBoundaryInt(f, FaceExp[f], facePhys, outarray);
342 void Expansion3D::AddFaceBoundaryInt(
349 boost::ignore_unused(varcoeffs);
352 int order_f = FaceExp->GetNcoeffs();
356 GetBasisNumModes(0), GetBasisNumModes(1), GetBasisNumModes(2),
357 face, GetTraceOrient(face));
373 FaceExp->IProductWRTBase(facePhys, coeff);
376 for(i = 0; i < order_f; ++i)
378 outarray[(*map)[i].index] += (*map)[i].sign*coeff[i];
385 void Expansion3D::SetFaceToGeomOrientation(
389 int nface = GetTraceNcoeffs(face);
396 GetBasisNumModes(0), GetBasisNumModes(1), GetBasisNumModes(2),
400 GetBasisNumModes(0), GetBasisNumModes(1), GetBasisNumModes(2),
401 face, GetTraceOrient(face));
404 ASSERTL1((*map1).size() == (*map2).size(),
405 "There is an error with the GetTraceToElementMap");
407 for(j = 0; j < (*map1).size(); ++j)
410 for(k = 0; k < (*map2).size(); ++k)
413 if((*map1)[j].index == (*map2)[k].index && k != j)
417 if((*map1)[j].
sign != (*map2)[k].
sign)
431 int nfaces = GetNtraces();
435 for(i = 0; i < nfaces; ++i)
437 SetFaceToGeomOrientation(i, f_tmp = inout + cnt);
438 cnt += GetTraceNcoeffs(i);
455 "Matrix construction is not implemented for variable "
456 "coefficients at the moment");
466 ASSERTL1(IsBoundaryInteriorExpansion(),
467 "HybridDGHelmholtz matrix not set up "
468 "for non boundary-interior expansions");
473 int ncoeffs = GetNcoeffs();
474 int nfaces = GetNtraces();
481 int order_f, coordim = GetCoordim();
494 StdRegions::VarCoeffMap::const_iterator x;
498 for(i = 0; i < coordim; ++i)
505 v_GetMF(i,coordim,varcoeffs);
507 v_GetMFDiv(i,varcoeffs);
510 DetShapeType(), *
this,
521 DetShapeType(), *
this,
527 Mat = Mat + Dmat*invMass*
Transpose(Dmat);
532 Mat = Mat + Dmat*invMass*
Transpose(Dmat);
557 Mat = Mat + lambdaval*Mass;
560 for(i = 0; i < nfaces; ++i)
562 FaceExp = GetTraceExp(i);
563 order_f = FaceExp->GetNcoeffs();
566 GetBasisNumModes(0), GetBasisNumModes(1),
567 GetBasisNumModes(2), i, GetTraceOrient(i));
588 for(j = 0; j < order_f; ++j)
590 for(k = 0; k < order_f; ++k)
592 Mat((*map)[j].index,(*map)[k].index) +=
593 tau*(*map)[j].sign*(*map)[k].sign*
eMass(j,k);
604 int nbndry = NumDGBndryCoeffs();
605 int ncoeffs = GetNcoeffs();
606 int nfaces = GetNtraces();
630 for(i = 0; i < nfaces; ++i)
632 FaceExp = GetTraceExp(i);
633 int nface = GetTraceNcoeffs(i);
639 for(j = 0; j < nface; ++j)
643 face_lambda[j] = 1.0;
645 SetFaceToGeomOrientation(i, face_lambda);
648 FaceExp->BwdTrans(face_lambda, tmp);
649 AddHDGHelmholtzFaceTerms(tau, i, tmp, mkey.
GetVarCoeffs(), f);
654 for(k = 0; k < ncoeffs; ++k)
656 Umat(k,bndry_cnt) = Ulam[k];
710 int nbndry = NumDGBndryCoeffs();
711 int coordim = GetCoordim();
712 int ncoeffs = GetNcoeffs();
713 int nfaces = GetNtraces();
735 for(i = 0; i < nfaces; ++i)
737 FaceExp[i] = GetTraceExp(i);
757 ASSERTL0(
false,
"Direction not known");
763 StdRegions::VarCoeffMap::const_iterator x;
771 v_GetMF(dir,coordim,varcoeffs);
773 v_GetMFDiv(dir,varcoeffs);
776 DetShapeType(), *
this,
780 Dmat = GetLocMatrix(Dmatkey);
787 DetShapeType(), *
this,
791 invMass = *GetLocMatrix(invMasskey);
802 for(j = 0; j < nbndry; ++j)
808 for(k = 0; k < ncoeffs; ++k)
810 Ulam[k] = lamToU(k,j);
817 SetTraceToGeomOrientation(lambda);
821 AddNormTraceInt(dir,lambda,FaceExp,f,mkey.
GetVarCoeffs());
827 Vmath::Vcopy(ncoeffs,&ulam[0],1,&(Qmat.GetPtr())[0]+j*ncoeffs,1);
835 int order_f, nquad_f;
836 int nbndry = NumDGBndryCoeffs();
837 int nfaces = GetNtraces();
860 LamToQ[0] = GetLocMatrix(LamToQ0key);
864 LamToQ[1] = GetLocMatrix(LamToQ1key);
868 LamToQ[2] = GetLocMatrix(LamToQ2key);
872 for(i = 0; i < nfaces; ++i)
874 FaceExp[i] = GetTraceExp(i);
878 for(i = 0; i < nbndry; ++i)
884 SetTraceToGeomOrientation(lam);
886 for(f = 0; f < nfaces; ++f)
888 order_f = FaceExp[f]->GetNcoeffs();
889 nquad_f = FaceExp[f]->GetNumPoints(0)*FaceExp[f]->GetNumPoints(1);
890 normals = GetTraceNormal(f);
896 GetBasisNumModes(0), GetBasisNumModes(1),
897 GetBasisNumModes(2), f, GetTraceOrient(f));
912 for(j = 0; j < order_f; ++j)
914 faceCoeffs[j] = (*map)[j].sign*(*LamToQ[0])((*map)[j].index,i);
917 FaceExp[f]->BwdTrans(faceCoeffs, facePhys);
933 v_GetnFacecdotMF(0, f, FaceExp[f],
948 for(j = 0; j < order_f; ++j)
950 faceCoeffs[j] = (*map)[j].sign*(*LamToQ[1])((*map)[j].index,i);
953 FaceExp[f]->BwdTrans(faceCoeffs, facePhys);
969 v_GetnFacecdotMF(1, f, FaceExp[f],
986 for(j = 0; j < order_f; ++j)
988 faceCoeffs[j] = (*map)[j].sign*(*LamToQ[2])((*map)[j].index,i);
991 FaceExp[f]->BwdTrans(faceCoeffs, facePhys);
1007 v_GetnFacecdotMF(2, f, FaceExp[f],
1008 normals, varcoeffs);
1025 for(j = 0; j < order_f; ++j)
1027 faceCoeffs[j] = (*map)[j].sign*LamToU((*map)[j].index,i) - lam[cnt+j];
1030 FaceExp[f]->BwdTrans(faceCoeffs, facePhys);
1046 FaceExp[f]->IProductWRTBase(work, faceCoeffs);
1048 SetFaceToGeomOrientation(f, faceCoeffs);
1050 for(j = 0; j < order_f; ++j)
1052 BndMat(cnt+j,i) = faceCoeffs[j];
1072 int nq = GetTotPoints();
1076 IProductWRTBase(tmp, outarray);
1079 &(lmat->GetPtr())[0],1);
1085 ASSERTL0(
false,
"This matrix type cannot be generated from this class");
1092 void Expansion3D::v_AddFaceNormBoundaryInt(
1109 if (m_requireNeg.size() == 0)
1111 m_requireNeg.resize(GetNtraces());
1113 for (i = 0; i < GetNtraces(); ++i)
1115 m_requireNeg[i] =
false;
1119 if (faceExp->GetRightAdjacentElementExp())
1121 if (faceExp->GetRightAdjacentElementExp()->GetGeom()
1122 ->GetGlobalID() == GetGeom()->GetGlobalID())
1124 m_requireNeg[i] =
true;
1131 GetBasisNumModes(0), GetBasisNumModes(1), GetBasisNumModes(2),
1132 face, GetTraceOrient(face));
1135 int order_e = (*map).size();
1136 int n_coeffs = FaceExp->GetNcoeffs();
1140 if (n_coeffs != order_e)
1145 FaceExp->FwdTrans(Fn, faceCoeffs);
1147 int NumModesElementMax = FaceExp->GetBasis(0)->GetNumModes();
1148 int NumModesElementMin = m_base[0]->GetNumModes();
1150 FaceExp->ReduceOrderCoeffs(NumModesElementMin,
1155 FaceExp->DetShapeType(),
1157 FaceExp->MassMatrixOp(faceCoeffs, faceCoeffs, masskey);
1160 int offset1 = 0, offset2 = 0;
1164 for (i = 0; i < NumModesElementMin; ++i)
1166 for (j = 0; j < NumModesElementMin; ++j)
1168 faceCoeffs[offset1+j] =
1169 faceCoeffs[offset2+j];
1171 offset1 += NumModesElementMin;
1172 offset2 += NumModesElementMax;
1176 for (i = NumModesElementMin; i < NumModesElementMax; ++i)
1178 for (j = NumModesElementMin; j < NumModesElementMax; ++j)
1180 faceCoeffs[i*NumModesElementMax+j] = 0.0;
1189 int offset1 = 0, offset2 = 0;
1191 for (i = 0; i < NumModesElementMin; ++i)
1193 for (j = 0; j < NumModesElementMin-i; ++j)
1195 faceCoeffs[offset1+j] =
1196 faceCoeffs[offset2+j];
1198 offset1 += NumModesElementMin-i;
1199 offset2 += NumModesElementMax-i;
1206 FaceExp->IProductWRTBase(Fn, faceCoeffs);
1209 if (m_requireNeg[face])
1211 for (i = 0; i < order_e; ++i)
1213 outarray[(*map)[i].index] -= (*map)[i].sign * faceCoeffs[i];
1218 for (i = 0; i < order_e; ++i)
1220 outarray[(*map)[i].index] += (*map)[i].sign * faceCoeffs[i];
1231 void Expansion3D::v_DGDeriv(
1238 int ncoeffs = GetNcoeffs();
1244 DNekScalMat &Dmat = *GetLocMatrix(DerivType[dir]);
1254 AddNormTraceInt(dir, FaceExp, faceCoeffs, coeffs);
1258 Out_d = InvMass*Coeffs;
1261 void Expansion3D::v_AddRobinMassMatrix(
1266 ASSERTL1(IsBoundaryInteriorExpansion(),
1267 "Not set up for non boundary-interior expansions");
1268 ASSERTL1(inoutmat->GetRows() == inoutmat->GetColumns(),
1269 "Assuming that input matrix was square");
1274 int order_f = faceExp->GetNcoeffs();
1283 faceExp->DetShapeType();
1291 DNekScalMat &facemat = *faceExp->GetLocMatrix(mkey);
1308 int rows = inoutmat->GetRows();
1310 if (rows == GetNcoeffs())
1312 GetTraceToElementMap(face,map,
sign,GetTraceOrient(face));
1314 else if (rows == GetNverts())
1316 int nfvert = faceExp->GetNverts();
1323 GetLinStdExp()->GetTraceToElementMap(face,linmap,linsign,
1324 GetTraceOrient(face));
1332 for(i = 0; i < nfvert; ++i)
1334 fmap = faceExp->GetVertexMap(i,
true);
1338 map[fmap] = linmap[i];
1341 else if(rows == NumBndryCoeffs())
1343 int nbndry = NumBndryCoeffs();
1346 GetTraceToElementMap(face,map,
sign,GetTraceOrient(face));
1347 GetBoundaryMap(bmap);
1349 for(i = 0; i < order_f; ++i)
1351 for(j = 0; j < nbndry; ++j)
1353 if(map[i] == bmap[j])
1359 ASSERTL1(j != nbndry,
"Did not find number in map");
1362 else if (rows == NumDGBndryCoeffs())
1370 GetBasisNumModes(0), GetBasisNumModes(1),
1371 GetBasisNumModes(2), face, GetTraceOrient(face));
1374 GetBasisNumModes(0), GetBasisNumModes(1),
1375 GetBasisNumModes(2), face,
1379 ASSERTL1((*map1).size() == (*map2).size(),
1380 "There is an error with the GetTraceToElementMap");
1382 for (i = 0; i < face; ++i)
1384 cnt += GetTraceNcoeffs(i);
1387 for(i = 0; i < (*map1).size(); ++i)
1391 for(j = 0; j < (*map2).size(); ++j)
1393 if((*map1)[i].index == (*map2)[j].index)
1400 ASSERTL2(idx >= 0,
"Index not found");
1401 map [i] = idx + cnt;
1402 sign[i] = (*map2)[idx].sign;
1407 ASSERTL0(
false,
"Could not identify matrix type from dimension");
1410 for(i = 0; i < order_f; ++i)
1413 for(j = 0; j < order_f; ++j)
1416 (*inoutmat)(id1,id2) += facemat(i,j)*
sign[i]*
sign[j];
1427 int nVerts, vid1, vid2, vMap1, vMap2;
1430 nVerts = GetNverts();
1434 nVerts, nVerts, 0.0, storage);
1435 DNekMat &VertexMat = (*vertexmatrix);
1437 for (vid1 = 0; vid1 < nVerts; ++vid1)
1439 vMap1 = GetVertexMap(vid1,
true);
1441 for (vid2 = 0; vid2 < nVerts; ++vid2)
1443 vMap2 = GetVertexMap(vid2,
true);
1444 VertexValue = (*r_bnd)(vMap1, vMap2);
1445 VertexMat.SetValue(vid1, vid2, VertexValue);
1449 return vertexmatrix;
1457 int eid, fid, vid, n, i;
1459 int nBndCoeffs = NumBndryCoeffs();
1464 nVerts = GetNverts();
1465 nEdges = GetNedges();
1490 int nConnectedEdges = 3;
1491 int nConnectedFaces = 3;
1495 MatEdgeLocation(nConnectedEdges);
1497 MatFaceLocation(nConnectedFaces);
1503 transformationmatrix =
1505 nBndCoeffs, nBndCoeffs, 0.0, storage);
1507 DNekMat &R = (*transformationmatrix);
1513 for (vid = 0; vid < nVerts; ++vid)
1517 GetEdgeNcoeffs (geom->GetVertexEdgeMap(vid, 0)) +
1518 GetEdgeNcoeffs (geom->GetVertexEdgeMap(vid, 1)) +
1519 GetEdgeNcoeffs (geom->GetVertexEdgeMap(vid, 2)) +
1520 GetTraceIntNcoeffs(geom->GetVertexFaceMap(vid, 0)) +
1521 GetTraceIntNcoeffs(geom->GetVertexFaceMap(vid, 1)) +
1522 GetTraceIntNcoeffs(geom->GetVertexFaceMap(vid, 2)) - 6;
1524 int nedgemodesconnected =
1525 GetEdgeNcoeffs (geom->GetVertexEdgeMap(vid, 0)) +
1526 GetEdgeNcoeffs (geom->GetVertexEdgeMap(vid, 1)) +
1527 GetEdgeNcoeffs (geom->GetVertexEdgeMap(vid, 2)) - 6;
1530 int nfacemodesconnected =
1531 GetTraceIntNcoeffs(geom->GetVertexFaceMap(vid, 0)) +
1532 GetTraceIntNcoeffs(geom->GetVertexFaceMap(vid, 1)) +
1533 GetTraceIntNcoeffs(geom->GetVertexFaceMap(vid, 2));
1539 for (eid = 0; eid < nConnectedEdges; ++eid)
1541 MatEdgeLocation[eid] = GetEdgeInverseBoundaryMap(
1542 geom->GetVertexEdgeMap(vid, eid));
1543 nmodes = MatEdgeLocation[eid].size();
1548 1, &edgemodearray[offset], 1);
1557 for (fid = 0; fid < nConnectedFaces; ++fid)
1559 MatFaceLocation[fid] = GetTraceInverseBoundaryMap(
1560 geom->GetVertexFaceMap(vid, fid));
1561 nmodes = MatFaceLocation[fid].size();
1566 1, &facemodearray[offset], 1);
1573 1, efRow, 0.0, storage);
1574 DNekMat &Sveft = (*vertexedgefacetransformmatrix);
1578 1, efRow, 0.0, storage);
1579 DNekMat &Svef = (*vertexedgefacecoupling);
1582 for (n = 0; n < nedgemodesconnected; ++n)
1585 VertexEdgeFaceValue = (*r_bnd)(GetVertexMap(vid),
1589 Svef.SetValue(0, n, VertexEdgeFaceValue);
1593 for (n = 0; n < nfacemodesconnected; ++n)
1596 VertexEdgeFaceValue = (*r_bnd)(GetVertexMap(vid),
1600 Svef.SetValue(0, n + nedgemodesconnected,
1601 VertexEdgeFaceValue);
1614 efRow, efRow, 0.0, storage);
1615 DNekMat &Sefef = (*edgefacecoupling);
1620 for (m = 0; m < nedgemodesconnected; ++m)
1622 for (n = 0; n < nedgemodesconnected; ++n)
1625 EdgeEdgeValue = (*r_bnd)(edgemodearray[n],
1629 Sefef.SetValue(n, m, EdgeEdgeValue);
1634 for (n = 0; n < nfacemodesconnected; ++n)
1636 for (m = 0; m < nfacemodesconnected; ++m)
1639 FaceFaceValue = (*r_bnd)(facemodearray[n],
1642 Sefef.SetValue(nedgemodesconnected + n,
1643 nedgemodesconnected + m, FaceFaceValue);
1648 for (n = 0; n < nedgemodesconnected; ++n)
1650 for (m = 0; m < nfacemodesconnected; ++m)
1653 FaceFaceValue = (*r_bnd)(edgemodearray[n],
1658 nedgemodesconnected + m,
1661 FaceFaceValue = (*r_bnd)(facemodearray[m],
1665 Sefef.SetValue(nedgemodesconnected + m,
1678 Sveft = -Svef * Sefef;
1682 for (n = 0; n < edgemodearray.size(); ++n)
1684 R.SetValue(GetVertexMap(vid), edgemodearray[n],
1689 for (n = 0; n < facemodearray.size(); ++n)
1691 R.SetValue(GetVertexMap(vid), facemodearray[n],
1692 Sveft(0, n + nedgemodesconnected));
1715 int efCol, efRow, nedgemodes;
1718 nConnectedFaces = 2;
1729 for (eid = 0; eid < nEdges; ++eid)
1732 efCol = GetTraceIntNcoeffs(geom->GetEdgeFaceMap(eid, 0)) +
1733 GetTraceIntNcoeffs(geom->GetEdgeFaceMap(eid, 1));
1734 efRow = GetEdgeNcoeffs(eid) - 2;
1739 efRow, efCol, 0.0, storage);
1740 DNekMat &Mef = (*efedgefacecoupling);
1745 efCol, efCol, 0.0, storage);
1746 DNekMat &Meff = (*effacefacecoupling);
1751 efRow, efCol, 0.0, storage);
1752 DNekMat &Meft = (*edgefacetransformmatrix);
1754 int nfacemodesconnected =
1755 GetTraceIntNcoeffs(geom->GetEdgeFaceMap(eid, 0)) +
1756 GetTraceIntNcoeffs(geom->GetEdgeFaceMap(eid, 1));
1758 facemodearray(nfacemodesconnected);
1762 = GetEdgeInverseBoundaryMap(eid);
1763 nedgemodes = GetEdgeNcoeffs(eid) - 2;
1769 1, &edgemodearray[0], 1);
1775 for (fid = 0; fid < nConnectedFaces; ++fid)
1777 MatFaceLocation[fid] = GetTraceInverseBoundaryMap(
1778 geom->GetEdgeFaceMap(eid, fid));
1779 nmodes = MatFaceLocation[fid].size();
1784 1, &facemodearray[offset], 1);
1790 for (n = 0; n < nedgemodes; ++n)
1792 for (m = 0; m < nfacemodesconnected; ++m)
1795 EdgeFaceValue = (*r_bnd)(edgemodearray[n],
1799 Mef.SetValue(n, m, EdgeFaceValue);
1804 for (n = 0; n < nfacemodesconnected; ++n)
1806 for (m = 0; m < nfacemodesconnected; ++m)
1809 FaceFaceValue = (*r_bnd)(facemodearray[n],
1813 Meff.SetValue(n, m, FaceFaceValue);
1827 for (n = 0; n < Meft.GetRows(); ++n)
1829 for (m = 0; m < Meft.GetColumns(); ++m)
1831 R.SetValue(edgemodearray[n], facemodearray[m],
1837 for (i = 0; i < R.GetRows(); ++i)
1839 R.SetValue(i, i, 1.0);
1845 return transformationmatrix;
1849 NEKERROR(ErrorUtil::efatal,
"unkown matrix type" );
1866 int i, j, n, eid = 0, fid = 0;
1867 int nCoeffs = NumBndryCoeffs();
1877 nCoeffs, nCoeffs, 0.0, storage);
1878 DNekMat &InvR = (*inversetransformationmatrix);
1880 int nVerts = GetNverts();
1881 int nEdges = GetNedges();
1882 int nFaces = GetNtraces();
1886 int nedgemodestotal = 0;
1887 int nfacemodestotal = 0;
1889 for (eid = 0; eid < nEdges; ++eid)
1891 nedgemodes = GetEdgeNcoeffs(eid) - 2;
1892 nedgemodestotal += nedgemodes;
1895 for (fid = 0; fid < nFaces; ++fid)
1897 nfacemodes = GetTraceIntNcoeffs(fid);
1898 nfacemodestotal += nfacemodes;
1902 edgemodearray(nedgemodestotal);
1904 facemodearray(nfacemodestotal);
1909 for (eid = 0; eid < nEdges; ++eid)
1912 = GetEdgeInverseBoundaryMap(eid);
1913 nedgemodes = GetEdgeNcoeffs(eid) - 2;
1919 &edgemodearray[offset], 1);
1922 offset += nedgemodes;
1928 for (fid = 0; fid < nFaces; ++fid)
1931 = GetTraceInverseBoundaryMap(fid);
1932 nfacemodes = GetTraceIntNcoeffs(fid);
1938 &facemodearray[offset], 1);
1941 offset += nfacemodes;
1945 for (i = 0; i < nVerts; ++i)
1947 for (j = 0; j < nedgemodestotal; ++j)
1950 GetVertexMap(i), edgemodearray[j],
1951 -R(GetVertexMap(i), edgemodearray[j]));
1953 for (j = 0; j < nfacemodestotal; ++j)
1956 GetVertexMap(i), facemodearray[j],
1957 -R(GetVertexMap(i), facemodearray[j]));
1958 for (n = 0; n < nedgemodestotal; ++n)
1960 MatrixValue = InvR.GetValue(GetVertexMap(i),
1962 + R(GetVertexMap(i), edgemodearray[n])
1963 * R(edgemodearray[n], facemodearray[j]);
1964 InvR.SetValue(GetVertexMap(i),
1972 for (i = 0; i < nedgemodestotal; ++i)
1974 for (j = 0; j < nfacemodestotal; ++j)
1977 edgemodearray[i], facemodearray[j],
1978 -R(edgemodearray[i], facemodearray[j]));
1982 for (i = 0; i < nCoeffs; ++i)
1984 InvR.SetValue(i, i, 1.0);
1987 return inversetransformationmatrix;
1995 int nBndCoeffs = NumBndryCoeffs();
1998 GetBoundaryMap(bmap);
2002 map<int, int> invmap;
2003 for (j = 0; j < nBndCoeffs; ++j)
2005 invmap[bmap[j]] = j;
2009 nEdgeCoeffs = GetEdgeNcoeffs(eid) - 2;
2015 geom->GetEorient(eid);
2022 GetEdgeInteriorToElementMap(eid, maparray, signarray, eOrient);
2024 for (n = 0; n < nEdgeCoeffs; ++n)
2026 edgemaparray[n] = invmap[maparray[n]];
2029 return edgemaparray;
2041 int nBndCoeffs = NumBndryCoeffs();
2044 GetBoundaryMap(bmap);
2048 map<int, int> reversemap;
2049 for (j = 0; j < bmap.size(); ++j)
2051 reversemap[bmap[j]] = j;
2055 nFaceCoeffs = GetTraceIntNcoeffs(fid);
2065 fOrient = GetTraceOrient(fid);
2069 fOrient = faceOrient;
2073 GetTraceInteriorToElementMap(fid, maparray, signarray, fOrient);
2077 GetTraceNumModes(fid,locP1,locP2,fOrient);
2085 ASSERTL1(P1 <= locP1,
"Expect value of passed P1 to "
2086 "be lower or equal to face num modes");
2095 ASSERTL1(P2 <= locP2,
"Expect value of passed P2 to "
2096 "be lower or equal to face num modes");
2099 switch(GetGeom3D()->GetFace(fid)->GetShapeType())
2103 if(((P1-3)>0)&&((P2-3)>0))
2108 for(n = 0; n < P1-3; ++n)
2110 for(
int m = 0; m < P2-3-n; ++m, ++cnt)
2112 facemaparray[cnt] = reversemap[maparray[cnt1+m]];
2121 if(((P1-2)>0)&&((P2-2)>0))
2126 for(n = 0; n < P2-2; ++n)
2128 for(
int m = 0; m < P1-2; ++m, ++cnt)
2130 facemaparray[cnt] = reversemap[maparray[cnt1+m]];
2139 ASSERTL0(
false,
"Invalid shape type.");
2145 return facemaparray;
2148 void Expansion3D::GetInverseBoundaryMaps(
2157 int nBndCoeffs = NumBndryCoeffs();
2160 GetBoundaryMap(bmap);
2164 map<int, int> reversemap;
2165 for (j = 0; j < bmap.size(); ++j)
2167 reversemap[bmap[j]] = j;
2170 int nverts = GetNverts();
2172 for (n = 0; n < nverts; ++n)
2174 int id = GetVertexMap(n);
2175 vmap[n] = reversemap[id];
2178 int nedges = GetNedges();
2181 for(
int eid = 0; eid < nedges; ++eid)
2184 nEdgeCoeffs = GetEdgeNcoeffs(eid) - 2;
2195 for (n = 0; n < nEdgeCoeffs; ++n)
2197 edgemaparray[n] = reversemap[maparray[n]];
2199 emap[eid] = edgemaparray;
2202 int nfaces = GetNtraces();
2205 for(
int fid = 0; fid < nfaces; ++fid)
2208 nFaceCoeffs = GetTraceIntNcoeffs(fid);
2217 GetTraceInteriorToElementMap(fid,maparray, signarray,
2220 for (n = 0; n < nFaceCoeffs; ++n)
2222 facemaparray[n] = reversemap[maparray[n]];
2225 fmap[fid] = facemaparray;
2232 return m_geom->GetForient(face);
2240 void Expansion3D::v_GetTracePhysVals(
2249 orient = GetTraceOrient(face);
2252 int nq0 = FaceExp->GetNumPoints(0);
2253 int nq1 = FaceExp->GetNumPoints(1);
2255 int nfacepts = GetTraceNumPoints(face);
2256 int dir0 = GetGeom3D()->GetDir(face,0);
2257 int dir1 = GetGeom3D()->GetDir(face,1);
2264 GetTracePhysMap(face,faceids);
2268 Vmath::Gathr(
static_cast<int>(faceids.size()),inarray,faceids,o_tmp);
2285 m_base[dir1]->GetPointsKey(),
2287 FaceExp->GetBasis(to_id0)->GetPointsKey(),
2288 FaceExp->GetBasis(to_id1)->GetPointsKey(),
2292 v_ReOrientTracePhysMap(orient,faceids, nq0,nq1);
2296 void Expansion3D::v_ReOrientTracePhysMap
2299 const int nq0,
const int nq1)
2302 if(idmap.size() != nq0*nq1)
2307 if(GetNverts() == 3)
2313 for(
int i = 0; i < nq0*nq1; ++i)
2320 for (
int j = 0; j < nq1; ++j)
2322 for(
int i = 0; i < nq0; ++i)
2324 idmap[j*nq0+i] = nq0-1-i +j*nq0;
2329 ASSERTL0(
false,
"Case not supposed to be used in this function");
2338 for(
int i = 0; i < nq0*nq1; ++i)
2346 for (
int j = 0; j < nq1; j++)
2348 for (
int i =0; i < nq0; ++i)
2350 idmap[j*nq0+i] = nq0-1-i + j*nq0;
2358 for (
int j = 0; j < nq1; j++)
2360 for (
int i =0; i < nq0; ++i)
2362 idmap[j*nq0+i] = nq0*(nq1-1-j)+i;
2370 for (
int j = 0; j < nq1; j++)
2372 for (
int i =0; i < nq0; ++i)
2374 idmap[j*nq0+i] = nq0*nq1-1-j*nq0 -i;
2382 for (
int i =0; i < nq0; ++i)
2384 for (
int j = 0; j < nq1; ++j)
2386 idmap[i*nq1+j] = i + j*nq0;
2394 for (
int i =0; i < nq0; ++i)
2396 for (
int j = 0; j < nq1; ++j)
2398 idmap[i*nq1+j] = nq0-1-i + j*nq0;
2406 for (
int i =0; i < nq0; ++i)
2408 for (
int j = 0; j < nq1; ++j)
2410 idmap[i*nq1+j] = i+nq0*(nq1-1)-j*nq0;
2418 for (
int i =0; i < nq0; ++i)
2420 for (
int j = 0; j < nq1; ++j)
2422 idmap[i*nq1+j] = nq0*nq1-1-i-j*nq0;
2428 ASSERTL0(
false,
"Unknow orientation");
2434 void Expansion3D::v_NormVectorIProductWRTBase(
2438 NormVectorIProductWRTBase(Fvec[0], Fvec[1], Fvec[2], outarray);
2450 int nquad_f = FaceExp_f->GetNumPoints(0)*FaceExp_f->GetNumPoints(1);
2451 int coordim = GetCoordim();
2453 int nquad0 = m_base[0]->GetNumPoints();
2454 int nquad1 = m_base[1]->GetNumPoints();
2455 int nquad2 = m_base[2]->GetNumPoints();
2456 int nqtot = nquad0*nquad1*nquad2;
2474 StdRegions::VarCoeffMap::const_iterator MFdir;
2479 for (
int k=0; k<coordim; k++)
2481 MFdir = varcoeffs.find(MMFCoeffs[dir*5+k]);
2482 tmp = MFdir->second;
2484 GetPhysFaceVarCoeffsFromElement(face, FaceExp_f, tmp, tmp_f);
2489 &nFacecdotMF[0], 1);
2497 auto x = m_faceNormals.find(face);
2498 ASSERTL0 (x != m_faceNormals.end(),
2499 "face normal not computed.");
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed to...
#define sign(a, b)
return the sign(b)*a
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
const ConstFactorMap & GetConstFactors() const
const VarCoeffMap & GetVarCoeffs() const
MatrixType GetMatrixType() const
bool HasVarCoeff(const StdRegions::VarCoeffType &coeff) const
NekDouble GetConstFactor(const ConstFactorType &factor) const
int getNumberOfCoefficients(int Na)
void Interp2D(const BasisKey &fbasis0, const BasisKey &fbasis1, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, const BasisKey &tbasis1, Array< OneD, NekDouble > &to)
this function interpolates a 2D function evaluated at the quadrature points of the 2D basis,...
std::shared_ptr< Expansion > ExpansionSharedPtr
std::shared_ptr< IndexMapValues > IndexMapValuesSharedPtr
std::shared_ptr< Geometry3D > Geometry3DSharedPtr
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
@ eInvLaplacianWithUnityMean
static ConstFactorMap NullConstFactorMap
@ eDir1BwdDir2_Dir2BwdDir1
@ eDir1FwdDir1_Dir2FwdDir2
@ eDir1BwdDir1_Dir2BwdDir2
@ eDir1BwdDir2_Dir2FwdDir1
@ eDir1FwdDir1_Dir2BwdDir2
@ eDir1BwdDir1_Dir2FwdDir2
@ eDir1FwdDir2_Dir2FwdDir1
@ eDir1FwdDir2_Dir2BwdDir1
The above copyright notice and this permission notice shall be included.
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)
static DNekMatSharedPtr NullDNekMatSharedPtr
std::shared_ptr< DNekMat > DNekMatSharedPtr
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.
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*x + y
void Neg(int n, T *x, const int incx)
Negate x = -x.
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
void Scatr(int n, const T *x, const int *y, T *z)
Scatter vector z[y[i]] = x[i].
void Gathr(int n, const T *sign, const T *x, const int *y, T *z)
Gather vector z[i] = sign[i]*x[y[i]].
void Zero(int n, T *x, const int incx)
Zero vector.
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)