16 #include "../coefficient.hpp" 35 #ifndef MFEM_THREAD_SAFE 43 MFEM_ABORT(
"method is not implemented for this class");
49 MFEM_ABORT(
"method is not implemented for this class");
55 MFEM_ABORT(
"method is not implemented for this class");
62 div_shape *= (1.0 / Trans.
Weight());
68 MFEM_ABORT(
"method is not implemented for this class");
78 #ifdef MFEM_THREAD_SAFE 83 curl_shape *= (1.0 / Trans.
Weight());
89 curl_shape *= (1.0 / Trans.
Weight());
92 MFEM_ABORT(
"Invalid dimension, Dim = " <<
dim);
98 MFEM_ABORT(
"method is not overloaded");
104 MFEM_ABORT(
"method is not overloaded");
110 MFEM_ABORT(
"method is not overloaded");
116 MFEM_ABORT(
"method is not overloaded");
123 MFEM_ABORT(
"method is not overloaded");
129 MFEM_ABORT(
"method is not overloaded");
135 MFEM_ABORT(
"method is not overloaded");
141 mfem_error(
"FiniteElement::ProjectFromNodes() (vector) is not overloaded!");
147 MFEM_ABORT(
"method is not overloaded");
152 MFEM_ABORT(
"method is not implemented for this element");
158 MFEM_ABORT(
"method is not implemented for this element");
165 MFEM_ABORT(
"method is not implemented for this element");
172 MFEM_ABORT(
"method is not implemented for this element");
179 MFEM_ABORT(
"method is not implemented for this element");
196 #ifdef MFEM_THREAD_SAFE 216 int size = (
dim*(
dim+1))/2;
222 for (
int nd = 0; nd <
dof; nd++)
224 Laplacian[nd] = hess(nd,0) + hess(nd,4) + hess(nd,5);
229 for (
int nd = 0; nd <
dof; nd++)
231 Laplacian[nd] = hess(nd,0) + hess(nd,2);
236 for (
int nd = 0; nd <
dof; nd++)
238 Laplacian[nd] = hess(nd,0);
248 int size = (
dim*(
dim+1))/2;
259 scale[1] = 2*Gij(0,1);
260 scale[2] = 2*Gij(0,2);
262 scale[3] = 2*Gij(1,2);
270 scale[1] = 2*Gij(0,1);
278 for (
int nd = 0; nd <
dof; nd++)
281 for (
int ii = 0; ii < size; ii++)
283 Laplacian[nd] += hess(nd,ii)*scale[ii];
323 int size = (
dim*(
dim+1))/2;
341 for (
int i = 0; i <
dim; i++)
343 for (
int j = 0; j <
dim; j++)
345 for (
int k = 0; k <
dim; k++)
347 for (
int l = 0; l <
dim; l++)
349 lhm(map[i*
dim+j],map[k*
dim+l]) += invJ(i,k)*invJ(j,l);
357 for (
int i = 0; i <
dim*
dim; i++) { mult[map[i]]++; }
362 Mult( hess, lhm, Hessian);
373 if (d2q.
IntRule == &ir && d2q.
mode == mode) {
return d2q; }
376 #ifdef MFEM_THREAD_SAFE 394 for (
int i = 0; i < nqpt; i++)
398 for (
int j = 0; j <
dof; j++)
400 d2q->
B[i+nqpt*j] = d2q->
Bt[j+
dof*i] = shape(j);
409 for (
int i = 0; i < nqpt; i++)
413 for (
int d = 0; d <
dim; d++)
415 for (
int j = 0; j <
dof; j++)
433 for (
int i = 0; i < nqpt; i++)
437 for (
int d = 0; d <
dim; d++)
439 for (
int j = 0; j <
dof; j++)
454 for (
int i = 0; i < nqpt; i++)
458 for (
int j = 0; j <
dof; j++)
460 d2q->
G[i+nqpt*j] = d2q->
Gt[j+
dof*i] = divshape(j);
471 for (
int i = 0; i < nqpt; i++)
475 for (
int d = 0; d <
cdim; d++)
477 for (
int j = 0; j <
dof; j++)
479 d2q->
G[i+nqpt*(d+
cdim*j)] = d2q->
Gt[j+
dof*(i+nqpt*d)] = curlshape(j, d);
497 MFEM_ABORT(
"method is not implemented for this element");
517 #ifdef MFEM_THREAD_SAFE 527 for (
int i = 0; i < fine_fe.
dof; i++)
532 for (
int j = 0; j <
dof; j++)
534 if (fabs(I(i,j) = shape(j)) < 1.0e-12)
560 Vector fine_shape(fs), coarse_shape(cs);
561 DenseMatrix fine_mass(fs), fine_coarse_mass(fs, cs);
579 fine_mass_inv.
Mult(fine_coarse_mass, I);
599 Vector fine_shape(fs), coarse_shape(cs);
600 DenseMatrix coarse_mass(cs), coarse_fine_mass(cs, fs);
628 coarse_mass_inv.
Mult(coarse_fine_mass, R);
634 R *= 1.0 / Trans.
Weight();
645 for (
int i = 0; i <
dof; i++)
655 for (
int j = 0; j < fe.
GetDof(); j++)
657 curl(i,j) = w * curl_shape(j,0);
668 trans.Transform(p0, x);
675 trans.InverseJacobian().Mult(v, x);
684 #ifdef MFEM_THREAD_SAFE 693 for (
int j = 0; j <
dof; j++)
713 for (
int i = 0; i <
dof; i++)
719 dofs(i) = coeff.
Eval(Trans, ip);
722 dofs(i) *= Trans.
Weight();
733 for (
int i = 0; i <
dof; i++)
737 vc.
Eval (x, Trans, ip);
742 for (
int j = 0; j < x.Size(); j++)
744 dofs(
dof*j+i) = x(j);
756 for (
int k = 0; k <
dof; k++)
761 for (
int r = 0; r < MQ.Height(); r++)
763 for (
int d = 0; d < MQ.Width(); d++)
765 dofs(k+
dof*(d+MQ.Width()*r)) = MQ(r,d);
781 for (
int k = 0; k <
dof; k++)
784 for (
int j = 0; j < shape.Size(); j++)
786 I(k,j) = (fabs(shape(j)) < 1e-12) ? 0.0 : shape(j);
792 for (
int k = 0; k <
dof; k++)
800 for (
int j = 0; j < shape.Size(); j++)
802 I(k,j) = (fabs(shape(j)) < 1e-12) ? 0.0 : shape(j);
813 for (
int k = 0; k <
dof; k++)
840 for (
int k = 0; k <
dof; k++)
846 Mult(dshape, Jinv, grad_k);
851 for (
int j = 0; j < grad_k.Height(); j++)
852 for (
int d = 0; d <
dim; d++)
854 grad(k+d*
dof,j) = grad_k(j,d);
867 for (
int k = 0; k <
dof; k++)
875 for (
int j = 0; j < div_shape.Size(); j++)
877 div(k,j) = (fabs(div_shape(j)) < 1e-12) ? 0.0 : div_shape(j)/detJ;
882 for (
int j = 0; j < div_shape.Size(); j++)
884 div(k,j) = (fabs(div_shape(j)) < 1e-12) ? 0.0 : div_shape(j);
892 int Do,
int O,
int M,
int F)
906 void VectorFiniteElement::CalcShape(
909 mfem_error(
"Error: Cannot use scalar CalcShape(...) function with\n" 910 " VectorFiniteElements!");
913 void VectorFiniteElement::CalcDShape(
914 const IntegrationPoint &ip, DenseMatrix &dshape )
const 916 mfem_error(
"Error: Cannot use scalar CalcDShape(...) function with\n" 917 " VectorFiniteElements!");
949 MFEM_ABORT(
"Invalid dimension, Dim = " <<
dim);
953 MFEM_ABORT(
"Invalid MapType = " <<
map_type);
961 #ifdef MFEM_THREAD_SAFE 966 shape *= (1.0 / Trans.
Weight());
973 #ifdef MFEM_THREAD_SAFE 986 MFEM_ASSERT(vc.
GetVDim() == sdim,
"");
988 const bool square_J = (
dim == sdim);
990 for (
int k = 0; k <
dof; k++)
996 if (!square_J) { dofs(k) /= Trans.
Weight(); }
1005 const bool square_J = (
dim == sdim);
1007 for (
int k = 0; k <
dof; k++)
1012 &vc[k*sdim], nk + d2n[k]*
dim);
1013 if (!square_J) { dofs(k) /= Trans.
Weight(); }
1023 const int sdim = T.GetSpaceDim();
1024 MFEM_ASSERT(mc.
GetWidth() == sdim,
"");
1025 const bool square_J = (
dim == sdim);
1027 Vector nk_phys(sdim), dofs_k(MQ.Height());
1028 MFEM_ASSERT(dofs.
Size() ==
dof*MQ.Height(),
"");
1030 for (
int k = 0; k <
dof; k++)
1035 T.AdjugateJacobian().MultTranspose(nk + d2n[k]*
dim, nk_phys);
1036 if (!square_J) { nk_phys /= T.Weight(); }
1037 MQ.Mult(nk_phys, dofs_k);
1038 for (
int r = 0; r < MQ.Height(); r++)
1040 dofs(k+
dof*r) = dofs_k(r);
1056 for (
int k = 0; k <
dof; k++)
1067 double w = 1.0/Trans.
Weight();
1068 for (
int d = 0; d <
dim; d++)
1074 for (
int j = 0; j < shape.Size(); j++)
1076 double s = shape(j);
1077 if (fabs(
s) < 1e-12)
1083 for (
int d = 0; d < sdim; d++)
1085 I(k,j+d*shape.Size()) =
s*vk[d];
1096 const bool square_J = (
dim == sdim);
1099 for (
int k = 0; k <
dof; k++)
1111 if (!square_J) { vshapenk /= Trans.
Weight(); }
1112 for (
int j=0; j<vshapenk.Size(); j++)
1114 I(k,j) = vshapenk(j);
1126 mfem_error(
"VectorFiniteElement::ProjectGrad_RT works only in 2D!");
1134 for (
int k = 0; k <
dof; k++)
1137 tk[0] = nk[d2n[k]*
dim+1];
1138 tk[1] = -nk[d2n[k]*
dim];
1139 dshape.Mult(tk, grad_k);
1140 for (
int j = 0; j < grad_k.Size(); j++)
1142 grad(k,j) = (fabs(grad_k(j)) < 1e-12) ? 0.0 : grad_k(j);
1151 #ifdef MFEM_THREAD_SAFE 1164 for (
int k = 0; k <
dof; k++)
1178 for (
int j = 0; j < curl_k.Size(); j++)
1180 curl(k,j) = (fabs(curl_k(j)) < 1e-12) ? 0.0 : curl_k(j);
1193 for (
int k = 0; k <
dof; k++)
1196 curl_shape.Mult(nk + d2n[k]*
dim, curl_k);
1197 for (
int j = 0; j < curl_k.Size(); j++)
1199 curl(k,j) = (fabs(curl_k(j)) < 1e-12) ? 0.0 : curl_k(j);
1211 for (
int k = 0; k <
dof; k++)
1225 for (
int k = 0; k <
dof; k++)
1239 const int sdim = T.GetSpaceDim();
1240 MFEM_ASSERT(mc.
GetWidth() == sdim,
"");
1242 Vector tk_phys(sdim), dofs_k(MQ.Height());
1243 MFEM_ASSERT(dofs.
Size() ==
dof*MQ.Height(),
"");
1245 for (
int k = 0; k <
dof; k++)
1250 T.Jacobian().Mult(tk + d2t[k]*
dim, tk_phys);
1251 MQ.Mult(tk_phys, dofs_k);
1252 for (
int r = 0; r < MQ.Height(); r++)
1254 dofs(k+
dof*r) = dofs_k(r);
1270 for (
int k = 0; k <
dof; k++)
1281 double w = 1.0/Trans.
Weight();
1282 for (
int d = 0; d < sdim; d++)
1288 for (
int j = 0; j < shape.Size(); j++)
1290 double s = shape(j);
1291 if (fabs(
s) < 1e-12)
1297 for (
int d = 0; d < sdim; d++)
1299 I(k, j + d*shape.Size()) =
s*vk[d];
1312 for (
int k = 0; k <
dof; k++)
1324 for (
int j=0; j<vshapetk.Size(); j++)
1326 I(k, j) = vshapetk(j);
1342 for (
int k = 0; k <
dof; k++)
1345 dshape.Mult(tk + d2t[k]*
dim, grad_k);
1346 for (
int j = 0; j < grad_k.Size(); j++)
1348 grad(k,j) = (fabs(grad_k(j)) < 1e-12) ? 0.0 : grad_k(j);
1363 DenseMatrix fine_mass(fs), fine_coarse_mass(fs, cs);
1364 const int ir_order =
1380 for (
int k=0; k<fs; ++k)
1382 for (
int j=0; j<cs; ++j)
1385 for (
int d1=0; d1<
dim; ++d1)
1387 for (
int d2=0; d2<
dim; ++d2)
1389 Mkj += w*fine_shape(k,d1)*adjJ(d2,d1)*coarse_shape(j,d2);
1392 fine_coarse_mass(k,j) += (fabs(Mkj) < 1e-12) ? 0.0 : Mkj;
1397 fine_mass_inv.
Mult(fine_coarse_mass, I);
1411 #ifdef MFEM_THREAD_SAFE 1421 for (
int k = 0; k <
dof; k++)
1432 for (
int i = 0; i <
dim; i++)
1434 Ikj +=
vshape(j, i) * vk[i];
1436 I(k, j) = (fabs(Ikj) < 1e-12) ? 0.0 : Ikj;
1451 DenseMatrix fine_mass(fs), fine_coarse_mass(fs, cs);
1452 const int ir_order =
1467 for (
int k=0; k<fs; ++k)
1469 for (
int j=0; j<cs; ++j)
1472 for (
int d1=0; d1<
dim; ++d1)
1474 for (
int d2=0; d2<
dim; ++d2)
1476 Mkj += ip.
weight*fine_shape(k,d1)*J(d1,d2)*coarse_shape(j,d2);
1479 fine_coarse_mass(k,j) += (fabs(Mkj) < 1e-12) ? 0.0 : Mkj;
1484 fine_mass_inv.
Mult(fine_coarse_mass, I);
1496 #ifdef MFEM_THREAD_SAFE 1506 for (
int k = 0; k <
dof; k++)
1517 for (
int i = 0; i <
dim; i++)
1519 Ikj +=
vshape(j, i) * vk[i];
1521 I(k, j) = (fabs(Ikj) < 1e-12) ? 0.0 : Ikj;
1534 #ifdef MFEM_THREAD_SAFE 1540 const double weight = Trans.
Weight();
1541 for (
int j = 0; j <
dof; j++)
1550 for (
int k = 0; k <
dof; k++)
1553 for (
int d = 0; d <
dim; d++)
1555 R_jk +=
vshape(k,d)*pt_data[d];
1577 #ifdef MFEM_THREAD_SAFE 1583 for (
int j = 0; j <
dof; j++)
1590 Jinv.
Mult(tk+
dim*d2t[j], pt_data);
1591 for (
int k = 0; k <
dof; k++)
1594 for (
int d = 0; d <
dim; d++)
1596 R_jk +=
vshape(k,d)*pt_data[d];
1612 : etype(etype), auxiliary_basis(NULL), scale_integrated(false)
1621 for (
int i = 0; i <=
p; i++)
1635 for (
int i = 0; i <=
p; i++)
1637 for (
int j = 0; j < i; j++)
1639 double xij = x(i) - x(j);
1644 for (
int i = 0; i <=
p; i++)
1651 for (
int i = 0; i <
p; i++)
1655 mfem_error(
"Poly_1D::Basis::Basis : nodes are not increasing!");
1665 auxiliary_basis =
new Basis(
1687 int i, k,
p = x.Size() - 1;
1697 for (k = 0; k <
p; k++)
1699 if (y >= (x(k) + x(k+1))/2)
1705 for (i = k+1; i <=
p; i++)
1712 l = lk * (y - x(k));
1714 for (i = 0; i < k; i++)
1716 u(i) = l * w(i) / (y - x(i));
1719 for (i++; i <=
p; i++)
1721 u(i) = l * w(i) / (y - x(i));
1729 auxiliary_basis->Eval(y, u_aux, d_aux);
1730 EvalIntegrated(d_aux,
u);
1749 int i, k,
p = x.Size() - 1;
1750 double l, lp, lk, sk, si;
1760 for (k = 0; k <
p; k++)
1762 if (y >= (x(k) + x(k+1))/2)
1768 for (i = k+1; i <=
p; i++)
1775 l = lk * (y - x(k));
1778 for (i = 0; i < k; i++)
1780 si = 1.0/(y - x(i));
1782 u(i) = l * si * w(i);
1785 for (i++; i <=
p; i++)
1787 si = 1.0/(y - x(i));
1789 u(i) = l * si * w(i);
1793 for (i = 0; i < k; i++)
1795 d(i) = (lp * w(i) -
u(i))/(y - x(i));
1798 for (i++; i <=
p; i++)
1800 d(i) = (lp * w(i) -
u(i))/(y - x(i));
1808 auxiliary_basis->Eval(y, u_aux, d_aux, d2_aux);
1809 EvalIntegrated(d_aux,
u);
1810 EvalIntegrated(d2_aux,d);
1820 "Basis::Eval with second order derivatives not implemented for" 1821 " etype = " << etype);
1834 int i, k,
p = x.Size() - 1;
1835 double l, lp, lp2, lk, sk, si, sk2;
1846 for (k = 0; k <
p; k++)
1848 if (y >= (x(k) + x(k+1))/2)
1854 for (i = k+1; i <=
p; i++)
1861 l = lk * (y - x(k));
1865 for (i = 0; i < k; i++)
1867 si = 1.0/(y - x(i));
1870 u(i) = l * si * w(i);
1873 for (i++; i <=
p; i++)
1875 si = 1.0/(y - x(i));
1878 u(i) = l * si * w(i);
1881 lp2 = lp * sk + l * sk2 + sk * lk;
1883 for (i = 0; i < k; i++)
1885 d(i) = (lp * w(i) -
u(i))/(y - x(i));
1886 d2(i) = (lp2 * w(i) - 2 * d(i))/(y - x(i));
1889 d2(k) = sk2 *
u(k) + sk * d(k);
1890 for (i++; i <=
p; i++)
1892 d(i) = (lp * w(i) -
u(i))/(y - x(i));
1893 d2(i) = (lp2 * w(i) - 2 * d(i))/(y - x(i));
1901 MFEM_ABORT(
"Integrated basis must be evaluated with EvalIntegrated");
1910 "EvalIntegrated is only valid for Integrated basis type");
1911 int p = d_aux_.
Size() - 1;
1915 for (
int j=1; j<
p; ++j)
1917 u[j] =
u[j-1] - d_aux_[j];
1922 if (scale_integrated)
1924 Vector &aux_nodes = auxiliary_basis->x;
1925 for (
int j=0; j<aux_nodes.
Size()-1; ++j)
1927 u[j] *= aux_nodes[j+1] - aux_nodes[j];
1934 scale_integrated = scale_integrated_;
1939 delete auxiliary_basis;
1947 for (
int i = 0; i <=
p; i++)
1949 binom(i,0) = binom(i,i) = 1;
1950 for (
int j = 1; j < i; j++)
1952 binom(i,j) = binom(i-1,j) + binom(i-1,j-1);
1961 for (
int i = 0; i <=
p; i++)
1964 double s = sin(M_PI_2*(i + 0.5)/(
p + 1));
1969 void Poly_1D::CalcMono(
const int p,
const double x,
double *
u)
1973 for (
int n = 1; n <=
p; n++)
1979 void Poly_1D::CalcMono(
const int p,
const double x,
double *
u,
double *d)
1984 for (
int n = 1; n <=
p; n++)
2004 for (i = 1; i <
p; i++)
2011 for (i--; i > 0; i--)
2021 double *
u,
double *d)
2032 const double xpy = x + y, ptx =
p*x;
2035 for (i = 1; i <
p; i++)
2037 d[i] =
b[i]*z*(i*xpy - ptx);
2044 for (i--; i > 0; i--)
2066 const double xpy = x + y, ptx =
p*x;
2069 for (i = 1; i <
p; i++)
2071 d[i] =
b[i]*z*(i*xpy - ptx);
2076 for (i--; i > 0; i--)
2091 if (
p == 0) {
return; }
2092 u[1] = z = 2.*x - 1.;
2093 for (
int n = 1; n <
p; n++)
2095 u[n+1] = ((2*n + 1)*z*
u[n] - n*
u[n-1])/(n + 1);
2108 if (
p == 0) {
return; }
2109 u[1] = z = 2.*x - 1.;
2111 for (
int n = 1; n <
p; n++)
2113 u[n+1] = ((2*n + 1)*z*
u[n] - n*
u[n-1])/(n + 1);
2114 d[n+1] = (4*n + 2)*
u[n] + d[n-1];
2118 void Poly_1D::CalcChebyshev(
const int p,
const double x,
double *
u)
2125 if (
p == 0) {
return; }
2126 u[1] = z = 2.*x - 1.;
2127 for (
int n = 1; n <
p; n++)
2129 u[n+1] = 2*z*
u[n] -
u[n-1];
2133 void Poly_1D::CalcChebyshev(
const int p,
const double x,
double *
u,
double *d)
2146 if (
p == 0) {
return; }
2147 u[1] = z = 2.*x - 1.;
2149 for (
int n = 1; n <
p; n++)
2151 u[n+1] = 2*z*
u[n] -
u[n-1];
2152 d[n+1] = (n + 1)*(z*d[n]/n + 2*
u[n]);
2156 void Poly_1D::CalcChebyshev(
const int p,
const double x,
double *
u,
double *d,
2172 if (
p == 0) {
return; }
2173 u[1] = z = 2.*x - 1.;
2176 for (
int n = 1; n <
p; n++)
2178 u[n+1] = 2*z*
u[n] -
u[n-1];
2179 d[n+1] = (n + 1)*(z*d[n]/n + 2*
u[n]);
2180 dd[n+1] = (n + 1)*(2.*(n + 1)*d[n] + z*dd[n])/n;
2191 if (points_container.find(btype) == points_container.end())
2196 if (
pts.Size() <=
p)
2198 pts.SetSize(
p + 1, NULL);
2202 pts[
p] =
new double[
p + 1];
2212 if ( bases_container.find(btype) == bases_container.end() )
2218 if (bases.
Size() <=
p)
2222 if (bases[
p] == NULL)
2235 for (PointsMap::iterator it = points_container.begin();
2236 it != points_container.end() ; ++it)
2239 for (
int i = 0 ; i <
pts.Size() ; ++i )
2246 for (BasisMap::iterator it = bases_container.begin();
2247 it != bases_container.end() ; ++it)
2250 for (
int i = 0 ; i < bases.
Size() ; ++i )
2273 for (
int i = 1; i <
p; i++)
2281 const int p1 =
p + 1;
2292 for (
int i = 1; i <
p; i++)
2296 for (
int i = 1; i <
p; i++)
2300 for (
int i = 1; i <
p; i++)
2304 for (
int i = 1; i <
p; i++)
2310 for (
int j = 1; j <
p; j++)
2312 for (
int i = 1; i <
p; i++)
2321 const int p1 =
p + 1;
2325 dof_map[0 + (0 + 0*p1)*p1] = 0;
2337 for (
int i = 1; i <
p; i++)
2339 dof_map[i + (0 + 0*p1)*p1] = o++;
2341 for (
int i = 1; i <
p; i++)
2345 for (
int i = 1; i <
p; i++)
2349 for (
int i = 1; i <
p; i++)
2351 dof_map[0 + (i + 0*p1)*p1] = o++;
2353 for (
int i = 1; i <
p; i++)
2357 for (
int i = 1; i <
p; i++)
2361 for (
int i = 1; i <
p; i++)
2365 for (
int i = 1; i <
p; i++)
2369 for (
int i = 1; i <
p; i++)
2371 dof_map[0 + (0 + i*p1)*p1] = o++;
2373 for (
int i = 1; i <
p; i++)
2377 for (
int i = 1; i <
p; i++)
2381 for (
int i = 1; i <
p; i++)
2387 for (
int j = 1; j <
p; j++)
2389 for (
int i = 1; i <
p; i++)
2391 dof_map[i + ((
p-j) + 0*p1)*p1] = o++;
2394 for (
int j = 1; j <
p; j++)
2396 for (
int i = 1; i <
p; i++)
2398 dof_map[i + (0 + j*p1)*p1] = o++;
2401 for (
int j = 1; j <
p; j++)
2403 for (
int i = 1; i <
p; i++)
2408 for (
int j = 1; j <
p; j++)
2410 for (
int i = 1; i <
p; i++)
2415 for (
int j = 1; j <
p; j++)
2417 for (
int i = 1; i <
p; i++)
2419 dof_map[0 + ((
p-i) + j*p1)*p1] = o++;
2422 for (
int j = 1; j <
p; j++)
2424 for (
int i = 1; i <
p; i++)
2431 for (
int k = 1; k <
p; k++)
2433 for (
int j = 1; j <
p; j++)
2435 for (
int i = 1; i <
p; i++)
2437 dof_map[i + (j + k*p1)*p1] = o++;
2444 MFEM_ABORT(
"invalid dimension: " << dims);
2455 MFEM_ABORT(
"invalid DofMapType: " << dmtype);
2466 for (
int i = 0; i < dof2quad_array.
Size(); i++)
2468 const DofToQuad &d2q = *dof2quad_array[i];
2469 if (d2q.
IntRule == &ir && d2q.
mode == mode) {
return d2q; }
2484 Vector val(ndof), grad(ndof);
2485 for (
int i = 0; i < nqpt; i++)
2490 for (
int j = 0; j < ndof; j++)
2492 d2q->
B[i+nqpt*j] = d2q->
Bt[j+ndof*i] = val(j);
2493 d2q->
G[i+nqpt*j] = d2q->
Gt[j+ndof*i] = grad(j);
2496 dof2quad_array.
Append(d2q);
2527 internal::GetTensorFaceMap(
dim,
order, face_id, face_map);
2540 obasis1d(
poly1d.GetBasis(
p - 1, VerifyOpen(obtype)))
2542 MFEM_VERIFY(dims > 1,
"Constructor for VectorTensorFiniteElement with both " 2543 "open and closed bases is not valid for 1D elements.");
2555 obasis1d(
poly1d.GetBasis(
p, VerifyOpen(obtype)))
2557 MFEM_VERIFY(dims == 1,
"Constructor for VectorTensorFiniteElement without " 2558 "closed basis is only valid for 1D elements.");
2563 for (
int i = 0; i < dof2quad_array_open.Size(); i++)
2565 delete dof2quad_array_open[i];
Abstract class for all finite elements.
int GetHeight() const
Get the height of the matrix.
void Set(const double *p, const int dim)
void MultABt(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt)
Multiply a matrix A with the transpose of a matrix B: A*Bt.
virtual void CalcPhysLinLaplacian(ElementTransformation &Trans, Vector &Laplacian) const
void trans(const Vector &u, Vector &x)
int GetNPoints() const
Returns the number of the points in the integration rule.
bool IsIntegratedType() const
Returns true if the basis is "integrated", false otherwise.
const class FiniteElement * FE
The FiniteElement that created and owns this object.
Array< int > lex_ordering
Class for an integration rule - an Array of IntegrationPoint.
static int Check(int b_type)
If the input does not represents a valid BasisType, abort with an error; otherwise return the input...
EvalType
One-dimensional basis evaluation type.
void ScaleIntegrated(bool scale_integrated_)
Set whether the "integrated" basis should be scaled by the subcell sizes. Has no effect for non-integ...
NodalTensorFiniteElement(const int dims, const int p, const int btype, const DofMapType dmtype)
virtual void ProjectFromNodes(Vector &vc, ElementTransformation &Trans, Vector &dofs) const
Given a vector of values at the finite element nodes and a transformation, compute its projection (ap...
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
Basis(const int p, const double *nodes, EvalType etype=Barycentric)
Create a nodal or positive (Bernstein) basis of degree p.
void LocalL2Projection_RT(const VectorFiniteElement &cfe, ElementTransformation &Trans, DenseMatrix &I) const
Tensor product representation using 1D matrices/tensors with dimensions using 1D number of quadrature...
Base class for vector Coefficients that optionally depend on time and space.
void SetRow(int r, const double *row)
void InvRightScaling(const Vector &s)
InvRightScaling: this = this * diag(1./s);.
virtual void CalcCurlShape(const IntegrationPoint &ip, DenseMatrix &curl_shape) const
Evaluate the curl of all shape functions of a vector finite element in reference space at the given p...
void ProjectMatrixCoefficient_RT(const double *nk, const Array< int > &d2n, MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const
Project the rows of the matrix coefficient in an RT space.
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the vector coefficient in the element described by T at the point ip, storing the result in ...
void ProjectGrad_RT(const double *nk, const Array< int > &d2n, const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &grad) const
static void GivePolyPoints(const int np, double *pts, const int type)
void Mult(const double *x, double *y) const
Matrix vector multiplication with the inverse of dense matrix.
void SetSize(int s)
Resize the vector to size s.
void ProjectGrad(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &grad) const override
Compute the discrete gradient matrix from the given FiniteElement onto 'this' FiniteElement. The ElementTransformation is included to support cases when the matrix depends on it.
virtual void CalcHessian(const IntegrationPoint &ip, DenseMatrix &Hessian) const
Evaluate the Hessians of all shape functions of a scalar finite element in reference space at the giv...
virtual void GetLocalInterpolation(ElementTransformation &Trans, DenseMatrix &I) const
Return the local interpolation matrix I (Dof x Dof) where the fine element is the image of the base g...
FiniteElement(int D, Geometry::Type G, int Do, int O, int F=FunctionSpace::Pk)
Construct FiniteElement with given.
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
virtual void Eval(DenseMatrix &K, ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the matrix coefficient in the element described by T at the point ip, storing the result in ...
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
int dim
Dimension of reference space.
TensorBasisElement(const int dims, const int p, const int btype, const DofMapType dmtype)
virtual void CalcPhysLaplacian(ElementTransformation &Trans, Vector &Laplacian) const
Evaluate the Laplacian of all shape functions of a scalar finite element in reference space at the gi...
int Size() const
Returns the size of the vector.
int nqpt
Number of quadrature points. When mode is TENSOR, this is the 1D number.
Data type dense matrix using column-major storage.
Array< double > Gt
Transpose of G.
double * Data() const
Returns the matrix data array.
int ndof
Number of degrees of freedom = number of basis functions. When mode is TENSOR, this is the 1D number...
virtual ~VectorTensorFiniteElement()
void Eval(const double x, Vector &u) const
Evaluate the basis functions at point x in [0,1].
static int GetQuadrature1D(int b_type)
Get the corresponding Quadrature1D constant, when that makes sense; otherwise return Quadrature1D::In...
VectorFiniteElement(int D, Geometry::Type G, int Do, int O, int M, int F=FunctionSpace::Pk)
void CalcVShape_RT(ElementTransformation &Trans, DenseMatrix &shape) const
static const DofToQuad & GetTensorDofToQuad(const FiniteElement &fe, const IntegrationRule &ir, DofToQuad::Mode mode, const Poly_1D::Basis &basis, bool closed, Array< DofToQuad *> &dof2quad_array)
void Factor()
Factor the current DenseMatrix, *a.
Geometry::Type geom_type
Geometry::Type of the reference element.
Intermediate class for finite elements whose basis functions return vector values.
static void CalcLegendre(const int p, const double x, double *u)
const IntegrationPoint & GetCenter(int GeomType)
Return the center of the given Geometry::Type, GeomType.
void ProjectCurl_ND(const double *tk, const Array< int > &d2t, const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
Use change of basis, O(p^2) Evals.
int GetWidth() const
Get the width of the matrix.
void ProjectMatrixCoefficient_ND(const double *tk, const Array< int > &d2t, MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const
Project the rows of the matrix coefficient in an ND space.
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
int cdim
Dimension of curl for vector-valued basis functions.
int vdim
Vector dimension of vector-valued basis functions.
static void CalcBasis(const int p, const double x, double *u)
Evaluate the values of a hierarchical 1D basis at point x hierarchical = k-th basis function is degre...
static void CalcBinomTerms(const int p, const double x, const double y, double *u)
Compute the p terms in the expansion of the binomial (x + y)^p and store them in the already allocate...
const double * GetPoints(const int p, const int btype)
Get the coordinates of the points of the given BasisType, btype.
virtual void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const
Given a coefficient and a transformation, compute its projection (approximation) in the local finite ...
Class for standard nodal finite elements.
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
VectorTensorFiniteElement(const int dims, const int d, const int p, const int cbtype, const int obtype, const int M, const DofMapType dmtype)
virtual const DofToQuad & GetDofToQuad(const IntegrationRule &ir, DofToQuad::Mode mode) const
Return a DofToQuad structure corresponding to the given IntegrationRule using the given DofToQuad::Mo...
Class for finite elements with basis functions that return scalar values.
void SetSize(int m, int n)
void ProjectMatrixCoefficient(MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const override
Given a matrix coefficient and a transformation, compute an approximation ("projection") in the local...
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
virtual void SetMapType(int M)
Set the FiniteElement::MapType of the element to either VALUE or INTEGRAL. Also sets the FiniteElemen...
void LocalRestriction_ND(const double *tk, const Array< int > &d2t, ElementTransformation &Trans, DenseMatrix &R) const
virtual void GetFaceDofs(int face, int **dofs, int *ndofs) const
Get the dofs associated with the given face. *dofs is set to an internal array of the local dofc on t...
double * GetData() const
Returns the matrix data array.
void GetLocalRestriction(ElementTransformation &Trans, DenseMatrix &R) const override
Return a local restriction matrix R (Dof x Dof) mapping fine dofs to coarse dofs. ...
int Append(const T &el)
Append element 'el' to array, resize if necessary.
void MultTranspose(const double *x, double *y) const
Multiply a vector with the transpose matrix.
Fast evaluation of Bernstein polynomials.
void mfem_error(const char *msg)
Function called when an error is encountered. Used by the macros MFEM_ABORT, MFEM_ASSERT, MFEM_VERIFY.
static void ChebyshevPoints(const int p, double *x)
Compute the points for the Chebyshev polynomials of order p and place them in the already allocated x...
void AddMult_a_VWt(const double a, const Vector &v, const Vector &w, DenseMatrix &VWt)
VWt += a * v w^t.
virtual void ProjectDelta(int vertex, Vector &dofs) const
Project a delta function centered on the given vertex in the local finite dimensional space represent...
double InnerProduct(const double *x, const double *y) const
Compute y^t A x.
Mode mode
Describes the contents of the B, Bt, G, and Gt arrays, see Mode.
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const =0
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
void ProjectCurl_2D(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
void LocalL2Projection_ND(const VectorFiniteElement &cfe, ElementTransformation &Trans, DenseMatrix &I) const
void Get(double *p, const int dim) const
void Invert()
Replaces the current matrix with its inverse.
virtual void CalcPhysCurlShape(ElementTransformation &Trans, DenseMatrix &curl_shape) const
Evaluate the curl of all shape functions of a vector finite element in physical space at the point de...
void AddMult_a_VVt(const double a, const Vector &v, DenseMatrix &VVt)
VVt += a * v v^t.
int orders[Geometry::MaxDim]
Anisotropic orders.
void GetColumn(int c, Vector &col) const
virtual void ProjectGrad(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &grad) const
Compute the discrete gradient matrix from the given FiniteElement onto 'this' FiniteElement. The ElementTransformation is included to support cases when the matrix depends on it.
virtual ~FiniteElement()
Deconstruct the FiniteElement.
double FNorm2() const
Compute the square of the Frobenius norm of the matrix.
Use barycentric Lagrangian interpolation, O(p) Evals.
virtual void GetTransferMatrix(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &I) const
Return interpolation matrix, I, which maps dofs from a coarse element, fe, to the fine dofs on this f...
int GetVDim()
Returns dimension of the vector.
void CalcPhysDivShape(ElementTransformation &Trans, Vector &divshape) const
Evaluate the divergence of all shape functions of a vector finite element in physical space at the po...
void Mult(const double *x, double *y) const
Matrix vector multiplication.
Basis & GetBasis(const int p, const int btype)
Get a Poly_1D::Basis object of the given degree and BasisType, btype.
virtual void ProjectCurl(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
Compute the discrete curl matrix from the given FiniteElement onto 'this' FiniteElement. The ElementTransformation is included to support cases when the matrix depends on it.
void CalcPhysDShape(ElementTransformation &Trans, DenseMatrix &dshape) const
Evaluate the gradients of all shape functions of a scalar finite element in physical space at the poi...
virtual void ProjectDiv(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &div) const
Compute the discrete divergence matrix from the given FiniteElement onto 'this' FiniteElement. The ElementTransformation is included to support cases when the matrix depends on it.
void EvalIntegrated(const Vector &d, Vector &i) const
Evaluate the "integrated" basis type using pre-computed closed basis derivatives. ...
double * GetData() const
Return a pointer to the beginning of the Vector data.
void Threshold(double eps)
Replace small entries, abs(a_ij) <= eps, with zero.
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
void Set3(const double x1, const double x2, const double x3)
void LocalInterpolation_RT(const VectorFiniteElement &cfe, const double *nk, const Array< int > &d2n, ElementTransformation &Trans, DenseMatrix &I) const
Array< double > Bt
Transpose of B.
virtual void ProjectMatrixCoefficient(MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const
Given a matrix coefficient and a transformation, compute an approximation ("projection") in the local...
double p(const Vector &x, double t)
Integrated indicator functions (cf. Gerritsma)
int GetDim() const
Returns the reference space dimension for the finite element.
ComplexDenseMatrix * MultAtB(const ComplexDenseMatrix &A, const ComplexDenseMatrix &B)
Multiply the complex conjugate transpose of a matrix A with a matrix B. A^H*B.
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
void Project_RT(const double *nk, const Array< int > &d2n, VectorCoefficient &vc, ElementTransformation &Trans, Vector &dofs) const
Project a vector coefficient onto the RT basis functions.
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
void LocalInterpolation_ND(const VectorFiniteElement &cfe, const double *tk, const Array< int > &d2t, ElementTransformation &Trans, DenseMatrix &I) const
Base class for Matrix Coefficients that optionally depend on time and space.
void ScalarLocalInterpolation(ElementTransformation &Trans, DenseMatrix &I, const ScalarFiniteElement &fine_fe) const
Get matrix I "Interpolation" defined through local L2-projection in the space defined by the fine_fe...
void MultAAt(const DenseMatrix &a, DenseMatrix &aat)
Calculate the matrix A.At.
static const int * Binom(const int p)
Get a pointer to an array containing the binomial coefficients "p choose k" for k=0,...,p for the given p.
void GetColumnReference(int c, Vector &col)
int GetDof() const
Returns the number of degrees of freedom in the finite element.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
Structure representing the matrices/tensors needed to evaluate (in reference space) the values...
void SetDataAndSize(double *d, int s)
Set the Vector data and size.
void SetMapType(const int map_type_) override
Set the FiniteElement::MapType of the element to either VALUE or INTEGRAL. Also sets the FiniteElemen...
Integrated GLL indicator functions.
Array< double > B
Basis functions evaluated at quadrature points.
void CalcPhysShape(ElementTransformation &Trans, Vector &shape) const
Evaluate the values of all shape functions of a scalar finite element in physical space at the point ...
Class for integration point with weight.
Mode
Type of data stored in the arrays B, Bt, G, and Gt.
Full multidimensional representation which does not use tensor product structure. The ordering of the...
void ProjectDiv(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &div) const override
Compute the discrete divergence matrix from the given FiniteElement onto 'this' FiniteElement. The ElementTransformation is included to support cases when the matrix depends on it.
void ProjectCurl_RT(const double *nk, const Array< int > &d2n, const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
int dof
Number of degrees of freedom.
int GetVDim() const
Returns the vector dimension for vector-valued finite elements.
Array< DofToQuad * > dof2quad_array
Container for all DofToQuad objects created by the FiniteElement.
Implements CalcDivShape methods.
Array< double > G
Gradients/divergences/curls of basis functions evaluated at quadrature points.
virtual void CalcVShape(const IntegrationPoint &ip, DenseMatrix &shape) const
Evaluate the values of all shape functions of a vector finite element in reference space at the given...
void GetFaceMap(const int face_id, Array< int > &face_map) const override
Return the mapping from lexicographic face DOFs to lexicographic element DOFs for the given local fac...
Class for evaluating 1D nodal, positive (Bernstein), or integrated (Gerritsma) bases.
int GetMapType() const
Returns the FiniteElement::MapType of the element describing how reference functions are mapped to ph...
double infinity()
Define a shortcut for std::numeric_limits<double>::infinity()
int Size() const
Return the logical size of the array.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the coefficient in the element described by T at the point ip.
void InvertLinearTrans(ElementTransformation &trans, const IntegrationPoint &pt, Vector &x)
virtual void GetFaceMap(const int face_id, Array< int > &face_map) const
Return the mapping from lexicographic face DOFs to lexicographic element DOFs for the given local fac...
static void CalcBernstein(const int p, const double x, double *u)
Compute the values of the Bernstein basis functions of order p at coordinate x and store the results ...
void CalcVShape_ND(ElementTransformation &Trans, DenseMatrix &shape) const
void LocalRestriction_RT(const double *nk, const Array< int > &d2n, ElementTransformation &Trans, DenseMatrix &R) const
int GetRangeType() const
Returns the FiniteElement::RangeType of the element, one of {SCALAR, VECTOR}.
static bool CheckPoint(int GeomType, const IntegrationPoint &ip)
Check if the given point is inside the given reference element.
Describes the function space on each element.
void pts(int iphi, int t, double x[])
void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const override
Given a coefficient and a transformation, compute its projection (approximation) in the local finite ...
double u(const Vector &xvec)
Implements CalcDShape methods.
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
virtual void CalcPhysHessian(ElementTransformation &Trans, DenseMatrix &Hessian) const
Evaluate the Hessian of all shape functions of a scalar finite element in reference space at the give...
virtual void GetLocalRestriction(ElementTransformation &Trans, DenseMatrix &R) const
Return a local restriction matrix R (Dof x Dof) mapping fine dofs to coarse dofs. ...
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const =0
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
void Project_ND(const double *tk, const Array< int > &d2t, VectorCoefficient &vc, ElementTransformation &Trans, Vector &dofs) const
Project a vector coefficient onto the ND basis functions.
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
void ScalarLocalL2Restriction(ElementTransformation &Trans, DenseMatrix &R, const ScalarFiniteElement &coarse_fe) const
Get restriction matrix R defined through local L2-projection in the space defined by the coarse_fe...
void AddMult_a_AAt(double a, const DenseMatrix &A, DenseMatrix &AAt)
AAt += a * A * A^t.
static void CalcDBinomTerms(const int p, const double x, const double y, double *d)
Compute the derivatives (w.r.t. x) of the terms in the expansion of the binomial (x + y)^p assuming t...
const IntegrationRule * IntRule
IntegrationRule that defines the quadrature points at which the basis functions of the FE are evaluat...
virtual void CalcDivShape(const IntegrationPoint &ip, Vector &divshape) const
Evaluate the divergence of all shape functions of a vector finite element in reference space at the g...
void ProjectGrad_ND(const double *tk, const Array< int > &d2t, const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &grad) const
int order
Order/degree of the shape functions.
No derivatives implemented.
Implements CalcCurlShape methods.
void NodalLocalInterpolation(ElementTransformation &Trans, DenseMatrix &I, const ScalarFiniteElement &fine_fe) const
Get the matrix I that defines nodal interpolation between this element and the refined element fine_f...