35 #include <boost/core/ignore_unused.hpp>
50 namespace LocalRegions
54 void Expansion3D::AddHDGHelmholtzFaceTerms(
60 int nquad_f = FaceExp->GetNumPoints(0) * FaceExp->GetNumPoints(1);
61 int order_f = FaceExp->GetNcoeffs();
62 int coordim = GetCoordim();
63 int ncoeffs = GetNcoeffs();
79 GetBasisNumModes(1), GetBasisNumModes(2), face,
80 GetTraceOrient(face));
95 if ((x = varcoeffs.find(VarCoeff[0])) != varcoeffs.end())
97 GetPhysFaceVarCoeffsFromElement(face,FaceExp,x->second,varcoeff_work);
98 Vmath::Vmul(nquad_f,varcoeff_work,1,FaceExp->GetPhys(),1,FaceExp->UpdatePhys(),1);
105 FaceExp->IProductWRTBase(facePhys, outcoeff);
107 for (i = 0; i < order_f; ++i)
109 outarray[(*map)[i].index] += (*map)[i].sign * tau * outcoeff[i];
118 for (n = 0; n < coordim; ++n)
128 invMass = *GetLocMatrix(invMasskey);
131 GetnFacecdotMF(n, face, FaceExp, normals, varcoeffs);
133 Vmath::Vmul(nquad_f, ncdotMF_f, 1, facePhys, 1, inval, 1);
137 Vmath::Vmul(nquad_f, normals[n], 1, facePhys, 1, inval, 1);
141 const NekDouble *data = invMass.GetRawPtr();
154 FaceExp->IProductWRTBase(inval, outcoeff);
157 for (i = 0; i < ncoeffs; ++i)
160 for (j = 0; j < order_f; ++j)
162 tmpcoeff[i] += scale * data[i + (*map)[j].index * ncoeffs] *
163 (*map)[j].sign * outcoeff[j];
171 GetMF(n, coordim, varcoeffs);
173 GetMFDiv(n, varcoeffs);
181 Coeffs = Coeffs + Dmat * Tmpcoeff;
186 Coeffs = Coeffs + Dmat * Tmpcoeff;
206 void Expansion3D::GetPhysFaceVarCoeffsFromElement(
215 FwdTrans(varcoeff, tmp);
221 GetTraceToElementMap(face, emap,
sign, GetTraceOrient(face));
223 for (
unsigned int i = 0; i < FaceExp->GetNcoeffs(); ++i)
225 facetmp[i] = tmp[emap[i]];
229 FaceExp->BwdTrans(facetmp, outarray);
236 void Expansion3D::AddNormTraceInt(
const int dir,
243 int order_f, nquad_f;
244 int nfaces = GetNtraces();
247 for (f = 0; f < nfaces; ++f)
249 order_f = FaceExp[f]->GetNcoeffs();
250 nquad_f = FaceExp[f]->GetNumPoints(0) * FaceExp[f]->GetNumPoints(1);
257 for (i = 0; i < order_f; ++i)
259 faceCoeffs[i] = inarray[i + cnt];
263 FaceExp[f]->BwdTrans(faceCoeffs, facePhys);
280 StdRegions::VarCoeffMap::const_iterator x;
284 GetnFacecdotMF(dir, f, FaceExp[f], normals, varcoeffs);
286 Vmath::Vmul(nquad_f, ncdotMF_f, 1, facePhys, 1, facePhys, 1);
290 Vmath::Vmul(nquad_f, normals[dir], 1, facePhys, 1, facePhys, 1);
293 AddFaceBoundaryInt(f, FaceExp[f], facePhys, outarray, varcoeffs);
298 void Expansion3D::AddNormTraceInt(
305 int nfaces = GetNtraces();
307 for (f = 0; f < nfaces; ++f)
309 nquad_f = FaceExp[f]->GetNumPoints(0) * FaceExp[f]->GetNumPoints(1);
315 FaceExp[f]->BwdTrans(faceCoeffs[f], facePhys);
317 Vmath::Vmul(nquad_f, normals[dir], 1, facePhys, 1, facePhys, 1);
319 AddFaceBoundaryInt(f, FaceExp[f], facePhys, outarray);
326 void Expansion3D::AddFaceBoundaryInt(
const int face,
332 boost::ignore_unused(varcoeffs);
335 int order_f = FaceExp->GetNcoeffs();
339 GetBasisNumModes(1), GetBasisNumModes(2), face,
340 GetTraceOrient(face));
357 FaceExp->IProductWRTBase(facePhys, coeff);
360 for (i = 0; i < order_f; ++i)
362 outarray[(*map)[i].index] += (*map)[i].sign * coeff[i];
369 void Expansion3D::SetFaceToGeomOrientation(
const int face,
373 int nface = GetTraceNcoeffs(face);
380 GetBasisNumModes(1), GetBasisNumModes(2), face,
384 GetBasisNumModes(1), GetBasisNumModes(2), face,
385 GetTraceOrient(face));
388 ASSERTL1((*map1).size() == (*map2).size(),
389 "There is an error with the GetTraceToElementMap");
391 for (j = 0; j < (*map1).size(); ++j)
394 for (k = 0; k < (*map2).size(); ++k)
397 if ((*map1)[j].index == (*map2)[k].index && k != j)
401 if ((*map1)[j].
sign != (*map2)[k].
sign)
415 int nfaces = GetNtraces();
419 for (i = 0; i < nfaces; ++i)
421 SetFaceToGeomOrientation(i, f_tmp = inout + cnt);
422 cnt += GetTraceNcoeffs(i);
432 "Geometric information is not set up");
448 NekDouble jac = (m_metricinfo->GetJac(ptsKeys))[0];
461 DetShapeType(), *
this);
469 NekDouble fac = 1.0 / (m_metricinfo->GetJac(ptsKeys))[0];
491 NekDouble jac = (m_metricinfo->GetJac(ptsKeys))[0];
493 m_metricinfo->GetDerivFactors(ptsKeys);
509 DNekMat &deriv0 = *GetStdMatrix(deriv0key);
510 DNekMat &deriv1 = *GetStdMatrix(deriv1key);
511 DNekMat &deriv2 = *GetStdMatrix(deriv2key);
513 int rows = deriv0.GetRows();
514 int cols = deriv1.GetColumns();
518 (*WeakDeriv) = df[3 * dir][0] * deriv0 +
519 df[3 * dir + 1][0] * deriv1 +
520 df[3 * dir + 2][0] * deriv2;
554 DNekMat &lap00 = *GetStdMatrix(lap00key);
555 DNekMat &lap01 = *GetStdMatrix(lap01key);
556 DNekMat &lap02 = *GetStdMatrix(lap02key);
557 DNekMat &lap11 = *GetStdMatrix(lap11key);
558 DNekMat &lap12 = *GetStdMatrix(lap12key);
559 DNekMat &lap22 = *GetStdMatrix(lap22key);
561 NekDouble jac = (m_metricinfo->GetJac(ptsKeys))[0];
563 m_metricinfo->GetGmat(ptsKeys);
565 int rows = lap00.GetRows();
566 int cols = lap00.GetColumns();
571 (*lap) = gmat[0][0] * lap00 + gmat[4][0] * lap11 +
573 gmat[3][0] * (lap01 +
Transpose(lap01)) +
574 gmat[6][0] * (lap02 +
Transpose(lap02)) +
591 int rows = LapMat.GetRows();
592 int cols = LapMat.GetColumns();
598 (*helm) = LapMat + factor * MassMat;
614 "Need to specify eFactorGJP to construct "
615 "a HelmholtzGJP matrix");
619 factor /= HelmMat.Scale();
621 int ntot = HelmMat.GetRows() * HelmMat.GetColumns();
624 HelmMat.GetRawPtr(), 1, &NDTraceMat->GetPtr()[0], 1);
627 HelmMat.Scale(), NDTraceMat);
641 NekDouble jac = (m_metricinfo->GetJac(ptsKeys))[0];
667 GetLocStaticCondMatrix(helmkey);
679 GetLocStaticCondMatrix(masskey);
693 GetLocStaticCondMatrix(helmkey);
743 "Matrix construction is not implemented for variable "
744 "coefficients at the moment");
754 ASSERTL1(IsBoundaryInteriorExpansion(),
755 "HybridDGHelmholtz matrix not set up "
756 "for non boundary-interior expansions");
762 int ncoeffs = GetNcoeffs();
763 int nfaces = GetNtraces();
770 int order_f, coordim = GetCoordim();
784 StdRegions::VarCoeffMap::const_iterator x;
787 for (i = 0; i < coordim; ++i)
794 GetMF(i, coordim, varcoeffs);
796 GetMFDiv(i, varcoeffs);
799 DetShapeType(), *
this,
815 Mat = Mat + Dmat * invMass *
Transpose(Dmat);
820 Mat = Mat + Dmat * invMass *
Transpose(Dmat);
845 Mat = Mat + lambdaval * Mass;
848 for (i = 0; i < nfaces; ++i)
850 FaceExp = GetTraceExp(i);
851 order_f = FaceExp->GetNcoeffs();
854 GetBasisNumModes(0), GetBasisNumModes(1),
855 GetBasisNumModes(2), i, GetTraceOrient(i));
876 for (j = 0; j < order_f; ++j)
878 for (k = 0; k < order_f; ++k)
880 Mat((*map)[j].index, (*map)[k].index) +=
881 tau * (*map)[j].sign * (*map)[k].sign *
eMass(j, k);
892 int nbndry = NumDGBndryCoeffs();
893 int ncoeffs = GetNcoeffs();
894 int nfaces = GetNtraces();
921 for (i = 0; i < nfaces; ++i)
923 FaceExp = GetTraceExp(
925 int nface = GetTraceNcoeffs(i);
931 for (j = 0; j < nface; ++j)
935 face_lambda[j] = 1.0;
937 SetFaceToGeomOrientation(i, face_lambda);
940 FaceExp->BwdTrans(face_lambda, tmp);
941 AddHDGHelmholtzFaceTerms(tau, i, tmp, mkey.
GetVarCoeffs(),
947 for (k = 0; k < ncoeffs; ++k)
949 Umat(k, bndry_cnt) = Ulam[k];
1004 int nbndry = NumDGBndryCoeffs();
1005 int coordim = GetCoordim();
1006 int ncoeffs = GetNcoeffs();
1007 int nfaces = GetNtraces();
1032 for (i = 0; i < nfaces; ++i)
1034 FaceExp[i] = GetTraceExp(i);
1054 ASSERTL0(
false,
"Direction not known");
1060 StdRegions::VarCoeffMap::const_iterator x;
1067 GetMF(dir, coordim, varcoeffs);
1069 GetMFDiv(dir, varcoeffs);
1075 Dmat = GetLocMatrix(Dmatkey);
1085 invMass = *GetLocMatrix(invMasskey);
1096 for (j = 0; j < nbndry; ++j)
1102 for (k = 0; k < ncoeffs; ++k)
1104 Ulam[k] = lamToU(k, j);
1111 SetTraceToGeomOrientation(lambda);
1115 AddNormTraceInt(dir, lambda, FaceExp, f, mkey.
GetVarCoeffs());
1122 &(Qmat.GetPtr())[0] + j * ncoeffs, 1);
1130 int order_f, nquad_f;
1131 int nbndry = NumDGBndryCoeffs();
1132 int nfaces = GetNtraces();
1160 LamToQ[0] = GetLocMatrix(LamToQ0key);
1166 LamToQ[1] = GetLocMatrix(LamToQ1key);
1172 LamToQ[2] = GetLocMatrix(LamToQ2key);
1176 for (i = 0; i < nfaces; ++i)
1178 FaceExp[i] = GetTraceExp(i);
1182 for (i = 0; i < nbndry; ++i)
1188 SetTraceToGeomOrientation(lam);
1190 for (f = 0; f < nfaces; ++f)
1192 order_f = FaceExp[f]->GetNcoeffs();
1193 nquad_f = FaceExp[f]->GetNumPoints(0) *
1194 FaceExp[f]->GetNumPoints(1);
1195 normals = GetTraceNormal(f);
1201 GetBasisNumModes(0), GetBasisNumModes(1),
1202 GetBasisNumModes(2), f, GetTraceOrient(f));
1218 for (j = 0; j < order_f; ++j)
1221 (*map)[j].sign * (*LamToQ[0])((*map)[j].index, i);
1224 FaceExp[f]->BwdTrans(faceCoeffs, facePhys);
1240 0, f, FaceExp[f], normals, varcoeffs);
1242 Vmath::Vmul(nquad_f, ncdotMF, 1, facePhys, 1, work, 1);
1246 Vmath::Vmul(nquad_f, normals[0], 1, facePhys, 1, work,
1251 for (j = 0; j < order_f; ++j)
1254 (*map)[j].sign * (*LamToQ[1])((*map)[j].index, i);
1257 FaceExp[f]->BwdTrans(faceCoeffs, facePhys);
1273 1, f, FaceExp[f], normals, varcoeffs);
1275 Vmath::Vvtvp(nquad_f, ncdotMF, 1, facePhys, 1, work, 1,
1280 Vmath::Vvtvp(nquad_f, normals[1], 1, facePhys, 1, work,
1285 for (j = 0; j < order_f; ++j)
1288 (*map)[j].sign * (*LamToQ[2])((*map)[j].index, i);
1291 FaceExp[f]->BwdTrans(faceCoeffs, facePhys);
1307 2, f, FaceExp[f], normals, varcoeffs);
1309 Vmath::Vvtvp(nquad_f, ncdotMF, 1, facePhys, 1, work, 1,
1314 Vmath::Vvtvp(nquad_f, normals[2], 1, facePhys, 1, work,
1320 for (j = 0; j < order_f; ++j)
1323 (*map)[j].sign * LamToU((*map)[j].index, i) -
1327 FaceExp[f]->BwdTrans(faceCoeffs, facePhys);
1339 Vmath::Svtvp(nquad_f, -tau, facePhys, 1, work, 1, work, 1);
1342 FaceExp[f]->IProductWRTBase(work, faceCoeffs);
1344 SetFaceToGeomOrientation(f, faceCoeffs);
1346 for (j = 0; j < order_f; ++j)
1348 BndMat(cnt + j, i) = faceCoeffs[j];
1364 LapMat.GetRows(), LapMat.GetColumns());
1370 int nq = GetTotPoints();
1374 IProductWRTBase(tmp, outarray);
1376 Vmath::Vcopy(m_ncoeffs, &outarray[0], 1, &(lmat->GetPtr())[0], 1);
1383 int ntraces = GetNtraces();
1384 int ncoords = GetCoordim();
1385 int nphys = GetTotPoints();
1391 Vmath::Zero(m_ncoeffs * m_ncoeffs, Mat.GetPtr(), 1);
1395 for (
int d = 0; d < ncoords; ++d)
1403 for (
int t = 0; t < ntraces; ++t)
1405 traceExp[t] = GetTraceExp(t);
1406 tracepts[t] = traceExp[t]->GetTotPoints();
1407 maxtpts = (maxtpts > tracepts[t]) ? maxtpts : tracepts[t];
1413 for (
int t = 0; t < ntraces; ++t)
1419 for (
int i = 0; i < m_ncoeffs; ++i)
1422 PhysDeriv(phys, Deriv[0], Deriv[1], Deriv[2]);
1424 for (
int t = 0; t < ntraces; ++t)
1431 traceExp[t]->GetBasis(0)->GetBasisKey();
1433 traceExp[t]->GetBasis(1)->GetBasisKey();
1435 (fromkey0 != tokey0) || (fromkey1 != tokey1);
1442 for (
int d = 0; d < ncoords; ++d)
1455 GetTracePhysVals(t, traceExp[t], Deriv[d], val,
1456 v_GetTraceOrient(t));
1459 tmp = dphidn[t] + i * tracepts[t], 1,
1460 tmp1 = dphidn[t] + i * tracepts[t], 1);
1465 for (
int t = 0; t < ntraces; ++t)
1467 int nt = tracepts[t];
1469 TraceNormLen(t, h,
p);
1473 (
p == 1) ? 0.02 * h * h : 0.8 * pow(
p + 1, -4.0) * h * h;
1475 for (
int i = 0; i < m_ncoeffs; ++i)
1477 for (
int j = i; j < m_ncoeffs; ++j)
1480 dphidn[t] + j * nt, 1, val, 1);
1482 Mat(i, j) + scale * traceExp[t]->Integral(val);
1488 for (
int i = 0; i < m_ncoeffs; ++i)
1490 for (
int j = 0; j < i; ++j)
1492 Mat(i, j) = Mat(j, i);
1499 "This matrix type cannot be generated from this class");
1506 void Expansion3D::v_AddFaceNormBoundaryInt(
1521 if (m_requireNeg.size() == 0)
1523 m_requireNeg.resize(GetNtraces());
1525 for (i = 0; i < GetNtraces(); ++i)
1527 m_requireNeg[i] =
false;
1531 if (faceExp->GetRightAdjacentElementExp())
1533 if (faceExp->GetRightAdjacentElementExp()
1535 ->GetGlobalID() == GetGeom()->GetGlobalID())
1537 m_requireNeg[i] =
true;
1544 GetBasisNumModes(1), GetBasisNumModes(2), face,
1545 GetTraceOrient(face));
1548 int order_e = (*map).size();
1549 int n_coeffs = FaceExp->GetNcoeffs();
1553 if (n_coeffs != order_e)
1558 FaceExp->FwdTrans(Fn, faceCoeffs);
1560 int NumModesElementMax = FaceExp->GetBasis(0)->GetNumModes();
1561 int NumModesElementMin = m_base[0]->GetNumModes();
1563 FaceExp->ReduceOrderCoeffs(NumModesElementMin, faceCoeffs, faceCoeffs);
1566 FaceExp->DetShapeType(), *FaceExp);
1567 FaceExp->MassMatrixOp(faceCoeffs, faceCoeffs, masskey);
1570 int offset1 = 0, offset2 = 0;
1574 for (i = 0; i < NumModesElementMin; ++i)
1576 for (j = 0; j < NumModesElementMin; ++j)
1578 faceCoeffs[offset1 + j] = faceCoeffs[offset2 + j];
1580 offset1 += NumModesElementMin;
1581 offset2 += NumModesElementMax;
1585 for (i = NumModesElementMin; i < NumModesElementMax; ++i)
1587 for (j = NumModesElementMin; j < NumModesElementMax; ++j)
1589 faceCoeffs[i * NumModesElementMax + j] = 0.0;
1598 int offset1 = 0, offset2 = 0;
1600 for (i = 0; i < NumModesElementMin; ++i)
1602 for (j = 0; j < NumModesElementMin - i; ++j)
1604 faceCoeffs[offset1 + j] = faceCoeffs[offset2 + j];
1606 offset1 += NumModesElementMin - i;
1607 offset2 += NumModesElementMax - i;
1613 FaceExp->IProductWRTBase(Fn, faceCoeffs);
1616 if (m_requireNeg[face])
1618 for (i = 0; i < order_e; ++i)
1620 outarray[(*map)[i].index] -= (*map)[i].sign * faceCoeffs[i];
1625 for (i = 0; i < order_e; ++i)
1627 outarray[(*map)[i].index] += (*map)[i].sign * faceCoeffs[i];
1637 void Expansion3D::v_DGDeriv(
int dir,
1643 int ncoeffs = GetNcoeffs();
1649 DNekScalMat &Dmat = *GetLocMatrix(DerivType[dir]);
1659 AddNormTraceInt(dir, FaceExp, faceCoeffs, coeffs);
1663 Out_d = InvMass * Coeffs;
1666 void Expansion3D::v_AddRobinMassMatrix(
1670 ASSERTL1(IsBoundaryInteriorExpansion(),
1671 "Not set up for non boundary-interior expansions");
1672 ASSERTL1(inoutmat->GetRows() == inoutmat->GetColumns(),
1673 "Assuming that input matrix was square");
1678 int order_f = faceExp->GetNcoeffs();
1691 DNekScalMat &facemat = *faceExp->GetLocMatrix(mkey);
1708 int rows = inoutmat->GetRows();
1710 if (rows == GetNcoeffs())
1712 GetTraceToElementMap(face, map,
sign, GetTraceOrient(face));
1714 else if (rows == GetNverts())
1716 int nfvert = faceExp->GetNverts();
1723 GetLinStdExp()->GetTraceToElementMap(face, linmap, linsign,
1724 GetTraceOrient(face));
1732 for (i = 0; i < nfvert; ++i)
1734 fmap = faceExp->GetVertexMap(i,
true);
1738 map[fmap] = linmap[i];
1741 else if (rows == NumBndryCoeffs())
1743 int nbndry = NumBndryCoeffs();
1746 GetTraceToElementMap(face, map,
sign, GetTraceOrient(face));
1747 GetBoundaryMap(bmap);
1749 for (i = 0; i < order_f; ++i)
1751 for (j = 0; j < nbndry; ++j)
1753 if (map[i] == bmap[j])
1759 ASSERTL1(j != nbndry,
"Did not find number in map");
1762 else if (rows == NumDGBndryCoeffs())
1770 GetBasisNumModes(1), GetBasisNumModes(2), face,
1771 GetTraceOrient(face));
1774 GetBasisNumModes(1), GetBasisNumModes(2), face,
1778 ASSERTL1((*map1).size() == (*map2).size(),
1779 "There is an error with the GetTraceToElementMap");
1781 for (i = 0; i < face; ++i)
1783 cnt += GetTraceNcoeffs(i);
1786 for (i = 0; i < (*map1).size(); ++i)
1790 for (j = 0; j < (*map2).size(); ++j)
1792 if ((*map1)[i].index == (*map2)[j].index)
1799 ASSERTL2(idx >= 0,
"Index not found");
1801 sign[i] = (*map2)[idx].sign;
1806 ASSERTL0(
false,
"Could not identify matrix type from dimension");
1809 for (i = 0; i < order_f; ++i)
1812 for (j = 0; j < order_f; ++j)
1815 (*inoutmat)(id1, id2) += facemat(i, j) *
sign[i] *
sign[j];
1826 int nVerts, vid1, vid2, vMap1, vMap2;
1829 nVerts = GetNverts();
1833 DNekMat &VertexMat = (*vertexmatrix);
1835 for (vid1 = 0; vid1 < nVerts; ++vid1)
1837 vMap1 = GetVertexMap(vid1,
true);
1839 for (vid2 = 0; vid2 < nVerts; ++vid2)
1841 vMap2 = GetVertexMap(vid2,
true);
1842 VertexValue = (*r_bnd)(vMap1, vMap2);
1843 VertexMat.SetValue(vid1, vid2, VertexValue);
1847 return vertexmatrix;
1854 int eid, fid, vid, n, i;
1856 int nBndCoeffs = NumBndryCoeffs();
1861 nVerts = GetNverts();
1862 nEdges = GetNedges();
1887 int nConnectedEdges = 3;
1888 int nConnectedFaces = 3;
1899 nBndCoeffs, nBndCoeffs, 0.0, storage);
1901 DNekMat &R = (*transformationmatrix);
1906 for (vid = 0; vid < nVerts; ++vid)
1909 int efRow = GetEdgeNcoeffs(geom->GetVertexEdgeMap(vid, 0)) +
1910 GetEdgeNcoeffs(geom->GetVertexEdgeMap(vid, 1)) +
1911 GetEdgeNcoeffs(geom->GetVertexEdgeMap(vid, 2)) +
1912 GetTraceIntNcoeffs(geom->GetVertexFaceMap(vid, 0)) +
1913 GetTraceIntNcoeffs(geom->GetVertexFaceMap(vid, 1)) +
1914 GetTraceIntNcoeffs(geom->GetVertexFaceMap(vid, 2)) - 6;
1916 int nedgemodesconnected =
1917 GetEdgeNcoeffs(geom->GetVertexEdgeMap(vid, 0)) +
1918 GetEdgeNcoeffs(geom->GetVertexEdgeMap(vid, 1)) +
1919 GetEdgeNcoeffs(geom->GetVertexEdgeMap(vid, 2)) - 6;
1922 int nfacemodesconnected =
1923 GetTraceIntNcoeffs(geom->GetVertexFaceMap(vid, 0)) +
1924 GetTraceIntNcoeffs(geom->GetVertexFaceMap(vid, 1)) +
1925 GetTraceIntNcoeffs(geom->GetVertexFaceMap(vid, 2));
1931 for (eid = 0; eid < nConnectedEdges; ++eid)
1933 MatEdgeLocation[eid] =
1934 GetEdgeInverseBoundaryMap(geom->GetVertexEdgeMap(vid, eid));
1935 nmodes = MatEdgeLocation[eid].size();
1940 &edgemodearray[offset], 1);
1949 for (fid = 0; fid < nConnectedFaces; ++fid)
1951 MatFaceLocation[fid] =
1952 GetTraceInverseBoundaryMap(geom->GetVertexFaceMap(vid, fid));
1953 nmodes = MatFaceLocation[fid].size();
1958 &facemodearray[offset], 1);
1965 DNekMat &Sveft = (*vertexedgefacetransformmatrix);
1969 DNekMat &Svef = (*vertexedgefacecoupling);
1972 for (n = 0; n < nedgemodesconnected; ++n)
1975 VertexEdgeFaceValue = (*r_bnd)(GetVertexMap(vid), edgemodearray[n]);
1978 Svef.SetValue(0, n, VertexEdgeFaceValue);
1982 for (n = 0; n < nfacemodesconnected; ++n)
1985 VertexEdgeFaceValue = (*r_bnd)(GetVertexMap(vid), facemodearray[n]);
1988 Svef.SetValue(0, n + nedgemodesconnected, VertexEdgeFaceValue);
2002 DNekMat &Sefef = (*edgefacecoupling);
2007 for (m = 0; m < nedgemodesconnected; ++m)
2009 for (n = 0; n < nedgemodesconnected; ++n)
2012 EdgeEdgeValue = (*r_bnd)(edgemodearray[n], edgemodearray[m]);
2015 Sefef.SetValue(n, m, EdgeEdgeValue);
2020 for (n = 0; n < nfacemodesconnected; ++n)
2022 for (m = 0; m < nfacemodesconnected; ++m)
2025 FaceFaceValue = (*r_bnd)(facemodearray[n], facemodearray[m]);
2027 Sefef.SetValue(nedgemodesconnected + n, nedgemodesconnected + m,
2033 for (n = 0; n < nedgemodesconnected; ++n)
2035 for (m = 0; m < nfacemodesconnected; ++m)
2038 FaceFaceValue = (*r_bnd)(edgemodearray[n], facemodearray[m]);
2041 Sefef.SetValue(n, nedgemodesconnected + m, FaceFaceValue);
2043 FaceFaceValue = (*r_bnd)(facemodearray[m], edgemodearray[n]);
2046 Sefef.SetValue(nedgemodesconnected + m, n, FaceFaceValue);
2056 Sveft = -Svef * Sefef;
2060 for (n = 0; n < edgemodearray.size(); ++n)
2062 R.SetValue(GetVertexMap(vid), edgemodearray[n], Sveft(0, n));
2066 for (n = 0; n < facemodearray.size(); ++n)
2068 R.SetValue(GetVertexMap(vid), facemodearray[n],
2069 Sveft(0, n + nedgemodesconnected));
2092 int efCol, efRow, nedgemodes;
2095 nConnectedFaces = 2;
2104 for (eid = 0; eid < nEdges; ++eid)
2107 efCol = GetTraceIntNcoeffs(geom->GetEdgeFaceMap(eid, 0)) +
2108 GetTraceIntNcoeffs(geom->GetEdgeFaceMap(eid, 1));
2109 efRow = GetEdgeNcoeffs(eid) - 2;
2115 DNekMat &Mef = (*efedgefacecoupling);
2121 DNekMat &Meff = (*effacefacecoupling);
2127 DNekMat &Meft = (*edgefacetransformmatrix);
2129 int nfacemodesconnected =
2130 GetTraceIntNcoeffs(geom->GetEdgeFaceMap(eid, 0)) +
2131 GetTraceIntNcoeffs(geom->GetEdgeFaceMap(eid, 1));
2136 nedgemodes = GetEdgeNcoeffs(eid) - 2;
2141 Vmath::Vcopy(nedgemodes, &inedgearray[0], 1, &edgemodearray[0], 1);
2147 for (fid = 0; fid < nConnectedFaces; ++fid)
2149 MatFaceLocation[fid] =
2150 GetTraceInverseBoundaryMap(geom->GetEdgeFaceMap(eid, fid));
2151 nmodes = MatFaceLocation[fid].size();
2156 &facemodearray[offset], 1);
2162 for (n = 0; n < nedgemodes; ++n)
2164 for (m = 0; m < nfacemodesconnected; ++m)
2167 EdgeFaceValue = (*r_bnd)(edgemodearray[n], facemodearray[m]);
2170 Mef.SetValue(n, m, EdgeFaceValue);
2175 for (n = 0; n < nfacemodesconnected; ++n)
2177 for (m = 0; m < nfacemodesconnected; ++m)
2180 FaceFaceValue = (*r_bnd)(facemodearray[n], facemodearray[m]);
2183 Meff.SetValue(n, m, FaceFaceValue);
2197 for (n = 0; n < Meft.GetRows(); ++n)
2199 for (m = 0; m < Meft.GetColumns(); ++m)
2201 R.SetValue(edgemodearray[n], facemodearray[m], Meft(n, m));
2206 for (i = 0; i < R.GetRows(); ++i)
2208 R.SetValue(i, i, 1.0);
2214 return transformationmatrix;
2218 NEKERROR(ErrorUtil::efatal,
"unkown matrix type");
2235 int i, j, n, eid = 0, fid = 0;
2236 int nCoeffs = NumBndryCoeffs();
2247 DNekMat &InvR = (*inversetransformationmatrix);
2249 int nVerts = GetNverts();
2250 int nEdges = GetNedges();
2251 int nFaces = GetNtraces();
2255 int nedgemodestotal = 0;
2256 int nfacemodestotal = 0;
2258 for (eid = 0; eid < nEdges; ++eid)
2260 nedgemodes = GetEdgeNcoeffs(eid) - 2;
2261 nedgemodestotal += nedgemodes;
2264 for (fid = 0; fid < nFaces; ++fid)
2266 nfacemodes = GetTraceIntNcoeffs(fid);
2267 nfacemodestotal += nfacemodes;
2276 for (eid = 0; eid < nEdges; ++eid)
2279 nedgemodes = GetEdgeNcoeffs(eid) - 2;
2284 Vmath::Vcopy(nedgemodes, &edgearray[0], 1, &edgemodearray[offset],
2288 offset += nedgemodes;
2294 for (fid = 0; fid < nFaces; ++fid)
2297 nfacemodes = GetTraceIntNcoeffs(fid);
2302 Vmath::Vcopy(nfacemodes, &facearray[0], 1, &facemodearray[offset],
2306 offset += nfacemodes;
2310 for (i = 0; i < nVerts; ++i)
2312 for (j = 0; j < nedgemodestotal; ++j)
2314 InvR.SetValue(GetVertexMap(i), edgemodearray[j],
2315 -R(GetVertexMap(i), edgemodearray[j]));
2317 for (j = 0; j < nfacemodestotal; ++j)
2319 InvR.SetValue(GetVertexMap(i), facemodearray[j],
2320 -R(GetVertexMap(i), facemodearray[j]));
2321 for (n = 0; n < nedgemodestotal; ++n)
2323 MatrixValue = InvR.GetValue(GetVertexMap(i), facemodearray[j]) +
2324 R(GetVertexMap(i), edgemodearray[n]) *
2325 R(edgemodearray[n], facemodearray[j]);
2326 InvR.SetValue(GetVertexMap(i), facemodearray[j], MatrixValue);
2332 for (i = 0; i < nedgemodestotal; ++i)
2334 for (j = 0; j < nfacemodestotal; ++j)
2336 InvR.SetValue(edgemodearray[i], facemodearray[j],
2337 -R(edgemodearray[i], facemodearray[j]));
2341 for (i = 0; i < nCoeffs; ++i)
2343 InvR.SetValue(i, i, 1.0);
2346 return inversetransformationmatrix;
2353 int nBndCoeffs = NumBndryCoeffs();
2356 GetBoundaryMap(bmap);
2360 map<int, int> invmap;
2361 for (j = 0; j < nBndCoeffs; ++j)
2363 invmap[bmap[j]] = j;
2367 nEdgeCoeffs = GetEdgeNcoeffs(eid) - 2;
2377 GetEdgeInteriorToElementMap(eid, maparray, signarray, eOrient);
2379 for (n = 0; n < nEdgeCoeffs; ++n)
2381 edgemaparray[n] = invmap[maparray[n]];
2384 return edgemaparray;
2393 int nBndCoeffs = NumBndryCoeffs();
2396 GetBoundaryMap(bmap);
2400 map<int, int> reversemap;
2401 for (j = 0; j < bmap.size(); ++j)
2403 reversemap[bmap[j]] = j;
2407 nFaceCoeffs = GetTraceIntNcoeffs(fid);
2415 fOrient = GetTraceOrient(fid);
2419 fOrient = faceOrient;
2423 GetTraceInteriorToElementMap(fid, maparray, signarray, fOrient);
2427 GetTraceNumModes(fid, locP1, locP2, fOrient);
2435 ASSERTL1(P1 <= locP1,
"Expect value of passed P1 to "
2436 "be lower or equal to face num modes");
2445 ASSERTL1(P2 <= locP2,
"Expect value of passed P2 to "
2446 "be lower or equal to face num modes");
2449 switch (GetGeom3D()->GetFace(fid)->GetShapeType())
2453 if (((P1 - 3) > 0) && ((P2 - 3) > 0))
2460 for (n = 0; n < P1 - 3; ++n)
2462 for (
int m = 0; m < P2 - 3 - n; ++m, ++cnt)
2464 facemaparray[cnt] = reversemap[maparray[cnt1 + m]];
2466 cnt1 += locP2 - 3 - n;
2473 if (((P1 - 2) > 0) && ((P2 - 2) > 0))
2480 for (n = 0; n < P2 - 2; ++n)
2482 for (
int m = 0; m < P1 - 2; ++m, ++cnt)
2484 facemaparray[cnt] = reversemap[maparray[cnt1 + m]];
2493 ASSERTL0(
false,
"Invalid shape type.");
2498 return facemaparray;
2501 void Expansion3D::GetInverseBoundaryMaps(
2510 int nBndCoeffs = NumBndryCoeffs();
2513 GetBoundaryMap(bmap);
2517 map<int, int> reversemap;
2518 for (j = 0; j < bmap.size(); ++j)
2520 reversemap[bmap[j]] = j;
2523 int nverts = GetNverts();
2525 for (n = 0; n < nverts; ++n)
2527 int id = GetVertexMap(n);
2528 vmap[n] = reversemap[id];
2531 int nedges = GetNedges();
2534 for (
int eid = 0; eid < nedges; ++eid)
2537 nEdgeCoeffs = GetEdgeNcoeffs(eid) - 2;
2545 GetEdgeInteriorToElementMap(eid, maparray, signarray,
2548 for (n = 0; n < nEdgeCoeffs; ++n)
2550 edgemaparray[n] = reversemap[maparray[n]];
2552 emap[eid] = edgemaparray;
2555 int nfaces = GetNtraces();
2558 for (
int fid = 0; fid < nfaces; ++fid)
2561 nFaceCoeffs = GetTraceIntNcoeffs(fid);
2569 GetTraceInteriorToElementMap(fid, maparray, signarray,
2572 for (n = 0; n < nFaceCoeffs; ++n)
2574 facemaparray[n] = reversemap[maparray[n]];
2577 fmap[fid] = facemaparray;
2583 return m_geom->GetForient(face);
2591 void Expansion3D::v_GetTracePhysVals(
2598 orient = GetTraceOrient(face);
2601 int nq0 = FaceExp->GetNumPoints(0);
2602 int nq1 = FaceExp->GetNumPoints(1);
2604 int nfacepts = GetTraceNumPoints(face);
2605 int dir0 = GetGeom3D()->GetDir(face, 0);
2606 int dir1 = GetGeom3D()->GetDir(face, 1);
2613 GetTracePhysMap(face, faceids);
2617 Vmath::Gathr(
static_cast<int>(faceids.size()), inarray, faceids, o_tmp);
2634 m_base[dir0]->GetPointsKey(), m_base[dir1]->GetPointsKey(), o_tmp.get(),
2635 FaceExp->GetBasis(to_id0)->GetPointsKey(),
2636 FaceExp->GetBasis(to_id1)->GetPointsKey(), o_tmp2.get());
2639 v_ReOrientTracePhysMap(orient, faceids, nq0, nq1);
2646 if (faceGeom->GetNumVerts() == 3)
2649 GetTraceBasisKey(traceid, 0), GetTraceBasisKey(traceid, 1),
2650 m_geom->GetFace(traceid));
2655 GetTraceBasisKey(traceid, 0), GetTraceBasisKey(traceid, 1),
2656 m_geom->GetFace(traceid));
2665 if (idmap.size() != nq0 * nq1)
2670 if (GetNverts() == 3)
2676 for (
int i = 0; i < nq0 * nq1; ++i)
2683 for (
int j = 0; j < nq1; ++j)
2685 for (
int i = 0; i < nq0; ++i)
2687 idmap[j * nq0 + i] = nq0 - 1 - i + j * nq0;
2693 "Case not supposed to be used in this function");
2702 for (
int i = 0; i < nq0 * nq1; ++i)
2710 for (
int j = 0; j < nq1; j++)
2712 for (
int i = 0; i < nq0; ++i)
2714 idmap[j * nq0 + i] = nq0 - 1 - i + j * nq0;
2722 for (
int j = 0; j < nq1; j++)
2724 for (
int i = 0; i < nq0; ++i)
2726 idmap[j * nq0 + i] = nq0 * (nq1 - 1 - j) + i;
2734 for (
int j = 0; j < nq1; j++)
2736 for (
int i = 0; i < nq0; ++i)
2738 idmap[j * nq0 + i] = nq0 * nq1 - 1 - j * nq0 - i;
2746 for (
int i = 0; i < nq0; ++i)
2748 for (
int j = 0; j < nq1; ++j)
2750 idmap[i * nq1 + j] = i + j * nq0;
2758 for (
int i = 0; i < nq0; ++i)
2760 for (
int j = 0; j < nq1; ++j)
2762 idmap[i * nq1 + j] = nq0 - 1 - i + j * nq0;
2770 for (
int i = 0; i < nq0; ++i)
2772 for (
int j = 0; j < nq1; ++j)
2774 idmap[i * nq1 + j] = i + nq0 * (nq1 - 1) - j * nq0;
2782 for (
int i = 0; i < nq0; ++i)
2784 for (
int j = 0; j < nq1; ++j)
2786 idmap[i * nq1 + j] = nq0 * nq1 - 1 - i - j * nq0;
2792 ASSERTL0(
false,
"Unknow orientation");
2798 void Expansion3D::v_NormVectorIProductWRTBase(
2802 NormVectorIProductWRTBase(Fvec[0], Fvec[1], Fvec[2], outarray);
2811 int nquad_f = FaceExp_f->GetNumPoints(0) * FaceExp_f->GetNumPoints(1);
2812 int coordim = GetCoordim();
2814 int nquad0 = m_base[0]->GetNumPoints();
2815 int nquad1 = m_base[1]->GetNumPoints();
2816 int nquad2 = m_base[2]->GetNumPoints();
2817 int nqtot = nquad0 * nquad1 * nquad2;
2829 StdRegions::VarCoeffMap::const_iterator MFdir;
2834 for (
int k = 0; k < coordim; k++)
2836 MFdir = varcoeffs.find(MMFCoeffs[dir * 5 + k]);
2837 tmp = MFdir->second.GetValue();
2839 GetPhysFaceVarCoeffsFromElement(face, FaceExp_f, tmp, tmp_f);
2841 Vmath::Vvtvp(nquad_f, &tmp_f[0], 1, &normals[k][0], 1, &nFacecdotMF[0],
2842 1, &nFacecdotMF[0], 1);
2852 int nverts = geom->GetFace(traceid)->GetNumVerts();
2855 tn1.
Sub(*(geom->GetFace(traceid)->GetVertex(1)),
2856 *(geom->GetFace(traceid)->GetVertex(0)));
2858 tn2.
Sub(*(geom->GetFace(traceid)->GetVertex(nverts - 1)),
2859 *(geom->GetFace(traceid)->GetVertex(0)));
2861 normal.
Mult(tn1, tn2);
2865 mag = 1.0 /
sqrt(mag);
2871 for (
int i = 0; i < nverts; ++i)
2874 int edgid = geom->GetEdgeNormalToFaceVert(traceid, i);
2877 Dx.
Sub(*(geom->GetEdge(edgid)->GetVertex(0)),
2878 *(geom->GetEdge(edgid)->GetVertex(1)));
2882 h += fabs(normal.
dot(Dx));
2888 int dir0 = geom->GetDir(traceid, 0);
2889 int dir1 = geom->GetDir(traceid, 1);
2891 for (dirn = 0; dirn < 3; ++dirn)
2893 if ((dirn != dir0) && (dirn != dir1))
#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
Describes the specification for a Basis.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
boost::call_traits< DataType >::const_reference z() const
boost::call_traits< DataType >::const_reference x() const
boost::call_traits< DataType >::const_reference y() const
void Sub(PointGeom &a, PointGeom &b)
void Mult(PointGeom &a, PointGeom &b)
_this = a x b
NekDouble dot(PointGeom &a)
retun the dot product between this and input a
void UpdatePosition(NekDouble x, NekDouble y, NekDouble z)
const ConstFactorMap & GetConstFactors() const
LibUtilities::ShapeType GetShapeType() const
const VarCoeffMap & GetVarCoeffs() const
MatrixType GetMatrixType() const
bool HasVarCoeff(const StdRegions::VarCoeffType &coeff) const
NekDouble GetConstFactor(const ConstFactorType &factor) const
bool ConstFactorExists(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::vector< PointsKey > PointsKeyVector
std::shared_ptr< Expansion > ExpansionSharedPtr
std::shared_ptr< IndexMapValues > IndexMapValuesSharedPtr
@ eNoGeomType
No type defined.
@ eDeformed
Geometry is curved or has non-constant factors.
std::shared_ptr< Geometry > GeometrySharedPtr
std::shared_ptr< Geometry3D > Geometry3DSharedPtr
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
@ eInvLaplacianWithUnityMean
static ConstFactorMap NullConstFactorMap
@ eDir1BwdDir2_Dir2BwdDir1
@ eDir1FwdDir1_Dir2FwdDir2
@ eDir1BwdDir1_Dir2BwdDir2
@ eDir1BwdDir2_Dir2FwdDir1
@ eDir1FwdDir1_Dir2BwdDir2
@ eDir1BwdDir1_Dir2FwdDir2
@ eDir1FwdDir2_Dir2FwdDir1
@ eDir1FwdDir2_Dir2BwdDir1
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
The above copyright notice and this permission notice shall be included.
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
static DNekMatSharedPtr NullDNekMatSharedPtr
static Array< OneD, NekDouble > NullNekDouble1DArray
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)
scalarT< T > sqrt(scalarT< T > in)