15 #include "../coefficient.hpp" 34 #ifndef MFEM_THREAD_SAFE 42 MFEM_ABORT(
"method is not implemented for this class");
48 MFEM_ABORT(
"method is not implemented for this class");
54 MFEM_ABORT(
"method is not implemented for this class");
61 div_shape *= (1.0 /
Trans.Weight());
67 MFEM_ABORT(
"method is not implemented for this class");
77 #ifdef MFEM_THREAD_SAFE 82 curl_shape *= (1.0 /
Trans.Weight());
88 curl_shape *= (1.0 /
Trans.Weight());
91 MFEM_ABORT(
"Invalid dimension, Dim = " <<
dim);
97 MFEM_ABORT(
"method is not overloaded");
103 MFEM_ABORT(
"method is not overloaded");
109 MFEM_ABORT(
"method is not overloaded");
115 MFEM_ABORT(
"method is not overloaded");
122 MFEM_ABORT(
"method is not overloaded");
128 MFEM_ABORT(
"method is not overloaded");
134 MFEM_ABORT(
"method is not overloaded");
140 mfem_error(
"FiniteElement::ProjectFromNodes() (vector) is not overloaded!");
146 MFEM_ABORT(
"method is not overloaded");
151 MFEM_ABORT(
"method is not implemented for this element");
157 MFEM_ABORT(
"method is not implemented for this element");
164 MFEM_ABORT(
"method is not implemented for this element");
171 MFEM_ABORT(
"method is not implemented for this element");
178 MFEM_ABORT(
"method is not implemented for this element");
187 shape /=
Trans.Weight();
195 #ifdef MFEM_THREAD_SAFE 208 if (
Trans.Hessian().FNorm2() < 1e-20)
215 int size = (
dim*(
dim+1))/2;
221 for (
int nd = 0; nd <
dof; nd++)
223 Laplacian[nd] = hess(nd,0) + hess(nd,4) + hess(nd,5);
228 for (
int nd = 0; nd <
dof; nd++)
230 Laplacian[nd] = hess(nd,0) + hess(nd,2);
235 for (
int nd = 0; nd <
dof; nd++)
237 Laplacian[nd] = hess(nd,0);
247 int size = (
dim*(
dim+1))/2;
258 scale[1] = 2*Gij(0,1);
259 scale[2] = 2*Gij(0,2);
261 scale[3] = 2*Gij(1,2);
269 scale[1] = 2*Gij(0,1);
277 for (
int nd = 0; nd <
dof; nd++)
280 for (
int ii = 0; ii < size; ii++)
282 Laplacian[nd] += hess(nd,ii)*scale[ii];
322 int size = (
dim*(
dim+1))/2;
327 if (
Trans.Hessian().FNorm2() > 1e-10)
340 for (
int i = 0; i <
dim; i++)
342 for (
int j = 0; j <
dim; j++)
344 for (
int k = 0; k <
dim; k++)
346 for (
int l = 0; l <
dim; l++)
348 lhm(map[i*
dim+j],map[k*
dim+l]) += invJ(i,k)*invJ(j,l);
356 for (
int i = 0; i <
dim*
dim; i++) { mult[map[i]]++; }
361 Mult( hess, lhm, Hessian);
372 if (d2q.
IntRule == &ir && d2q.
mode == mode) {
return d2q; }
375 #ifdef MFEM_THREAD_SAFE 393 for (
int i = 0; i < nqpt; i++)
397 for (
int j = 0; j <
dof; j++)
399 d2q->
B[i+nqpt*j] = d2q->
Bt[j+
dof*i] = shape(j);
408 for (
int i = 0; i < nqpt; i++)
412 for (
int d = 0; d <
dim; d++)
414 for (
int j = 0; j <
dof; j++)
428 for (
int i = 0; i < nqpt; i++)
432 for (
int d = 0; d <
dim; d++)
434 for (
int j = 0; j <
dof; j++)
449 for (
int i = 0; i < nqpt; i++)
453 for (
int j = 0; j <
dof; j++)
455 d2q->
G[i+nqpt*j] = d2q->
Gt[j+
dof*i] = divshape(j);
466 for (
int i = 0; i < nqpt; i++)
470 for (
int d = 0; d <
cdim; d++)
472 for (
int j = 0; j <
dof; j++)
474 d2q->
G[i+nqpt*(d+
dim*j)] = d2q->
Gt[j+
dof*(i+nqpt*d)] = curlshape(j, d);
482 MFEM_ABORT(
"invalid finite element derivative type");
505 #ifdef MFEM_THREAD_SAFE 515 for (
int i = 0; i < fine_fe.
dof; i++)
520 for (
int j = 0; j <
dof; j++)
522 if (fabs(I(i,j) = shape(j)) < 1.0e-12)
548 Vector fine_shape(fs), coarse_shape(cs);
549 DenseMatrix fine_mass(fs), fine_coarse_mass(fs, cs);
558 Trans.Transform(ip, vv);
567 fine_mass_inv.
Mult(fine_coarse_mass, I);
587 Vector fine_shape(fs), coarse_shape(cs);
588 DenseMatrix coarse_mass(cs), coarse_fine_mass(cs, fs);
606 Trans.Transform(f_ip, vv);
616 coarse_mass_inv.
Mult(coarse_fine_mass, R);
622 R *= 1.0 /
Trans.Weight();
633 for (
int i = 0; i <
dof; i++)
643 for (
int j = 0; j < fe.
GetDof(); j++)
645 curl(i,j) = w * curl_shape(j,0);
656 trans.Transform(p0, x);
663 trans.InverseJacobian().Mult(v, x);
672 #ifdef MFEM_THREAD_SAFE 681 for (
int j = 0; j <
dof; j++)
701 for (
int i = 0; i <
dof; i++)
706 Trans.SetIntPoint(&ip);
710 dofs(i) *=
Trans.Weight();
721 for (
int i = 0; i <
dof; i++)
724 Trans.SetIntPoint(&ip);
730 for (
int j = 0; j < x.Size(); j++)
732 dofs(
dof*j+i) = x(j);
744 for (
int k = 0; k <
dof; k++)
749 for (
int r = 0; r < MQ.Height(); r++)
751 for (
int d = 0; d < MQ.Width(); d++)
753 dofs(k+
dof*(d+MQ.Width()*r)) = MQ(r,d);
769 for (
int k = 0; k <
dof; k++)
772 for (
int j = 0; j < shape.Size(); j++)
774 I(k,j) = (fabs(shape(j)) < 1e-12) ? 0.0 : shape(j);
780 for (
int k = 0; k <
dof; k++)
786 shape *=
Trans.Weight();
788 for (
int j = 0; j < shape.Size(); j++)
790 I(k,j) = (fabs(shape(j)) < 1e-12) ? 0.0 : shape(j);
801 for (
int k = 0; k <
dof; k++)
823 MFEM_ASSERT(
Trans.GetSpaceDim() ==
dim,
"")
828 for (
int k = 0; k <
dof; k++)
832 Trans.SetIntPoint(&ip);
834 Mult(dshape, Jinv, grad_k);
837 grad_k *=
Trans.Weight();
839 for (
int j = 0; j < grad_k.Height(); j++)
840 for (
int d = 0; d <
dim; d++)
842 grad(k+d*
dof,j) = grad_k(j,d);
855 for (
int k = 0; k <
dof; k++)
861 Trans.SetIntPoint(&ip);
862 detJ =
Trans.Weight();
863 for (
int j = 0; j < div_shape.Size(); j++)
865 div(k,j) = (fabs(div_shape(j)) < 1e-12) ? 0.0 : div_shape(j)/detJ;
870 for (
int j = 0; j < div_shape.Size(); j++)
872 div(k,j) = (fabs(div_shape(j)) < 1e-12) ? 0.0 : div_shape(j);
880 int Do,
int O,
int M,
int F)
894 void VectorFiniteElement::CalcShape(
897 mfem_error(
"Error: Cannot use scalar CalcShape(...) function with\n" 898 " VectorFiniteElements!");
901 void VectorFiniteElement::CalcDShape(
902 const IntegrationPoint &ip, DenseMatrix &dshape )
const 904 mfem_error(
"Error: Cannot use scalar CalcDShape(...) function with\n" 905 " VectorFiniteElements!");
937 MFEM_ABORT(
"Invalid dimension, Dim = " <<
dim);
941 MFEM_ABORT(
"Invalid MapType = " <<
map_type);
949 #ifdef MFEM_THREAD_SAFE 954 shape *= (1.0 /
Trans.Weight());
961 #ifdef MFEM_THREAD_SAFE 973 const int sdim =
Trans.GetSpaceDim();
974 MFEM_ASSERT(vc.
GetVDim() == sdim,
"");
976 const bool square_J = (
dim == sdim);
978 for (
int k = 0; k <
dof; k++)
983 dofs(k) =
Trans.AdjugateJacobian().InnerProduct(vk, nk + d2n[k]*
dim);
984 if (!square_J) { dofs(k) /=
Trans.Weight(); }
992 const int sdim =
Trans.GetSpaceDim();
993 const bool square_J = (
dim == sdim);
995 for (
int k = 0; k <
dof; k++)
999 dofs(k) =
Trans.AdjugateJacobian().InnerProduct(
1000 &vc[k*sdim], nk + d2n[k]*
dim);
1001 if (!square_J) { dofs(k) /=
Trans.Weight(); }
1011 const int sdim = T.GetSpaceDim();
1012 MFEM_ASSERT(mc.
GetWidth() == sdim,
"");
1013 const bool square_J = (
dim == sdim);
1015 Vector nk_phys(sdim), dofs_k(MQ.Height());
1016 MFEM_ASSERT(dofs.
Size() ==
dof*MQ.Height(),
"");
1018 for (
int k = 0; k <
dof; k++)
1023 T.AdjugateJacobian().MultTranspose(nk + d2n[k]*
dim, nk_phys);
1024 if (!square_J) { nk_phys /= T.Weight(); }
1025 MQ.Mult(nk_phys, dofs_k);
1026 for (
int r = 0; r < MQ.Height(); r++)
1028 dofs(k+
dof*r) = dofs_k(r);
1041 int sdim =
Trans.GetSpaceDim();
1044 for (
int k = 0; k <
dof; k++)
1049 Trans.SetIntPoint(&ip);
1052 Trans.AdjugateJacobian().MultTranspose(nk + d2n[k]*
dim, vk);
1055 double w = 1.0/
Trans.Weight();
1056 for (
int d = 0; d <
dim; d++)
1062 for (
int j = 0; j < shape.Size(); j++)
1064 double s = shape(j);
1065 if (fabs(
s) < 1e-12)
1071 for (
int d = 0; d < sdim; d++)
1073 I(k,j+d*shape.Size()) =
s*vk[d];
1080 int sdim =
Trans.GetSpaceDim();
1084 const bool square_J = (
dim == sdim);
1087 for (
int k = 0; k <
dof; k++)
1091 Trans.SetIntPoint(&ip);
1094 Trans.AdjugateJacobian().MultTranspose(nk + d2n[k]*
dim, vk);
1099 if (!square_J) { vshapenk /=
Trans.Weight(); }
1100 for (
int j=0; j<vshapenk.Size(); j++)
1102 I(k,j) = vshapenk(j);
1114 mfem_error(
"VectorFiniteElement::ProjectGrad_RT works only in 2D!");
1122 for (
int k = 0; k <
dof; k++)
1125 tk[0] = nk[d2n[k]*
dim+1];
1126 tk[1] = -nk[d2n[k]*
dim];
1127 dshape.Mult(tk, grad_k);
1128 for (
int j = 0; j < grad_k.Size(); j++)
1130 grad(k,j) = (fabs(grad_k(j)) < 1e-12) ? 0.0 : grad_k(j);
1139 #ifdef MFEM_THREAD_SAFE 1152 for (
int k = 0; k <
dof; k++)
1157 Trans.SetIntPoint(&ip);
1166 for (
int j = 0; j < curl_k.Size(); j++)
1168 curl(k,j) = (fabs(curl_k(j)) < 1e-12) ? 0.0 : curl_k(j);
1181 for (
int k = 0; k <
dof; k++)
1184 curl_shape.Mult(nk + d2n[k]*
dim, curl_k);
1185 for (
int j = 0; j < curl_k.Size(); j++)
1187 curl(k,j) = (fabs(curl_k(j)) < 1e-12) ? 0.0 : curl_k(j);
1199 for (
int k = 0; k <
dof; k++)
1205 dofs(k) =
Trans.Jacobian().InnerProduct(tk + d2t[k]*
dim, vk);
1213 for (
int k = 0; k <
dof; k++)
1217 dofs(k) =
Trans.Jacobian().InnerProduct(tk + d2t[k]*
dim, &vc[k*
dim]);
1227 const int sdim = T.GetSpaceDim();
1228 MFEM_ASSERT(mc.
GetWidth() == sdim,
"");
1230 Vector tk_phys(sdim), dofs_k(MQ.Height());
1231 MFEM_ASSERT(dofs.
Size() ==
dof*MQ.Height(),
"");
1233 for (
int k = 0; k <
dof; k++)
1238 T.Jacobian().Mult(tk + d2t[k]*
dim, tk_phys);
1239 MQ.Mult(tk_phys, dofs_k);
1240 for (
int r = 0; r < MQ.Height(); r++)
1242 dofs(k+
dof*r) = dofs_k(r);
1253 int sdim =
Trans.GetSpaceDim();
1258 for (
int k = 0; k <
dof; k++)
1263 Trans.SetIntPoint(&ip);
1266 Trans.Jacobian().Mult(tk + d2t[k]*
dim, vk);
1269 double w = 1.0/
Trans.Weight();
1270 for (
int d = 0; d < sdim; d++)
1276 for (
int j = 0; j < shape.Size(); j++)
1278 double s = shape(j);
1279 if (fabs(
s) < 1e-12)
1285 for (
int d = 0; d < sdim; d++)
1287 I(k, j + d*shape.Size()) =
s*vk[d];
1294 int sdim =
Trans.GetSpaceDim();
1300 for (
int k = 0; k <
dof; k++)
1304 Trans.SetIntPoint(&ip);
1307 Trans.Jacobian().Mult(tk + d2t[k]*
dim, vk);
1312 for (
int j=0; j<vshapetk.Size(); j++)
1314 I(k, j) = vshapetk(j);
1330 for (
int k = 0; k <
dof; k++)
1333 dshape.Mult(tk + d2t[k]*
dim, grad_k);
1334 for (
int j = 0; j < grad_k.Size(); j++)
1336 grad(k,j) = (fabs(grad_k(j)) < 1e-12) ? 0.0 : grad_k(j);
1351 DenseMatrix fine_mass(fs), fine_coarse_mass(fs, cs);
1352 const int ir_order =
1363 Trans.Transform(ip, v);
1368 for (
int k=0; k<fs; ++k)
1370 for (
int j=0; j<cs; ++j)
1373 for (
int d1=0; d1<
dim; ++d1)
1375 for (
int d2=0; d2<
dim; ++d2)
1377 Mkj += w*fine_shape(k,d1)*adjJ(d2,d1)*coarse_shape(j,d2);
1380 fine_coarse_mass(k,j) += (fabs(Mkj) < 1e-12) ? 0.0 : Mkj;
1385 fine_mass_inv.
Mult(fine_coarse_mass, I);
1399 #ifdef MFEM_THREAD_SAFE 1409 for (
int k = 0; k <
dof; k++)
1420 for (
int i = 0; i <
dim; i++)
1422 Ikj +=
vshape(j, i) * vk[i];
1424 I(k, j) = (fabs(Ikj) < 1e-12) ? 0.0 : Ikj;
1439 DenseMatrix fine_mass(fs), fine_coarse_mass(fs, cs);
1440 const int ir_order =
1450 Trans.Transform(ip, v);
1455 for (
int k=0; k<fs; ++k)
1457 for (
int j=0; j<cs; ++j)
1460 for (
int d1=0; d1<
dim; ++d1)
1462 for (
int d2=0; d2<
dim; ++d2)
1464 Mkj += ip.
weight*fine_shape(k,d1)*J(d1,d2)*coarse_shape(j,d2);
1467 fine_coarse_mass(k,j) += (fabs(Mkj) < 1e-12) ? 0.0 : Mkj;
1472 fine_mass_inv.
Mult(fine_coarse_mass, I);
1484 #ifdef MFEM_THREAD_SAFE 1494 for (
int k = 0; k <
dof; k++)
1505 for (
int i = 0; i <
dim; i++)
1507 Ikj +=
vshape(j, i) * vk[i];
1509 I(k, j) = (fabs(Ikj) < 1e-12) ? 0.0 : Ikj;
1522 #ifdef MFEM_THREAD_SAFE 1528 const double weight =
Trans.Weight();
1529 for (
int j = 0; j <
dof; j++)
1538 for (
int k = 0; k <
dof; k++)
1541 for (
int d = 0; d <
dim; d++)
1543 R_jk +=
vshape(k,d)*pt_data[d];
1565 #ifdef MFEM_THREAD_SAFE 1571 for (
int j = 0; j <
dof; j++)
1578 Jinv.
Mult(tk+
dim*d2t[j], pt_data);
1579 for (
int k = 0; k <
dof; k++)
1582 for (
int d = 0; d <
dim; d++)
1584 R_jk +=
vshape(k,d)*pt_data[d];
1600 : etype(etype), auxiliary_basis(NULL), scale_integrated(false)
1609 for (
int i = 0; i <=
p; i++)
1623 for (
int i = 0; i <=
p; i++)
1625 for (
int j = 0; j < i; j++)
1627 double xij = x(i) - x(j);
1632 for (
int i = 0; i <=
p; i++)
1639 for (
int i = 0; i <
p; i++)
1643 mfem_error(
"Poly_1D::Basis::Basis : nodes are not increasing!");
1653 auxiliary_basis =
new Basis(
1675 int i, k,
p = x.Size() - 1;
1685 for (k = 0; k <
p; k++)
1687 if (y >= (x(k) + x(k+1))/2)
1693 for (i = k+1; i <=
p; i++)
1700 l = lk * (y - x(k));
1702 for (i = 0; i < k; i++)
1704 u(i) = l * w(i) / (y - x(i));
1707 for (i++; i <=
p; i++)
1709 u(i) = l * w(i) / (y - x(i));
1717 auxiliary_basis->Eval(y, u_aux, d_aux);
1718 EvalIntegrated(d_aux,
u);
1737 int i, k,
p = x.Size() - 1;
1738 double l, lp, lk, sk, si;
1748 for (k = 0; k <
p; k++)
1750 if (y >= (x(k) + x(k+1))/2)
1756 for (i = k+1; i <=
p; i++)
1763 l = lk * (y - x(k));
1766 for (i = 0; i < k; i++)
1768 si = 1.0/(y - x(i));
1770 u(i) = l * si * w(i);
1773 for (i++; i <=
p; i++)
1775 si = 1.0/(y - x(i));
1777 u(i) = l * si * w(i);
1781 for (i = 0; i < k; i++)
1783 d(i) = (lp * w(i) -
u(i))/(y - x(i));
1786 for (i++; i <=
p; i++)
1788 d(i) = (lp * w(i) -
u(i))/(y - x(i));
1796 auxiliary_basis->Eval(y, u_aux, d_aux, d2_aux);
1797 EvalIntegrated(d_aux,
u);
1798 EvalIntegrated(d2_aux,d);
1808 "Basis::Eval with second order derivatives not implemented for" 1809 " etype = " << etype);
1822 int i, k,
p = x.Size() - 1;
1823 double l, lp, lp2, lk, sk, si, sk2;
1834 for (k = 0; k <
p; k++)
1836 if (y >= (x(k) + x(k+1))/2)
1842 for (i = k+1; i <=
p; i++)
1849 l = lk * (y - x(k));
1853 for (i = 0; i < k; i++)
1855 si = 1.0/(y - x(i));
1858 u(i) = l * si * w(i);
1861 for (i++; i <=
p; i++)
1863 si = 1.0/(y - x(i));
1866 u(i) = l * si * w(i);
1869 lp2 = lp * sk + l * sk2 + sk * lk;
1871 for (i = 0; i < k; i++)
1873 d(i) = (lp * w(i) -
u(i))/(y - x(i));
1874 d2(i) = (lp2 * w(i) - 2 * d(i))/(y - x(i));
1877 d2(k) = sk2 *
u(k) + sk * d(k);
1878 for (i++; i <=
p; i++)
1880 d(i) = (lp * w(i) -
u(i))/(y - x(i));
1881 d2(i) = (lp2 * w(i) - 2 * d(i))/(y - x(i));
1889 MFEM_ABORT(
"Integrated basis must be evaluated with EvalIntegrated");
1898 "EvalIntegrated is only valid for Integrated basis type");
1899 int p = d_aux_.
Size() - 1;
1903 for (
int j=1; j<
p; ++j)
1905 u[j] =
u[j-1] - d_aux_[j];
1910 if (scale_integrated)
1912 Vector &aux_nodes = auxiliary_basis->x;
1913 for (
int j=0; j<aux_nodes.
Size()-1; ++j)
1915 u[j] *= aux_nodes[j+1] - aux_nodes[j];
1922 scale_integrated = scale_integrated_;
1927 delete auxiliary_basis;
1935 for (
int i = 0; i <=
p; i++)
1937 binom(i,0) = binom(i,i) = 1;
1938 for (
int j = 1; j < i; j++)
1940 binom(i,j) = binom(i-1,j) + binom(i-1,j-1);
1949 for (
int i = 0; i <=
p; i++)
1952 double s = sin(M_PI_2*(i + 0.5)/(
p + 1));
1957 void Poly_1D::CalcMono(
const int p,
const double x,
double *
u)
1961 for (
int n = 1; n <=
p; n++)
1967 void Poly_1D::CalcMono(
const int p,
const double x,
double *
u,
double *d)
1972 for (
int n = 1; n <=
p; n++)
1992 for (i = 1; i <
p; i++)
1999 for (i--; i > 0; i--)
2009 double *
u,
double *d)
2020 const double xpy = x + y, ptx =
p*x;
2023 for (i = 1; i <
p; i++)
2025 d[i] =
b[i]*z*(i*xpy - ptx);
2032 for (i--; i > 0; i--)
2054 const double xpy = x + y, ptx =
p*x;
2057 for (i = 1; i <
p; i++)
2059 d[i] =
b[i]*z*(i*xpy - ptx);
2064 for (i--; i > 0; i--)
2079 if (
p == 0) {
return; }
2080 u[1] = z = 2.*x - 1.;
2081 for (
int n = 1; n <
p; n++)
2083 u[n+1] = ((2*n + 1)*z*
u[n] - n*
u[n-1])/(n + 1);
2096 if (
p == 0) {
return; }
2097 u[1] = z = 2.*x - 1.;
2099 for (
int n = 1; n <
p; n++)
2101 u[n+1] = ((2*n + 1)*z*
u[n] - n*
u[n-1])/(n + 1);
2102 d[n+1] = (4*n + 2)*
u[n] + d[n-1];
2106 void Poly_1D::CalcChebyshev(
const int p,
const double x,
double *
u)
2113 if (
p == 0) {
return; }
2114 u[1] = z = 2.*x - 1.;
2115 for (
int n = 1; n <
p; n++)
2117 u[n+1] = 2*z*
u[n] -
u[n-1];
2121 void Poly_1D::CalcChebyshev(
const int p,
const double x,
double *
u,
double *d)
2134 if (
p == 0) {
return; }
2135 u[1] = z = 2.*x - 1.;
2137 for (
int n = 1; n <
p; n++)
2139 u[n+1] = 2*z*
u[n] -
u[n-1];
2140 d[n+1] = (n + 1)*(z*d[n]/n + 2*
u[n]);
2144 void Poly_1D::CalcChebyshev(
const int p,
const double x,
double *
u,
double *d,
2160 if (
p == 0) {
return; }
2161 u[1] = z = 2.*x - 1.;
2164 for (
int n = 1; n <
p; n++)
2166 u[n+1] = 2*z*
u[n] -
u[n-1];
2167 d[n+1] = (n + 1)*(z*d[n]/n + 2*
u[n]);
2168 dd[n+1] = (n + 1)*(2.*(n + 1)*d[n] + z*dd[n])/n;
2179 if (points_container.find(btype) == points_container.end())
2184 if (
pts.Size() <=
p)
2186 pts.SetSize(
p + 1, NULL);
2190 pts[
p] =
new double[
p + 1];
2200 if ( bases_container.find(btype) == bases_container.end() )
2206 if (bases.
Size() <=
p)
2210 if (bases[
p] == NULL)
2223 for (PointsMap::iterator it = points_container.begin();
2224 it != points_container.end() ; ++it)
2227 for (
int i = 0 ; i <
pts.Size() ; ++i )
2234 for (BasisMap::iterator it = bases_container.begin();
2235 it != bases_container.end() ; ++it)
2238 for (
int i = 0 ; i < bases.
Size() ; ++i )
2261 for (
int i = 1; i <
p; i++)
2269 const int p1 =
p + 1;
2280 for (
int i = 1; i <
p; i++)
2284 for (
int i = 1; i <
p; i++)
2288 for (
int i = 1; i <
p; i++)
2292 for (
int i = 1; i <
p; i++)
2298 for (
int j = 1; j <
p; j++)
2300 for (
int i = 1; i <
p; i++)
2309 const int p1 =
p + 1;
2313 dof_map[0 + (0 + 0*p1)*p1] = 0;
2325 for (
int i = 1; i <
p; i++)
2327 dof_map[i + (0 + 0*p1)*p1] = o++;
2329 for (
int i = 1; i <
p; i++)
2333 for (
int i = 1; i <
p; i++)
2337 for (
int i = 1; i <
p; i++)
2339 dof_map[0 + (i + 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++)
2353 for (
int i = 1; i <
p; i++)
2357 for (
int i = 1; i <
p; i++)
2359 dof_map[0 + (0 + i*p1)*p1] = o++;
2361 for (
int i = 1; i <
p; i++)
2365 for (
int i = 1; i <
p; i++)
2369 for (
int i = 1; i <
p; i++)
2375 for (
int j = 1; j <
p; j++)
2377 for (
int i = 1; i <
p; i++)
2379 dof_map[i + ((
p-j) + 0*p1)*p1] = o++;
2382 for (
int j = 1; j <
p; j++)
2384 for (
int i = 1; i <
p; i++)
2386 dof_map[i + (0 + j*p1)*p1] = o++;
2389 for (
int j = 1; j <
p; j++)
2391 for (
int i = 1; i <
p; i++)
2396 for (
int j = 1; j <
p; j++)
2398 for (
int i = 1; i <
p; i++)
2403 for (
int j = 1; j <
p; j++)
2405 for (
int i = 1; i <
p; i++)
2407 dof_map[0 + ((
p-i) + j*p1)*p1] = o++;
2410 for (
int j = 1; j <
p; j++)
2412 for (
int i = 1; i <
p; i++)
2419 for (
int k = 1; k <
p; k++)
2421 for (
int j = 1; j <
p; j++)
2423 for (
int i = 1; i <
p; i++)
2425 dof_map[i + (j + k*p1)*p1] = o++;
2432 MFEM_ABORT(
"invalid dimension: " << dims);
2443 MFEM_ABORT(
"invalid DofMapType: " << dmtype);
2454 for (
int i = 0; i < dof2quad_array.
Size(); i++)
2456 const DofToQuad &d2q = *dof2quad_array[i];
2457 if (d2q.
IntRule == &ir && d2q.
mode == mode) {
return d2q; }
2472 Vector val(ndof), grad(ndof);
2473 for (
int i = 0; i < nqpt; i++)
2478 for (
int j = 0; j < ndof; j++)
2480 d2q->
B[i+nqpt*j] = d2q->
Bt[j+ndof*i] = val(j);
2481 d2q->
G[i+nqpt*j] = d2q->
Gt[j+ndof*i] = grad(j);
2484 dof2quad_array.
Append(d2q);
2522 obasis1d(
poly1d.GetBasis(
p - 1, VerifyOpen(obtype)))
2524 MFEM_VERIFY(dims > 1,
"Constructor for VectorTensorFiniteElement with both " 2525 "open and closed bases is not valid for 1D elements.");
2537 obasis1d(
poly1d.GetBasis(
p, VerifyOpen(obtype)))
2539 MFEM_VERIFY(dims == 1,
"Constructor for VectorTensorFiniteElement without " 2540 "closed basis is only valid for 1D elements.");
2545 for (
int i = 0; i < dof2quad_array_open.Size(); i++)
2547 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...
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.
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...
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)
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...