45#ifndef MFEM_THREAD_SAFE
53 MFEM_ABORT(
"method is not implemented for this class");
59 MFEM_ABORT(
"method is not implemented for this class");
65 MFEM_ABORT(
"method is not implemented for this class");
72 div_shape *= (1.0 / Trans.
Weight());
78 MFEM_ABORT(
"method is not implemented for this class");
88#ifdef MFEM_THREAD_SAFE
93 curl_shape *= (1.0 / Trans.
Weight());
99 curl_shape *= (1.0 / Trans.
Weight());
102 MFEM_ABORT(
"Invalid dimension, Dim = " <<
dim);
108 MFEM_ABORT(
"method is not overloaded");
114 MFEM_ABORT(
"method is not overloaded");
120 MFEM_ABORT(
"method is not overloaded");
126 MFEM_ABORT(
"method is not overloaded");
133 MFEM_ABORT(
"method is not overloaded");
139 MFEM_ABORT(
"method is not overloaded");
145 MFEM_ABORT(
"method is not overloaded");
151 mfem_error(
"FiniteElement::ProjectFromNodes() (vector) is not overloaded!");
157 MFEM_ABORT(
"method is not overloaded");
162 MFEM_ABORT(
"method is not implemented for this element");
168 MFEM_ABORT(
"method is not implemented for this element");
175 MFEM_ABORT(
"method is not implemented for this element");
182 MFEM_ABORT(
"method is not implemented for this element");
189 MFEM_ABORT(
"method is not implemented for this element");
206#ifdef MFEM_THREAD_SAFE
226 int size = (
dim*(
dim+1))/2;
232 for (
int nd = 0; nd <
dof; nd++)
234 Laplacian[nd] = hess(nd,0) + hess(nd,4) + hess(nd,5);
239 for (
int nd = 0; nd <
dof; nd++)
241 Laplacian[nd] = hess(nd,0) + hess(nd,2);
246 for (
int nd = 0; nd <
dof; nd++)
248 Laplacian[nd] = hess(nd,0);
258 int size = (
dim*(
dim+1))/2;
269 scale[1] = 2*Gij(0,1);
270 scale[2] = 2*Gij(0,2);
272 scale[3] = 2*Gij(1,2);
280 scale[1] = 2*Gij(0,1);
288 for (
int nd = 0; nd <
dof; nd++)
291 for (
int ii = 0; ii < size; ii++)
293 Laplacian[nd] += hess(nd,ii)*scale[ii];
333 int size = (
dim*(
dim+1))/2;
351 for (
int i = 0; i <
dim; i++)
353 for (
int j = 0; j <
dim; j++)
355 for (
int k = 0; k <
dim; k++)
357 for (
int l = 0; l <
dim; l++)
359 lhm(map[i*
dim+j],map[k*
dim+l]) += invJ(i,k)*invJ(j,l);
367 for (
int i = 0; i <
dim*
dim; i++) { mult[map[i]]++; }
372 Mult(hess, lhm, Hessian);
381#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
382 #pragma omp critical (DofToQuad)
388 if (d2q->
IntRule != &ir || d2q->
mode != mode) { d2q =
nullptr; }
392#ifdef MFEM_THREAD_SAFE
411 for (
int i = 0; i < nqpt; i++)
415 for (
int j = 0; j <
dof; j++)
417 d2q->
B[i+nqpt*j] = d2q->
Bt[j+
dof*i] = shape(j);
427 for (
int i = 0; i < nqpt; i++)
431 for (
int d = 0; d <
dim; d++)
433 for (
int j = 0; j <
dof; j++)
435 d2q->
B[i+nqpt*(d+
dim*j)] =
453 for (
int i = 0; i < nqpt; i++)
455 const IntegrationPoint &ip = ir.
IntPoint(i);
457 for (
int d = 0; d <
dim; d++)
459 for (
int j = 0; j <
dof; j++)
461 d2q->
G[i+nqpt*(d+
dim*j)] =
475 for (
int i = 0; i < nqpt; i++)
477 const IntegrationPoint &ip = ir.
IntPoint(i);
479 for (
int j = 0; j <
dof; j++)
481 d2q->
G[i+nqpt*j] = d2q->
Gt[j+
dof*i] = divshape(j);
492 for (
int i = 0; i < nqpt; i++)
494 const IntegrationPoint &ip = ir.
IntPoint(i);
496 for (
int d = 0; d <
cdim; d++)
498 for (
int j = 0; j <
dof; j++)
500 d2q->
G[i+nqpt*(d+
cdim*j)] =
501 d2q->
Gt[j+
dof*(i+nqpt*d)] = curlshape(j, d);
520 MFEM_ABORT(
"method is not implemented for this element");
540#ifdef MFEM_THREAD_SAFE
550 for (
int i = 0; i < fine_fe.
dof; i++)
555 for (
int j = 0; j <
dof; j++)
557 if (fabs(I(i,j) = shape(j)) < 1.0e-12)
583 Vector fine_shape(fs), coarse_shape(cs);
584 DenseMatrix fine_mass(fs), fine_coarse_mass(fs, cs);
602 fine_mass_inv.
Mult(fine_coarse_mass, I);
622 Vector fine_shape(fs), coarse_shape(cs);
623 DenseMatrix coarse_mass(cs), coarse_fine_mass(cs, fs);
651 coarse_mass_inv.
Mult(coarse_fine_mass, R);
657 R *= 1.0 / Trans.
Weight();
661void NodalFiniteElement::CreateLexicographicFullMap(
const IntegrationRule &ir)
665#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
666 #pragma omp critical (DofToQuad)
678 for (
int i = 0; i < nqpt; i++)
680 for (
int d = 0; d < b_dim; d++)
682 for (
int j = 0; j <
dof; j++)
684 const double val = d2q.
B[i + nqpt*(d+b_dim*
lex_ordering[j])];
685 d2q_new->B[i+nqpt*(d+b_dim*j)] = val;
686 d2q_new->Bt[j+
dof*(i+nqpt*d)] = val;
691 const int g_dim = [
this]()
702 for (
int i = 0; i < nqpt; i++)
704 for (
int d = 0; d < g_dim; d++)
706 for (
int j = 0; j <
dof; j++)
708 const double val = d2q.
G[i + nqpt*(d+g_dim*
lex_ordering[j])];
709 d2q_new->G[i+nqpt*(d+g_dim*j)] = val;
710 d2q_new->Gt[j+
dof*(i+nqpt*d)] = val;
723#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
724 #pragma omp critical (DofToQuad)
731 if (d2q->
IntRule == &ir && d2q->
mode == mode) {
break; }
735 if (d2q) {
return *d2q; }
742 CreateLexicographicFullMap(ir);
754 for (
int i = 0; i <
dof; i++)
764 for (
int j = 0; j < fe.
GetDof(); j++)
766 curl(i,j) = w * curl_shape(j,0);
777 trans.Transform(p0, x);
784 trans.InverseJacobian().Mult(v, x);
793#ifdef MFEM_THREAD_SAFE
802 for (
int j = 0; j <
dof; j++)
822 for (
int i = 0; i <
dof; i++)
828 dofs(i) = coeff.
Eval(Trans, ip);
831 dofs(i) *= Trans.
Weight();
842 for (
int i = 0; i <
dof; i++)
846 vc.
Eval (x, Trans, ip);
851 for (
int j = 0; j < x.
Size(); j++)
853 dofs(
dof*j+i) = x(j);
865 for (
int k = 0; k <
dof; k++)
870 for (
int r = 0; r < MQ.
Height(); r++)
872 for (
int d = 0; d < MQ.
Width(); d++)
874 dofs(k+
dof*(d+MQ.
Width()*r)) = MQ(r,d);
890 for (
int k = 0; k <
dof; k++)
893 for (
int j = 0; j < shape.
Size(); j++)
895 I(k,j) = (fabs(shape(j)) < 1e-12) ? 0.0 : shape(j);
901 for (
int k = 0; k <
dof; k++)
909 for (
int j = 0; j < shape.
Size(); j++)
911 I(k,j) = (fabs(shape(j)) < 1e-12) ? 0.0 : shape(j);
922 for (
int k = 0; k <
dof; k++)
949 for (
int k = 0; k <
dof; k++)
955 Mult(dshape, Jinv, grad_k);
960 for (
int j = 0; j < grad_k.Height(); j++)
961 for (
int d = 0; d <
dim; d++)
963 grad(k+d*
dof,j) = grad_k(j,d);
976 for (
int k = 0; k <
dof; k++)
984 for (
int j = 0; j < div_shape.
Size(); j++)
986 div(k,j) = (fabs(div_shape(j)) < 1e-12) ? 0.0 : div_shape(j)/detJ;
991 for (
int j = 0; j < div_shape.
Size(); j++)
993 div(k,j) = (fabs(div_shape(j)) < 1e-12) ? 0.0 : div_shape(j);
1003 MFEM_ASSERT(dofs.
Size() == ncomp *
dof,
"Wrong input size.");
1006 for (
int i = 0; i <
dof; i++)
1008 for (
int c = 0; c < ncomp; c++)
1017 int Do,
int O,
int M,
int F)
1031void VectorFiniteElement::CalcShape(
1034 mfem_error(
"Error: Cannot use scalar CalcShape(...) function with\n"
1035 " VectorFiniteElements!");
1038void VectorFiniteElement::CalcDShape(
1039 const IntegrationPoint &ip, DenseMatrix &dshape)
const
1041 mfem_error(
"Error: Cannot use scalar CalcDShape(...) function with\n"
1042 " VectorFiniteElements!");
1074 MFEM_ABORT(
"Invalid dimension, Dim = " <<
dim);
1078 MFEM_ABORT(
"Invalid MapType = " <<
map_type);
1086#ifdef MFEM_THREAD_SAFE
1091 shape *= (1.0 / Trans.
Weight());
1098#ifdef MFEM_THREAD_SAFE
1111 MFEM_ASSERT(vc.
GetVDim() == sdim,
"");
1113 const bool square_J = (
dim == sdim);
1115 for (
int k = 0; k <
dof; k++)
1121 if (!square_J) { dofs(k) /= Trans.
Weight(); }
1130 const bool square_J = (
dim == sdim);
1132 for (
int k = 0; k <
dof; k++)
1137 &vc[k*sdim], nk + d2n[k]*
dim);
1138 if (!square_J) { dofs(k) /= Trans.
Weight(); }
1149 MFEM_ASSERT(mc.
GetWidth() == sdim,
"");
1150 const bool square_J = (
dim == sdim);
1155 for (
int k = 0; k <
dof; k++)
1161 if (!square_J) { nk_phys /= T.
Weight(); }
1162 MQ.
Mult(nk_phys, dofs_k);
1163 for (
int r = 0; r < MQ.
Height(); r++)
1165 dofs(k+
dof*r) = dofs_k(r);
1181 for (
int k = 0; k <
dof; k++)
1193 for (
int d = 0; d <
dim; d++)
1199 for (
int j = 0; j < shape.
Size(); j++)
1202 if (fabs(s) < 1e-12)
1208 for (
int d = 0; d < sdim; d++)
1210 I(k,j+d*shape.
Size()) = s*vk[d];
1221 const bool square_J = (
dim == sdim);
1224 for (
int k = 0; k <
dof; k++)
1236 if (!square_J) { vshapenk /= Trans.
Weight(); }
1237 for (
int j=0; j<vshapenk.
Size(); j++)
1239 I(k,j) = vshapenk(j);
1251 mfem_error(
"VectorFiniteElement::ProjectGrad_RT works only in 2D!");
1259 for (
int k = 0; k <
dof; k++)
1262 tk[0] = nk[d2n[k]*
dim+1];
1263 tk[1] = -nk[d2n[k]*
dim];
1264 dshape.
Mult(tk, grad_k);
1265 for (
int j = 0; j < grad_k.
Size(); j++)
1267 grad(k,j) = (fabs(grad_k(j)) < 1e-12) ? 0.0 : grad_k(j);
1276#ifdef MFEM_THREAD_SAFE
1289 for (
int k = 0; k <
dof; k++)
1303 for (
int j = 0; j < curl_k.
Size(); j++)
1305 curl(k,j) = (fabs(curl_k(j)) < 1e-12) ? 0.0 : curl_k(j);
1318 for (
int k = 0; k <
dof; k++)
1321 curl_shape.
Mult(nk + d2n[k]*
dim, curl_k);
1322 for (
int j = 0; j < curl_k.
Size(); j++)
1324 curl(k,j) = (fabs(curl_k(j)) < 1e-12) ? 0.0 : curl_k(j);
1336 for (
int k = 0; k <
dof; k++)
1350 for (
int k = 0; k <
dof; k++)
1365 MFEM_ASSERT(mc.
GetWidth() == sdim,
"");
1370 for (
int k = 0; k <
dof; k++)
1376 MQ.
Mult(tk_phys, dofs_k);
1377 for (
int r = 0; r < MQ.
Height(); r++)
1379 dofs(k+
dof*r) = dofs_k(r);
1395 for (
int k = 0; k <
dof; k++)
1407 for (
int d = 0; d < sdim; d++)
1413 for (
int j = 0; j < shape.
Size(); j++)
1416 if (fabs(s) < 1e-12)
1422 for (
int d = 0; d < sdim; d++)
1424 I(k, j + d*shape.
Size()) = s*vk[d];
1437 for (
int k = 0; k <
dof; k++)
1449 for (
int j=0; j<vshapetk.
Size(); j++)
1451 I(k, j) = vshapetk(j);
1467 for (
int k = 0; k <
dof; k++)
1470 dshape.
Mult(tk + d2t[k]*
dim, grad_k);
1471 for (
int j = 0; j < grad_k.
Size(); j++)
1473 grad(k,j) = (fabs(grad_k(j)) < 1e-12) ? 0.0 : grad_k(j);
1488 DenseMatrix fine_mass(fs), fine_coarse_mass(fs, cs);
1489 const int ir_order =
1505 for (
int k=0; k<fs; ++k)
1507 for (
int j=0; j<cs; ++j)
1510 for (
int d1=0; d1<
dim; ++d1)
1512 for (
int d2=0; d2<
dim; ++d2)
1514 Mkj += w*fine_shape(k,d1)*adjJ(d2,d1)*coarse_shape(j,d2);
1517 fine_coarse_mass(k,j) += (fabs(Mkj) < 1e-12) ? 0.0 : Mkj;
1522 fine_mass_inv.
Mult(fine_coarse_mass, I);
1536#ifdef MFEM_THREAD_SAFE
1546 for (
int k = 0; k <
dof; k++)
1557 for (
int i = 0; i <
dim; i++)
1559 Ikj +=
vshape(j, i) * vk[i];
1561 I(k, j) = (fabs(Ikj) < 1e-12) ? 0.0 : Ikj;
1576 DenseMatrix fine_mass(fs), fine_coarse_mass(fs, cs);
1577 const int ir_order =
1592 for (
int k=0; k<fs; ++k)
1594 for (
int j=0; j<cs; ++j)
1597 for (
int d1=0; d1<
dim; ++d1)
1599 for (
int d2=0; d2<
dim; ++d2)
1601 Mkj += ip.
weight*fine_shape(k,d1)*J(d1,d2)*coarse_shape(j,d2);
1604 fine_coarse_mass(k,j) += (fabs(Mkj) < 1e-12) ? 0.0 : Mkj;
1609 fine_mass_inv.
Mult(fine_coarse_mass, I);
1621#ifdef MFEM_THREAD_SAFE
1631 for (
int k = 0; k <
dof; k++)
1642 for (
int i = 0; i <
dim; i++)
1644 Ikj +=
vshape(j, i) * vk[i];
1646 I(k, j) = (fabs(Ikj) < 1e-12) ? 0.0 : Ikj;
1659#ifdef MFEM_THREAD_SAFE
1666 for (
int j = 0; j <
dof; j++)
1675 for (
int k = 0; k <
dof; k++)
1678 for (
int d = 0; d <
dim; d++)
1680 R_jk +=
vshape(k,d)*pt_data[d];
1702#ifdef MFEM_THREAD_SAFE
1708 for (
int j = 0; j <
dof; j++)
1715 Jinv.
Mult(tk+
dim*d2t[j], pt_data);
1716 for (
int k = 0; k <
dof; k++)
1719 for (
int d = 0; d <
dim; d++)
1721 R_jk +=
vshape(k,d)*pt_data[d];
1737 : etype(etype), auxiliary_basis(NULL), scale_integrated(false)
1746 for (
int i = 0; i <=
p; i++)
1760 for (
int i = 0; i <=
p; i++)
1762 for (
int j = 0; j < i; j++)
1764 real_t xij = x(i) - x(j);
1769 for (
int i = 0; i <=
p; i++)
1776 for (
int i = 0; i <
p; i++)
1780 mfem_error(
"Poly_1D::Basis::Basis : nodes are not increasing!");
1790 auxiliary_basis =
new Basis(
1812 int i, k,
p = x.Size() - 1;
1822 for (k = 0; k <
p; k++)
1824 if (y >= (x(k) + x(k+1))/2)
1830 for (i = k+1; i <=
p; i++)
1837 l = lk * (y - x(k));
1839 for (i = 0; i < k; i++)
1841 u(i) = l * w(i) / (y - x(i));
1844 for (i++; i <=
p; i++)
1846 u(i) = l * w(i) / (y - x(i));
1854 auxiliary_basis->Eval(y, u_aux, d_aux);
1855 EvalIntegrated(d_aux,
u);
1874 int i, k,
p = x.Size() - 1;
1875 real_t l, lp, lk, sk, si;
1885 for (k = 0; k <
p; k++)
1887 if (y >= (x(k) + x(k+1))/2)
1893 for (i = k+1; i <=
p; i++)
1900 l = lk * (y - x(k));
1903 for (i = 0; i < k; i++)
1905 si = 1.0/(y - x(i));
1907 u(i) = l * si * w(i);
1910 for (i++; i <=
p; i++)
1912 si = 1.0/(y - x(i));
1914 u(i) = l * si * w(i);
1918 for (i = 0; i < k; i++)
1920 d(i) = (lp * w(i) -
u(i))/(y - x(i));
1923 for (i++; i <=
p; i++)
1925 d(i) = (lp * w(i) -
u(i))/(y - x(i));
1933 auxiliary_basis->Eval(y, u_aux, d_aux, d2_aux);
1934 EvalIntegrated(d_aux,
u);
1935 EvalIntegrated(d2_aux,d);
1945 "Basis::Eval with second order derivatives not implemented for"
1946 " etype = " << etype);
1959 int i, k,
p = x.Size() - 1;
1960 real_t l, lp, lp2, lk, sk, si, sk2;
1971 for (k = 0; k <
p; k++)
1973 if (y >= (x(k) + x(k+1))/2)
1979 for (i = k+1; i <=
p; i++)
1986 l = lk * (y - x(k));
1990 for (i = 0; i < k; i++)
1992 si = 1.0/(y - x(i));
1995 u(i) = l * si * w(i);
1998 for (i++; i <=
p; i++)
2000 si = 1.0/(y - x(i));
2003 u(i) = l * si * w(i);
2006 lp2 = lp * sk + l * sk2 + sk * lk;
2008 for (i = 0; i < k; i++)
2010 d(i) = (lp * w(i) -
u(i))/(y - x(i));
2011 d2(i) = (lp2 * w(i) - 2 * d(i))/(y - x(i));
2014 d2(k) = sk2 *
u(k) + sk * d(k);
2015 for (i++; i <=
p; i++)
2017 d(i) = (lp * w(i) -
u(i))/(y - x(i));
2018 d2(i) = (lp2 * w(i) - 2 * d(i))/(y - x(i));
2026 MFEM_ABORT(
"Integrated basis must be evaluated with EvalIntegrated");
2035 "EvalIntegrated is only valid for Integrated basis type");
2036 int p = d_aux_.
Size() - 1;
2040 for (
int j=1; j<
p; ++j)
2042 u[j] =
u[j-1] - d_aux_[j];
2047 if (scale_integrated)
2049 Vector &aux_nodes = auxiliary_basis->x;
2050 for (
int j=0; j<aux_nodes.
Size()-1; ++j)
2052 u[j] *= aux_nodes[j+1] - aux_nodes[j];
2059 scale_integrated = scale_integrated_;
2064 delete auxiliary_basis;
2072 for (
int i = 0; i <=
p; i++)
2074 binom(i,0) = binom(i,i) = 1;
2075 for (
int j = 1; j < i; j++)
2077 binom(i,j) = binom(i-1,j) + binom(i-1,j-1);
2086 for (
int i = 0; i <=
p; i++)
2089 real_t s = sin(M_PI_2*(i + 0.5)/(
p + 1));
2098 for (
int n = 1; n <=
p; n++)
2109 for (
int n = 1; n <=
p; n++)
2129 for (i = 1; i <
p; i++)
2136 for (i--; i > 0; i--)
2157 const real_t xpy = x + y, ptx =
p*x;
2160 for (i = 1; i <
p; i++)
2162 d[i] =
b[i]*z*(i*xpy - ptx);
2169 for (i--; i > 0; i--)
2191 const real_t xpy = x + y, ptx =
p*x;
2194 for (i = 1; i <
p; i++)
2196 d[i] =
b[i]*z*(i*xpy - ptx);
2201 for (i--; i > 0; i--)
2223 for (i = 1; i <
p; i++)
2230 for (i--; i > 0; i--)
2252 for (i = 1; i <
p; i++)
2259 for (i--; i > 0; i--)
2261 u[i] *= (
p - i) * z;
2274 if (
p == 0) {
return; }
2275 u[1] = z = 2.*x - 1.;
2276 for (
int n = 1; n <
p; n++)
2278 u[n+1] = ((2*n + 1)*z*
u[n] - n*
u[n-1])/(n + 1);
2291 if (
p == 0) {
return; }
2292 u[1] = z = 2.*x - 1.;
2294 for (
int n = 1; n <
p; n++)
2296 u[n+1] = ((2*n + 1)*z*
u[n] - n*
u[n-1])/(n + 1);
2297 d[n+1] = (4*n + 2)*
u[n] + d[n-1];
2301void Poly_1D::CalcChebyshev(
const int p,
const real_t x,
real_t *
u)
2308 if (
p == 0) {
return; }
2309 u[1] = z = 2.*x - 1.;
2310 for (
int n = 1; n <
p; n++)
2312 u[n+1] = 2*z*
u[n] -
u[n-1];
2329 if (
p == 0) {
return; }
2330 u[1] = z = 2.*x - 1.;
2332 for (
int n = 1; n <
p; n++)
2334 u[n+1] = 2*z*
u[n] -
u[n-1];
2335 d[n+1] = (n + 1)*(z*d[n]/n + 2*
u[n]);
2355 if (
p == 0) {
return; }
2356 u[1] = z = 2.*x - 1.;
2359 for (
int n = 1; n <
p; n++)
2361 u[n+1] = 2*z*
u[n] -
u[n-1];
2362 d[n+1] = (n + 1)*(z*d[n]/n + 2*
u[n]);
2363 dd[n+1] = (n + 1)*(2.*(n + 1)*d[n] + z*dd[n])/n;
2374#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
2375 #pragma omp critical (Poly1DGetPoints)
2378 std::pair<int, int> key(btype,
p);
2379 auto it = points_container.find(key);
2380 if (it == points_container.end())
2382 it = points_container.emplace(key,
new Array<real_t>(
p + 1, h_mt)).first;
2383 val = it->second.get();
2389 val = it->second.get();
2400#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
2401 #pragma omp critical (Poly1DGetBasis)
2404 std::pair<int, int> key(btype,
p);
2405 auto it = bases_container.find(key);
2406 if (it == bases_container.end())
2412 it = bases_container
2416 val = it->second.get();
2436 for (
int i = 1; i <
p; i++)
2444 const int p1 =
p + 1;
2455 for (
int i = 1; i <
p; i++)
2459 for (
int i = 1; i <
p; i++)
2463 for (
int i = 1; i <
p; i++)
2467 for (
int i = 1; i <
p; i++)
2473 for (
int j = 1; j <
p; j++)
2475 for (
int i = 1; i <
p; i++)
2484 const int p1 =
p + 1;
2488 dof_map[0 + (0 + 0*p1)*p1] = 0;
2500 for (
int i = 1; i <
p; i++)
2502 dof_map[i + (0 + 0*p1)*p1] = o++;
2504 for (
int i = 1; i <
p; i++)
2508 for (
int i = 1; i <
p; i++)
2512 for (
int i = 1; i <
p; i++)
2514 dof_map[0 + (i + 0*p1)*p1] = o++;
2516 for (
int i = 1; i <
p; i++)
2520 for (
int i = 1; i <
p; i++)
2524 for (
int i = 1; i <
p; i++)
2528 for (
int i = 1; i <
p; i++)
2532 for (
int i = 1; i <
p; i++)
2534 dof_map[0 + (0 + i*p1)*p1] = o++;
2536 for (
int i = 1; i <
p; i++)
2540 for (
int i = 1; i <
p; i++)
2544 for (
int i = 1; i <
p; i++)
2550 for (
int j = 1; j <
p; j++)
2552 for (
int i = 1; i <
p; i++)
2554 dof_map[i + ((
p-j) + 0*p1)*p1] = o++;
2557 for (
int j = 1; j <
p; j++)
2559 for (
int i = 1; i <
p; i++)
2561 dof_map[i + (0 + j*p1)*p1] = o++;
2564 for (
int j = 1; j <
p; j++)
2566 for (
int i = 1; i <
p; i++)
2571 for (
int j = 1; j <
p; j++)
2573 for (
int i = 1; i <
p; i++)
2578 for (
int j = 1; j <
p; j++)
2580 for (
int i = 1; i <
p; i++)
2582 dof_map[0 + ((
p-i) + j*p1)*p1] = o++;
2585 for (
int j = 1; j <
p; j++)
2587 for (
int i = 1; i <
p; i++)
2594 for (
int k = 1; k <
p; k++)
2596 for (
int j = 1; j <
p; j++)
2598 for (
int i = 1; i <
p; i++)
2600 dof_map[i + (j + k*p1)*p1] = o++;
2607 MFEM_ABORT(
"invalid dimension: " << dims);
2618 MFEM_ABORT(
"invalid DofMapType: " << dmtype);
2630#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
2631 #pragma omp critical (DofToQuad)
2634 for (
int i = 0; i < dof2quad_array.
Size(); i++)
2636 auto* d2q_ = dof2quad_array[i];
2637 if (d2q_->IntRule == &ir && d2q_->mode == mode)
2657 Vector val(ndof), grad(ndof);
2658 for (
int i = 0; i < nqpt; i++)
2663 for (
int j = 0; j < ndof; j++)
2665 d2q->
B[i+nqpt*j] = d2q->
Bt[j+ndof*i] = val(j);
2666 d2q->
G[i+nqpt*j] = d2q->
Gt[j+ndof*i] = grad(j);
2669 dof2quad_array.
Append(d2q);
2716 internal::GetTensorFaceMap(
dim,
order, face_id, face_map);
2729 obasis1d(
poly1d.GetBasis(
p - 1, VerifyOpen(obtype)))
2731 MFEM_VERIFY(dims > 1,
"Constructor for VectorTensorFiniteElement with both "
2732 "open and closed bases is not valid for 1D elements.");
2744 obasis1d(
poly1d.GetBasis(
p, VerifyOpen(obtype)))
2746 MFEM_VERIFY(dims == 1,
"Constructor for VectorTensorFiniteElement without "
2747 "closed basis is only valid for 1D elements.");
2752 for (
int i = 0; i < dof2quad_array_open.Size(); i++)
2754 delete dof2quad_array_open[i];
void SetSize(int m, int n)
Set the 2D array size to m x n.
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
int Size() const
Return the logical size of the array.
int Append(const T &el)
Append element 'el' to array, resize if necessary.
void Abs()
Replace each entry of the array with its absolute value.
T * HostWrite()
Shortcut for mfem::Write(a.GetMemory(), a.Size(), false).
static int GetQuadrature1D(int b_type)
Get the corresponding Quadrature1D constant, when that makes sense; otherwise return Quadrature1D::In...
static int Check(int b_type)
If the input does not represents a valid BasisType, abort with an error; otherwise return the input.
@ GaussLobatto
Closed type.
@ Positive
Bernstein polynomials.
@ IntegratedGLL
Integrated GLL indicator functions.
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the coefficient in the element described by T at the point ip.
void Factor()
Factor the current DenseMatrix, *a.
void Mult(const real_t *x, real_t *y) const
Matrix vector multiplication with the inverse of dense matrix.
Data type dense matrix using column-major storage.
void Mult(const real_t *x, real_t *y) const
Matrix vector multiplication.
void MultTranspose(const real_t *x, real_t *y) const
Multiply a vector with the transpose matrix.
void Threshold(real_t eps)
Replace small entries, abs(a_ij) <= eps, with zero.
void SetRow(int r, const real_t *row)
void GetColumnReference(int c, Vector &col)
real_t InnerProduct(const real_t *x, const real_t *y) const
Compute y^t A x.
real_t * Data() const
Returns the matrix data array. Warning: this method casts away constness.
real_t * GetData() const
Returns the matrix data array. Warning: this method casts away constness.
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
void Invert()
Replaces the current matrix with its inverse.
void InvRightScaling(const Vector &s)
InvRightScaling: this = this * diag(1./s);.
void GetColumn(int c, Vector &col) const
real_t FNorm2() const
Compute the square of the Frobenius norm of the matrix.
Structure representing the matrices/tensors needed to evaluate (in reference space) the values,...
Mode mode
Describes the contents of the B, Bt, G, and Gt arrays, see Mode.
const IntegrationRule * IntRule
IntegrationRule that defines the quadrature points at which the basis functions of the FE are evaluat...
Array< real_t > G
Gradients/divergences/curls of basis functions evaluated at quadrature points.
Mode
Type of data stored in the arrays B, Bt, G, and Gt.
@ FULL
Full multidimensional representation which does not use tensor product structure. The ordering of the...
@ LEXICOGRAPHIC_FULL
Full multidimensional representation which does not use tensor product structure. The ordering of the...
@ TENSOR
Tensor product representation using 1D matrices/tensors with dimensions using 1D number of quadrature...
Array< real_t > B
Basis functions evaluated at quadrature points.
int ndof
Number of degrees of freedom = number of basis functions. When mode is TENSOR, this is the 1D number.
Array< real_t > Gt
Transpose of G.
const class FiniteElement * FE
The FiniteElement that created and owns this object.
int nqpt
Number of quadrature points. When mode is TENSOR, this is the 1D number.
Array< real_t > Bt
Transpose of B.
DofToQuad Abs() const
Returns absolute value of the maps.
Abstract class for all finite elements.
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...
int dof
Number of degrees of freedom.
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 ProjectMatrixCoefficient(MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const
Given a matrix coefficient and a transformation, compute an approximation ("projection") in the local...
virtual ~FiniteElement()
Deconstruct the FiniteElement.
virtual void ProjectDiv(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &div) const
Compute the discrete divergence matrix from the given FiniteElement onto 'this' FiniteElement....
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...
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...
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...
int GetRangeDim() const
Returns the vector dimension for vector-valued finite elements, which is also the dimension of the in...
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
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 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...
virtual void ProjectGrad(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &grad) const
Compute the discrete gradient matrix from the given FiniteElement onto 'this' FiniteElement....
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...
int GetDim() const
Returns the reference space dimension for the finite element.
int vdim
Vector dimension of vector-valued basis functions.
void CalcPhysHessian(ElementTransformation &Trans, DenseMatrix &Hessian) const
Evaluate the Hessian of all shape functions of a scalar finite element in physical space at the given...
FiniteElement(int D, Geometry::Type G, int Do, int O, int F=FunctionSpace::Pk)
Construct FiniteElement with given.
virtual void ProjectDelta(int vertex, Vector &dofs) const
Project a delta function centered on the given vertex in the local finite dimensional space represent...
int orders[Geometry::MaxDim]
Anisotropic orders.
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 GetMapType() const
Returns the FiniteElement::MapType of the element describing how reference functions are mapped to ph...
int GetRangeType() const
Returns the FiniteElement::RangeType of the element, one of {SCALAR, VECTOR}.
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...
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
int cdim
Dimension of curl for vector-valued basis functions.
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...
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...
@ DIV
Implements CalcDivShape methods.
@ NONE
No derivatives implemented.
@ CURL
Implements CalcCurlShape methods.
@ GRAD
Implements CalcDShape methods.
virtual void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const
Given a coefficient and a transformation, compute its projection (approximation) in the local finite ...
Geometry::Type geom_type
Geometry::Type of the reference element.
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...
Array< DofToQuad * > dof2quad_array
Container for all DofToQuad objects created by the FiniteElement.
void CalcPhysLaplacian(ElementTransformation &Trans, Vector &Laplacian) const
Evaluate the Laplacian of all shape functions of a scalar finite element in physical space at the giv...
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...
virtual void ProjectCurl(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
Compute the discrete curl matrix from the given FiniteElement onto 'this' FiniteElement....
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...
int GetDof() const
Returns the number of degrees of freedom in the finite element.
int order
Order/degree of the shape functions.
void CalcPhysLinLaplacian(ElementTransformation &Trans, Vector &Laplacian) const
Evaluate the Laplacian of all shape functions of a scalar finite element in physical space at the giv...
int dim
Dimension of reference space.
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 ...
Describes the function space on each element.
const IntegrationPoint & GetCenter(int GeomType) const
Return the center of the given Geometry::Type, GeomType.
static bool CheckPoint(int GeomType, const IntegrationPoint &ip)
Check if the given point is inside the given reference element.
Class for integration point with weight.
void Get(real_t *p, const int dim) const
void Set(const real_t *p, const int dim)
void Set3(const real_t x1, const real_t x2, const real_t x3)
Class for an integration rule - an Array of IntegrationPoint.
int GetNPoints() const
Returns the number of the points in the integration rule.
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
Base class for Matrix Coefficients that optionally depend on time and space.
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 GetWidth() const
Get the width of the matrix.
int GetHeight() const
Get the height of the matrix.
Class for standard nodal finite elements.
void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const override
Given a coefficient and a transformation, compute its projection (approximation) in the local finite ...
void ProjectCurl_2D(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
void ReorderLexToNative(int ncomp, Vector &dofs) const
void ProjectDiv(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &div) const override
Compute the discrete divergence matrix from the given FiniteElement onto 'this' FiniteElement....
void GetLocalRestriction(ElementTransformation &Trans, DenseMatrix &R) const override
Return a local restriction matrix R (Dof x Dof) mapping fine dofs to coarse dofs.
void ProjectGrad(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &grad) const override
Compute the discrete gradient matrix from the given FiniteElement onto 'this' FiniteElement....
void ProjectMatrixCoefficient(MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const override
Given a matrix coefficient and a transformation, compute an approximation ("projection") in the local...
Array< int > lex_ordering
const DofToQuad & GetDofToQuad(const IntegrationRule &ir, DofToQuad::Mode mode) const override
Return a DofToQuad structure corresponding to the given IntegrationRule using the given DofToQuad::Mo...
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...
NodalTensorFiniteElement(const int dims, const int p, const int btype, const DofMapType dmtype)
const DofToQuad & GetDofToQuad(const IntegrationRule &ir, DofToQuad::Mode mode) const override
Return a DofToQuad structure corresponding to the given IntegrationRule using the given DofToQuad::Mo...
void SetMapType(const int map_type_) override
Set the FiniteElement::MapType of the element to either VALUE or INTEGRAL. Also sets the FiniteElemen...
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
Class for evaluating 1D nodal, positive (Bernstein), or integrated (Gerritsma) bases.
void Eval(const real_t x, Vector &u) const
Evaluate the basis functions at point x in [0,1].
bool IsIntegratedType() const
Returns true if the basis is "integrated", false otherwise.
void ScaleIntegrated(bool scale_integrated_)
Set whether the "integrated" basis should be scaled by the subcell sizes. Has no effect for non-integ...
void EvalIntegrated(const Vector &d, Vector &i) const
Evaluate the "integrated" basis type using pre-computed closed basis derivatives.
Basis(const int p, const real_t *nodes, EvalType etype=Barycentric)
Create a nodal or positive (Bernstein) basis of degree p.
static void CalcDBinomTerms(const int p, const real_t x, const real_t y, real_t *d)
Compute the derivatives (w.r.t. x) of the terms in the expansion of the binomial (x + y)^p assuming t...
const real_t * GetPoints(const int p, const int btype, bool on_device=false)
Get the coordinates of the points of the given BasisType, btype.
static const int * Binom(const int p)
Get a pointer to an array containing the binomial coefficients "pchoose k" for k=0,...
Basis & GetBasis(const int p, const int btype)
Get a Poly_1D::Basis object of the given degree and BasisType, btype.
const Array< real_t > * GetPointsArray(const int p, const int btype)
Get the coordinates of the points of the given BasisType, btype.
static void CalcDyBinomTerms(const int p, const real_t x, const real_t y, real_t *d)
Compute the derivatives (w.r.t. y) of the terms in the expansion of the binomial (x + y)^p....
static void CalcLegendre(const int p, const real_t x, real_t *u)
static void CalcBernstein(const int p, const real_t x, real_t *u)
Compute the values of the Bernstein basis functions of order p at coordinate x and store the results ...
EvalType
One-dimensional basis evaluation type.
@ ChangeOfBasis
Use change of basis, O(p^2) Evals.
@ Integrated
Integrated indicator functions (cf. Gerritsma)
@ Positive
Fast evaluation of Bernstein polynomials.
@ Barycentric
Use barycentric Lagrangian interpolation, O(p) Evals.
static void ChebyshevPoints(const int p, real_t *x)
Compute the points for the Chebyshev polynomials of order p and place them in the already allocated x...
static void CalcBasis(const int p, const real_t x, real_t *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 real_t x, const real_t y, real_t *u)
Compute the p terms in the expansion of the binomial (x + y)^p and store them in the already allocate...
static void CalcDxBinomTerms(const int p, const real_t x, const real_t y, real_t *d)
Compute the derivatives (w.r.t. x) of the terms in the expansion of the binomial (x + y)^p....
static void GivePolyPoints(const int np, real_t *pts, const int type)
Class for finite elements with basis functions that return scalar values.
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...
virtual void SetMapType(int M)
Set the FiniteElement::MapType of the element to either VALUE or INTEGRAL. Also sets the FiniteElemen...
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 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.
static const DofToQuad & GetTensorDofToQuad(const FiniteElement &fe, const IntegrationRule &ir, DofToQuad::Mode mode, const Poly_1D::Basis &basis, bool closed, Array< DofToQuad * > &dof2quad_array)
TensorBasisElement(const int dims, const int p, const int btype, const DofMapType dmtype)
Base class for vector Coefficients that optionally depend on time and space.
int GetVDim()
Returns dimension of the vector.
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 ...
Intermediate class for finite elements whose basis functions return vector values.
void ProjectGrad_RT(const real_t *nk, const Array< int > &d2n, const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &grad) const
void LocalRestriction_RT(const real_t *nk, const Array< int > &d2n, ElementTransformation &Trans, DenseMatrix &R) const
void Project_ND(const real_t *tk, const Array< int > &d2t, VectorCoefficient &vc, ElementTransformation &Trans, Vector &dofs) const
Project a vector coefficient onto the ND basis functions.
void Project_RT(const real_t *nk, const Array< int > &d2n, VectorCoefficient &vc, ElementTransformation &Trans, Vector &dofs) const
Project a vector coefficient onto the RT basis functions.
void LocalInterpolation_RT(const VectorFiniteElement &cfe, const real_t *nk, const Array< int > &d2n, ElementTransformation &Trans, DenseMatrix &I) const
void ProjectMatrixCoefficient_ND(const real_t *tk, const Array< int > &d2t, MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const
Project the rows of the matrix coefficient in an ND space.
void LocalRestriction_ND(const real_t *tk, const Array< int > &d2t, ElementTransformation &Trans, DenseMatrix &R) const
void LocalL2Projection_RT(const VectorFiniteElement &cfe, ElementTransformation &Trans, DenseMatrix &I) const
void ProjectGrad_ND(const real_t *tk, const Array< int > &d2t, const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &grad) const
void CalcVShape_ND(ElementTransformation &Trans, DenseMatrix &shape) const
void CalcVShape_RT(ElementTransformation &Trans, DenseMatrix &shape) const
VectorFiniteElement(int D, Geometry::Type G, int Do, int O, int M, int F=FunctionSpace::Pk)
void LocalInterpolation_ND(const VectorFiniteElement &cfe, const real_t *tk, const Array< int > &d2t, ElementTransformation &Trans, DenseMatrix &I) const
void ProjectCurl_RT(const real_t *nk, const Array< int > &d2n, const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
void LocalL2Projection_ND(const VectorFiniteElement &cfe, ElementTransformation &Trans, DenseMatrix &I) const
void ProjectCurl_ND(const real_t *tk, const Array< int > &d2t, const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
void ProjectMatrixCoefficient_RT(const real_t *nk, const Array< int > &d2n, MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const
Project the rows of the matrix coefficient in an RT space.
virtual ~VectorTensorFiniteElement()
VectorTensorFiniteElement(const int dims, const int d, const int p, const int cbtype, const int obtype, const int M, const DofMapType dmtype)
void SetDataAndSize(real_t *d, int s)
Set the Vector data and size.
int Size() const
Returns the size of the vector.
void SetSize(int s)
Resize the vector to size s.
real_t * GetData() const
Return a pointer to the beginning of the Vector data.
void trans(const Vector &u, Vector &x)
real_t infinity()
Define a shortcut for std::numeric_limits<double>::infinity()
real_t u(const Vector &xvec)
void mfem_error(const char *msg)
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
void MultABt(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt)
Multiply a matrix A with the transpose of a matrix B: A*Bt.
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
void AddMult_a_VWt(const real_t a, const Vector &v, const Vector &w, DenseMatrix &VWt)
VWt += a * v w^t.
void AddMult_a_VVt(const real_t a, const Vector &v, DenseMatrix &VVt)
VVt += a * v v^t.
void AddMult_a_AAt(real_t a, const DenseMatrix &A, DenseMatrix &AAt)
AAt += a * A * A^t.
void MultAAt(const DenseMatrix &a, DenseMatrix &aat)
Calculate the matrix A.At.
ComplexDenseMatrix * MultAtB(const ComplexDenseMatrix &A, const ComplexDenseMatrix &B)
Multiply the complex conjugate transpose of a matrix A with a matrix B. A^H*B.
void InvertLinearTrans(ElementTransformation &trans, const IntegrationPoint &pt, Vector &x)
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
real_t p(const Vector &x, real_t t)
std::array< int, NCMesh::MaxFaceNodes > nodes