23 void BilinearFormIntegrator::AssembleElementMatrix (
27 mfem_error (
"BilinearFormIntegrator::AssembleElementMatrix (...)\n"
28 " is not implemented fot this class.");
31 void BilinearFormIntegrator::AssembleElementMatrix2 (
35 mfem_error (
"BilinearFormIntegrator::AssembleElementMatrix2 (...)\n"
36 " is not implemented fot this class.");
39 void BilinearFormIntegrator::AssembleFaceMatrix (
43 mfem_error (
"BilinearFormIntegrator::AssembleFaceMatrix (...)\n"
44 " is not implemented fot this class.");
47 void BilinearFormIntegrator::AssembleFaceMatrix(
52 MFEM_ABORT(
"AssembleFaceMatrix (mixed form) is not implemented for this"
53 " Integrator class.");
56 void BilinearFormIntegrator::AssembleElementVector(
60 mfem_error(
"BilinearFormIntegrator::AssembleElementVector\n"
61 " is not implemented fot this class.");
65 void TransposeIntegrator::AssembleElementMatrix (
68 bfi -> AssembleElementMatrix (el, Trans, bfi_elmat);
73 void TransposeIntegrator::AssembleElementMatrix2 (
77 bfi -> AssembleElementMatrix2 (test_fe, trial_fe, Trans, bfi_elmat);
82 void TransposeIntegrator::AssembleFaceMatrix (
86 bfi -> AssembleFaceMatrix (el1, el2, Trans, bfi_elmat);
91 void LumpedIntegrator::AssembleElementMatrix (
94 bfi -> AssembleElementMatrix (el, Trans, elmat);
98 void InverseIntegrator::AssembleElementMatrix(
101 integrator->AssembleElementMatrix(el, Trans, elmat);
105 void SumIntegrator::AssembleElementMatrix(
108 MFEM_ASSERT(integrators.Size() > 0,
"empty SumIntegrator.");
110 integrators[0]->AssembleElementMatrix(el, Trans, elmat);
111 for (
int i = 1; i < integrators.Size(); i++)
113 integrators[i]->AssembleElementMatrix(el, Trans, elem_mat);
118 SumIntegrator::~SumIntegrator()
122 for (
int i = 0; i < integrators.Size(); i++)
124 delete integrators[i];
129 void MixedScalarIntegrator::AssembleElementMatrix2(
133 MFEM_ASSERT(this->VerifyFiniteElementTypes(trial_fe, test_fe),
134 this->FiniteElementTypeFailureMessage());
136 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
137 bool same_shapes = same_calc_shape && (&trial_fe == &test_fe);
139 #ifdef MFEM_THREAD_SAFE
140 Vector test_shape(test_nd);
154 elmat.
SetSize(test_nd, trial_nd);
159 int ir_order = this->GetIntegrationOrder(trial_fe, test_fe, Trans);
169 this->CalcTestShape(test_fe, Trans, test_shape);
170 this->CalcTrialShape(trial_fe, Trans, trial_shape);
176 w *= Q->Eval(Trans, ip);
180 #ifndef MFEM_THREAD_SAFE
188 void MixedVectorIntegrator::AssembleElementMatrix2(
192 MFEM_ASSERT(this->VerifyFiniteElementTypes(trial_fe, test_fe),
193 this->FiniteElementTypeFailureMessage());
195 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
197 bool same_shapes = same_calc_shape && (&trial_fe == &test_fe);
199 #ifdef MFEM_THREAD_SAFE
200 Vector V(VQ ? VQ->GetVDim() : 0);
201 Vector D(DQ ? DQ->GetVDim() : 0);
202 DenseMatrix M(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
207 V.SetSize(VQ ? VQ->GetVDim() : 0);
208 D.SetSize(DQ ? DQ->GetVDim() : 0);
209 M.SetSize(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
210 test_shape.SetSize(test_nd, spaceDim);
211 test_shape_tmp.
SetSize(test_nd, spaceDim);
215 trial_shape.
Reset(test_shape.Data(), trial_nd, spaceDim);
219 trial_shape.
SetSize(trial_nd, spaceDim);
222 elmat.
SetSize(test_nd, trial_nd);
227 int ir_order = this->GetIntegrationOrder(trial_fe, test_fe, Trans);
237 this->CalcTestShape(test_fe, Trans, test_shape);
240 this->CalcTrialShape(trial_fe, Trans, trial_shape);
247 MQ->Eval(M, Trans, ip);
249 Mult(test_shape, M, test_shape_tmp);
250 AddMultABt(test_shape_tmp, trial_shape, elmat);
254 DQ->Eval(D, Trans, ip);
260 VQ->Eval(V, Trans, ip);
262 for (
int j=0; j<test_nd; j++)
264 test_shape_tmp(j,0) = test_shape(j,1) * V(2) -
265 test_shape(j,2) * V(1);
266 test_shape_tmp(j,1) = test_shape(j,2) * V(0) -
267 test_shape(j,0) * V(2);
268 test_shape_tmp(j,2) = test_shape(j,0) * V(1) -
269 test_shape(j,1) * V(0);
271 AddMultABt(test_shape_tmp, trial_shape, elmat);
277 w *= Q -> Eval (Trans, ip);
289 #ifndef MFEM_THREAD_SAFE
297 void MixedScalarVectorIntegrator::AssembleElementMatrix2(
301 MFEM_ASSERT(this->VerifyFiniteElementTypes(trial_fe, test_fe),
302 this->FiniteElementTypeFailureMessage());
307 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
308 int sca_nd = sca_fe->
GetDof();
309 int vec_nd = vec_fe->
GetDof();
313 #ifdef MFEM_THREAD_SAFE
314 Vector V(VQ ? VQ->GetVDim() : 0);
317 Vector vshape_tmp(vec_nd);
319 V.SetSize(VQ ? VQ->GetVDim() : 0);
320 vshape.SetSize(vec_nd, spaceDim);
328 elmat.
SetSize(test_nd, trial_nd);
333 int ir_order = this->GetIntegrationOrder(trial_fe, test_fe, Trans);
343 this->CalcShape(*sca_fe, Trans, shape);
344 this->CalcVShape(*vec_fe, Trans, vshape);
348 VQ->Eval(V, Trans, ip);
351 if ( vec_fe->
GetDim() == 2 && cross_2d )
358 vshape.Mult(V,vshape_tmp);
364 void DiffusionIntegrator::AssembleElementMatrix
371 bool square = (dim == spaceDim);
374 #ifdef MFEM_THREAD_SAFE
375 DenseMatrix dshape(nd,dim), dshapedxt(nd,spaceDim), invdfdx(dim,spaceDim);
377 dshape.SetSize(nd,dim);
378 dshapedxt.SetSize(nd,spaceDim);
387 if (el.
Space() == FunctionSpace::Pk)
397 if (el.
Space() == FunctionSpace::rQk)
415 w = ip.
weight / (square ? w : w*w*w);
423 w *= Q->Eval(Trans, ip);
429 MQ->Eval(invdfdx, Trans, ip);
431 Mult(dshapedxt, invdfdx, dshape);
437 void DiffusionIntegrator::AssembleElementMatrix2(
441 int tr_nd = trial_fe.
GetDof();
442 int te_nd = test_fe.
GetDof();
445 bool square = (dim == spaceDim);
448 #ifdef MFEM_THREAD_SAFE
449 DenseMatrix dshape(tr_nd, dim), dshapedxt(tr_nd, spaceDim);
450 DenseMatrix te_dshape(te_nd, dim), te_dshapedxt(te_nd, spaceDim);
453 dshape.SetSize(tr_nd, dim);
454 dshapedxt.
SetSize(tr_nd, spaceDim);
455 te_dshape.SetSize(te_nd, dim);
456 te_dshapedxt.
SetSize(te_nd, spaceDim);
457 invdfdx.
SetSize(dim, spaceDim);
465 if (trial_fe.
Space() == FunctionSpace::Pk)
474 if (trial_fe.
Space() == FunctionSpace::rQk)
494 w = ip.
weight / (square ? w : w*w*w);
495 Mult(dshape, invdfdx, dshapedxt);
496 Mult(te_dshape, invdfdx, te_dshapedxt);
502 w *= Q->Eval(Trans, ip);
509 MQ->Eval(invdfdx, Trans, ip);
511 Mult(te_dshapedxt, invdfdx, te_dshape);
517 void DiffusionIntegrator::AssembleElementVector(
525 #ifdef MFEM_THREAD_SAFE
528 dshape.SetSize(nd,dim);
529 invdfdx.SetSize(dim);
533 pointflux.SetSize(dim);
541 if (el.
Space() == FunctionSpace::Pk)
551 if (el.
Space() == FunctionSpace::rQk)
573 dshape.MultTranspose(elfun, vec);
574 invdfdx.MultTranspose(vec, pointflux);
577 w *= Q->Eval(Tr, ip);
583 dshape.MultTranspose(elfun, pointflux);
584 invdfdx.MultTranspose(pointflux, vec);
585 MQ->Eval(mq, Tr, ip);
586 mq.
Mult(vec, pointflux);
589 invdfdx.Mult(pointflux, vec);
590 dshape.AddMult(vec, elvect);
594 void DiffusionIntegrator::ComputeElementFlux
598 int i, j, nd,
dim, spaceDim, fnd;
604 #ifdef MFEM_THREAD_SAFE
605 DenseMatrix dshape(nd,dim), invdfdx(dim, spaceDim);
607 dshape.SetSize(nd,dim);
608 invdfdx.
SetSize(dim, spaceDim);
611 pointflux.SetSize(spaceDim);
615 flux.
SetSize( fnd * spaceDim );
617 for (i = 0; i < fnd; i++)
621 dshape.MultTranspose(u, vec);
631 pointflux *= Q->Eval(Trans,ip);
633 for (j = 0; j < spaceDim; j++)
635 flux(fnd*j+i) = pointflux(j);
641 MFEM_ASSERT(dim == spaceDim,
"TODO");
642 MQ->Eval(invdfdx, Trans, ip);
643 invdfdx.
Mult(pointflux, vec);
644 for (j = 0; j <
dim; j++)
646 flux(fnd*j+i) = vec(j);
652 double DiffusionIntegrator::ComputeFluxEnergy
656 int nd = fluxelem.
GetDof();
660 #ifdef MFEM_THREAD_SAFE
665 pointflux.SetSize(spaceDim);
666 if (d_energy) { vec.SetSize(dim); }
669 int order = 2 * fluxelem.
GetOrder();
673 if (d_energy) { *d_energy = 0.0; }
681 for (
int k = 0; k < spaceDim; k++)
683 for (
int j = 0; j < nd; j++)
685 pointflux(k) += flux(k*nd+j)*shape(j);
694 double e = (pointflux * pointflux);
695 if (Q) { e *= Q->Eval(Trans, ip); }
700 MQ->Eval(mq, Trans, ip);
708 for (
int k = 0; k <
dim; k++)
710 (*d_energy)[k] += w * vec[k] * vec[k];
720 void MassIntegrator::AssembleElementMatrix
737 if (el.
Space() == FunctionSpace::rQk)
757 w *= Q -> Eval(Trans, ip);
764 void MassIntegrator::AssembleElementMatrix2(
768 int tr_nd = trial_fe.
GetDof();
769 int te_nd = test_fe.
GetDof();
774 shape.SetSize (tr_nd);
775 te_shape.SetSize (te_nd);
796 w *= Q -> Eval(Trans, ip);
805 void BoundaryMassIntegrator::AssembleFaceMatrix(
810 "support for interior faces is not implemented");
838 w *= Q -> Eval(*Trans.
Face, ip);
846 void ConvectionIntegrator::AssembleElementMatrix(
853 dshape.SetSize(nd,dim);
868 Q.Eval(Q_ir, Trans, *ir);
879 Q_ir.GetColumnReference(i, vec1);
882 adjJ.Mult(vec1, vec2);
883 dshape.Mult(vec2, BdFidxT);
890 void GroupConvectionIntegrator::AssembleElementMatrix(
897 dshape.SetSize(nd,dim);
900 grad.SetSize(nd,dim);
909 Q.Eval(Q_nodal, Trans, el.
GetNodes());
921 Mult(dshape, adjJ, grad);
926 for (
int k = 0; k < nd; k++)
928 double wsk = w*shape(k);
929 for (
int l = 0; l < nd; l++)
932 for (
int s = 0; s <
dim; s++)
934 a += Q_nodal(s,k)*grad(l,s);
943 void VectorMassIntegrator::AssembleElementMatrix
953 int vdim = (VQ) ? (VQ -> GetVDim()) : ((MQ) ? (MQ -> GetVDim()) : spaceDim);
957 partelmat.SetSize(nd);
964 mcoeff.SetSize(vdim);
972 if (el.
Space() == FunctionSpace::rQk)
995 VQ->Eval(vec, Trans, ip);
996 for (
int k = 0; k < vdim; k++)
998 elmat.
AddMatrix(norm*vec(k), partelmat, nd*k, nd*k);
1003 MQ->Eval(mcoeff, Trans, ip);
1004 for (
int i = 0; i < vdim; i++)
1005 for (
int j = 0; j < vdim; j++)
1007 elmat.
AddMatrix(norm*mcoeff(i,j), partelmat, nd*i, nd*j);
1014 norm *= Q->Eval(Trans, ip);
1017 for (
int k = 0; k < vdim; k++)
1025 void VectorMassIntegrator::AssembleElementMatrix2(
1029 int tr_nd = trial_fe.
GetDof();
1030 int te_nd = test_fe.
GetDof();
1037 vdim = (VQ) ? (VQ -> GetVDim()) : ((MQ) ? (MQ -> GetVDim()) : (dim));
1039 elmat.
SetSize(te_nd*vdim, tr_nd*vdim);
1040 shape.SetSize(tr_nd);
1041 te_shape.SetSize(te_nd);
1042 partelmat.SetSize(te_nd, tr_nd);
1049 mcoeff.SetSize(vdim);
1056 Trans.
OrderW() + Q_order);
1058 if (trial_fe.
Space() == FunctionSpace::rQk)
1078 MultVWt(te_shape, shape, partelmat);
1082 VQ->Eval(vec, Trans, ip);
1083 for (
int k = 0; k < vdim; k++)
1085 elmat.
AddMatrix(norm*vec(k), partelmat, te_nd*k, tr_nd*k);
1090 MQ->Eval(mcoeff, Trans, ip);
1091 for (
int i = 0; i < vdim; i++)
1092 for (
int j = 0; j < vdim; j++)
1094 elmat.
AddMatrix(norm*mcoeff(i,j), partelmat, te_nd*i, tr_nd*j);
1101 norm *= Q->Eval(Trans, ip);
1104 for (
int k = 0; k < vdim; k++)
1106 elmat.
AddMatrix(partelmat, te_nd*k, tr_nd*k);
1112 void VectorFEDivergenceIntegrator::AssembleElementMatrix2(
1116 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
1118 #ifdef MFEM_THREAD_SAFE
1119 Vector divshape(trial_nd), shape(test_nd);
1121 divshape.SetSize(trial_nd);
1125 elmat.
SetSize(test_nd, trial_nd);
1144 w *= Q->Eval(Trans, ip);
1151 void VectorFEWeakDivergenceIntegrator::AssembleElementMatrix2(
1155 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
1161 "Trial space must be H(Curl) and test space must be H_1");
1163 #ifdef MFEM_THREAD_SAFE
1169 dshape.SetSize(test_nd, dim);
1170 dshapedxt.
SetSize(test_nd, dim);
1171 vshape.
SetSize(trial_nd, dim);
1175 elmat.
SetSize(test_nd, trial_nd);
1217 Mult(dshape, invdfdx, dshapedxt);
1225 w *= Q->Eval(Trans, ip);
1233 void VectorFECurlIntegrator::AssembleElementMatrix2(
1237 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
1239 int dimc = (dim == 3) ? 3 : 1;
1243 "At least one of the finite elements must be in H(Curl)");
1245 int curl_nd, vec_nd;
1257 #ifdef MFEM_THREAD_SAFE
1262 curlshapeTrial.
SetSize(curl_nd, dimc);
1263 curlshapeTrial_dFT.
SetSize(curl_nd, dimc);
1264 vshapeTest.
SetSize(vec_nd, dimc);
1268 elmat.
SetSize(test_nd, trial_nd);
1315 w *= Q->Eval(Trans, ip);
1321 AddMultABt(vshapeTest, curlshapeTrial_dFT, elmat);
1325 AddMultABt(curlshapeTrial_dFT, vshapeTest, elmat);
1330 void DerivativeIntegrator::AssembleElementMatrix2 (
1337 int trial_nd = trial_fe.
GetDof();
1338 int test_nd = test_fe.
GetDof();
1343 elmat.
SetSize (test_nd,trial_nd);
1344 dshape.SetSize (trial_nd,dim);
1345 dshapedxt.SetSize(trial_nd,dim);
1346 dshapedxi.SetSize(trial_nd);
1347 invdfdx.SetSize(dim);
1348 shape.SetSize (test_nd);
1354 if (trial_fe.
Space() == FunctionSpace::Pk)
1363 if (trial_fe.
Space() == FunctionSpace::rQk)
1383 Mult (dshape, invdfdx, dshapedxt);
1387 for (l = 0; l < trial_nd; l++)
1389 dshapedxi(l) = dshapedxt(l,xi);
1392 shape *= Q.Eval(Trans,ip) * det * ip.
weight;
1397 void CurlCurlIntegrator::AssembleElementMatrix
1403 int dimc = (dim == 3) ? 3 : 1;
1406 #ifdef MFEM_THREAD_SAFE
1407 DenseMatrix curlshape(nd,dimc), curlshape_dFt(nd,dimc);
1409 curlshape.SetSize(nd,dimc);
1410 curlshape_dFt.
SetSize(nd,dimc);
1418 if (el.
Space() == FunctionSpace::Pk)
1451 w *= Q->Eval(Trans, ip);
1458 void CurlCurlIntegrator
1463 #ifdef MFEM_THREAD_SAFE
1470 projcurl.
Mult(u, flux);
1479 int nd = fluxelem.
GetDof();
1482 #ifdef MFEM_THREAD_SAFE
1486 pointflux.SetSize(dim);
1487 if (d_energy) { vec.SetSize(dim); }
1489 int order = 2 * fluxelem.
GetOrder();
1492 double energy = 0.0;
1493 if (d_energy) { *d_energy = 0.0; }
1512 double e = w * (pointflux * pointflux);
1521 #if ANISO_EXPERIMENTAL
1541 #if ANISO_EXPERIMENTAL
1545 int n = (int) round(pow(ir.
GetNPoints(), 1.0/3.0));
1549 for (
int k = 0; k < n; k++)
1550 for (
int l = 0; l < n; l++)
1551 for (
int m = 0; m < n; m++)
1553 Vector &vec = pfluxes[(k*n + l)*n + m];
1556 tmp = vec; tmp -= pfluxes[(k*n + l)*n + (m-1)];
1557 (*d_energy)[0] += (tmp * tmp);
1561 tmp = vec; tmp -= pfluxes[(k*n + (l-1))*n + m];
1562 (*d_energy)[1] += (tmp * tmp);
1566 tmp = vec; tmp -= pfluxes[((k-1)*n + l)*n + m];
1567 (*d_energy)[2] += (tmp * tmp);
1580 void VectorCurlCurlIntegrator::AssembleElementMatrix(
1585 int cld = (dim*(dim-1))/2;
1587 #ifdef MFEM_THREAD_SAFE
1588 DenseMatrix dshape_hat(dof, dim), dshape(dof, dim);
1591 dshape_hat.SetSize(dof, dim);
1593 curlshape.SetSize(dim*dof, cld);
1615 Mult(dshape_hat, Jadj, dshape);
1620 w *= Q->Eval(Trans, ip);
1627 double VectorCurlCurlIntegrator::GetElementEnergy(
1633 #ifdef MFEM_THREAD_SAFE
1634 DenseMatrix dshape_hat(dof, dim), Jadj(dim), grad_hat(dim), grad(dim);
1636 dshape_hat.SetSize(dof, dim);
1639 grad_hat.SetSize(dim);
1653 for (
int i = 0; i < ir->GetNPoints(); i++)
1658 MultAtB(elfun_mat, dshape_hat, grad_hat);
1664 Mult(grad_hat, Jadj, grad);
1668 double curl = grad(0,1) - grad(1,0);
1673 double curl_x = grad(2,1) - grad(1,2);
1674 double curl_y = grad(0,2) - grad(2,0);
1675 double curl_z = grad(1,0) - grad(0,1);
1676 w *= curl_x * curl_x + curl_y * curl_y + curl_z * curl_z;
1681 w *= Q->Eval(Tr, ip);
1687 elfun_mat.ClearExternalData();
1689 return 0.5 * energy;
1693 void VectorFEMassIntegrator::AssembleElementMatrix(
1703 #ifdef MFEM_THREAD_SAFE
1704 Vector D(VQ ? VQ->GetVDim() : 0);
1706 DenseMatrix K(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
1708 trial_vshape.
SetSize(dof, spaceDim);
1709 D.SetSize(VQ ? VQ->GetVDim() : 0);
1710 K.SetSize(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
1712 DenseMatrix tmp(trial_vshape.Height(), K.Width());
1736 MQ->Eval(K, Trans, ip);
1738 Mult(trial_vshape,K,tmp);
1743 VQ->Eval(D, Trans, ip);
1751 w *= Q -> Eval (Trans, ip);
1758 void VectorFEMassIntegrator::AssembleElementMatrix2(
1762 if ( test_fe.
GetRangeType() == FiniteElement::SCALAR && VQ )
1766 int trial_dof = trial_fe.
GetDof();
1767 int test_dof = test_fe.
GetDof();
1771 mfem_error(
"VectorFEMassIntegrator::AssembleElementMatrix2(...)\n"
1772 " is not implemented for tensor materials");
1774 #ifdef MFEM_THREAD_SAFE
1779 trial_vshape.
SetSize(trial_dof, dim);
1784 elmat.
SetSize (test_dof, trial_dof);
1804 VQ->Eval(D, Trans, ip);
1807 for (
int d = 0; d <
dim; d++)
1809 for (
int j = 0; j < test_dof; j++)
1811 for (
int k = 0; k < trial_dof; k++)
1813 elmat(j, k) += D[d] * shape(j) * trial_vshape(k, d);
1819 else if ( test_fe.
GetRangeType() == FiniteElement::SCALAR )
1823 int trial_dof = trial_fe.
GetDof();
1824 int test_dof = test_fe.
GetDof();
1828 mfem_error(
"VectorFEMassIntegrator::AssembleElementMatrix2(...)\n"
1829 " is not implemented for vector/tensor permeability");
1831 #ifdef MFEM_THREAD_SAFE
1835 trial_vshape.
SetSize(trial_dof, dim);
1839 elmat.
SetSize (dim*test_dof, trial_dof);
1861 w *= Q -> Eval (Trans, ip);
1864 for (
int d = 0; d <
dim; d++)
1866 for (
int j = 0; j < test_dof; j++)
1868 for (
int k = 0; k < trial_dof; k++)
1870 elmat(d * test_dof + j, k) += w * shape(j) * trial_vshape(k, d);
1880 int trial_dof = trial_fe.
GetDof();
1881 int test_dof = test_fe.
GetDof();
1885 mfem_error(
"VectorFEMassIntegrator::AssembleElementMatrix2(...)\n"
1886 " is not implemented for vector/tensor permeability");
1888 #ifdef MFEM_THREAD_SAFE
1892 trial_vshape.
SetSize(trial_dof, dim);
1893 test_vshape.
SetSize(test_dof,dim);
1896 elmat.
SetSize (test_dof, trial_dof);
1918 w *= Q -> Eval (Trans, ip);
1921 for (
int d = 0; d <
dim; d++)
1923 for (
int j = 0; j < test_dof; j++)
1925 for (
int k = 0; k < trial_dof; k++)
1927 elmat(j, k) += w * test_vshape(j, d) * trial_vshape(k, d);
1935 void VectorDivergenceIntegrator::AssembleElementMatrix2(
1942 int trial_dof = trial_fe.
GetDof();
1943 int test_dof = test_fe.
GetDof();
1946 dshape.SetSize (trial_dof, dim);
1947 gshape.SetSize (trial_dof, dim);
1949 divshape.SetSize (dim*trial_dof);
1950 shape.SetSize (test_dof);
1952 elmat.
SetSize (test_dof, dim*trial_dof);
1963 for (
int i = 0; i < ir -> GetNPoints(); i++)
1973 Mult (dshape, Jadj, gshape);
1975 gshape.GradToDiv (divshape);
1980 c *= Q -> Eval (Trans, ip);
1990 void DivDivIntegrator::AssembleElementMatrix(
1998 #ifdef MFEM_THREAD_SAFE
2014 for (
int i = 0; i < ir -> GetNPoints(); i++)
2025 c *= Q -> Eval (Trans, ip);
2034 void VectorDiffusionIntegrator::AssembleElementMatrix(
2046 Jinv. SetSize (dim);
2047 dshape.SetSize (dof, dim);
2048 gshape.SetSize (dof, dim);
2049 pelmat.SetSize (dof);
2056 if (el.
Space() == FunctionSpace::rQk)
2068 for (
int i = 0; i < ir -> GetNPoints(); i++)
2078 Mult (dshape, Jinv, gshape);
2084 norm *= Q -> Eval (Trans, ip);
2089 for (
int d = 0; d <
dim; d++)
2091 for (
int k = 0; k < dof; k++)
2092 for (
int l = 0; l < dof; l++)
2094 elmat (dof*d+k, dof*d+l) += pelmat (k, l);
2100 void VectorDiffusionIntegrator::AssembleElementVector(
2109 dshape.SetSize(dof, dim);
2110 pelmat.SetSize(dim);
2111 gshape.SetSize(dim);
2122 ir = (el.
Space() == FunctionSpace::rQk) ?
2128 for (
int i = 0; i < ir->GetNPoints(); i++)
2137 w *= Q->Eval(Tr, ip);
2144 MultAtB(mat_in, dshape, pelmat);
2145 MultABt(pelmat, gshape, Jinv);
2151 void ElasticityIntegrator::AssembleElementMatrix(
2158 #ifdef MFEM_THREAD_SAFE
2159 DenseMatrix dshape(dof, dim), Jinv(dim), gshape(dof, dim), pelmat(dof);
2160 Vector divshape(dim*dof);
2163 dshape.SetSize(dof, dim);
2164 gshape.SetSize(dof, dim);
2180 for (
int i = 0; i < ir -> GetNPoints(); i++)
2189 Mult(dshape, Jinv, gshape);
2191 gshape.GradToDiv (divshape);
2193 M = mu->Eval(Trans, ip);
2196 L = lambda->Eval(Trans, ip);
2211 for (
int d = 0; d <
dim; d++)
2213 for (
int k = 0; k < dof; k++)
2214 for (
int l = 0; l < dof; l++)
2216 elmat (dof*d+k, dof*d+l) += (M * w) * pelmat(k, l);
2219 for (
int i = 0; i <
dim; i++)
2220 for (
int j = 0; j <
dim; j++)
2222 for (
int k = 0; k < dof; k++)
2223 for (
int l = 0; l < dof; l++)
2224 elmat(dof*i+k, dof*j+l) +=
2225 (M * w) * gshape(k, j) * gshape(l, i);
2237 int dim, ndof1, ndof2;
2243 Vector vu(dim), nor(dim);
2254 shape1.SetSize(ndof1);
2255 shape2.SetSize(ndof2);
2271 if (el1.
Space() == FunctionSpace::Pk)
2292 u->Eval(vu, *Trans.
Elem1, eip1);
2296 nor(0) = 2*eip1.
x - 1.0;
2304 a = 0.5 *
alpha * un;
2305 b = beta * fabs(un);
2313 if (un >= 0.0 && ndof2)
2316 rho_p = rho->Eval(*Trans.
Elem2, eip2);
2320 rho_p = rho->Eval(*Trans.
Elem1, eip1);
2329 for (
int i = 0; i < ndof1; i++)
2330 for (
int j = 0; j < ndof1; j++)
2332 elmat(i, j) += w * shape1(i) * shape1(j);
2341 for (
int i = 0; i < ndof2; i++)
2342 for (
int j = 0; j < ndof1; j++)
2344 elmat(ndof1+i, j) -= w * shape2(i) * shape1(j);
2350 for (
int i = 0; i < ndof2; i++)
2351 for (
int j = 0; j < ndof2; j++)
2353 elmat(ndof1+i, ndof1+j) += w * shape2(i) * shape2(j);
2356 for (
int i = 0; i < ndof1; i++)
2357 for (
int j = 0; j < ndof2; j++)
2359 elmat(i, ndof1+j) -= w * shape1(i) * shape2(j);
2366 void DGDiffusionIntegrator::AssembleFaceMatrix(
2370 int dim, ndof1, ndof2, ndofs;
2371 bool kappa_is_nonzero = (
kappa != 0.);
2386 shape1.SetSize(ndof1);
2387 dshape1.SetSize(ndof1, dim);
2388 dshape1dn.SetSize(ndof1);
2392 shape2.SetSize(ndof2);
2393 dshape2.SetSize(ndof2, dim);
2394 dshape2dn.SetSize(ndof2);
2401 ndofs = ndof1 + ndof2;
2404 if (kappa_is_nonzero)
2437 nor(0) = 2*eip1.
x - 1.0;
2456 w *= Q->Eval(*Trans.
Elem1, eip1);
2463 MQ->Eval(mq, *Trans.
Elem1, eip1);
2464 mq.MultTranspose(nh, ni);
2468 if (kappa_is_nonzero)
2483 dshape1.Mult(nh, dshape1dn);
2484 for (
int i = 0; i < ndof1; i++)
2485 for (
int j = 0; j < ndof1; j++)
2487 elmat(i, j) += shape1(i) * dshape1dn(j);
2501 w *= Q->Eval(*Trans.
Elem2, eip2);
2508 MQ->Eval(mq, *Trans.
Elem2, eip2);
2509 mq.MultTranspose(nh, ni);
2513 if (kappa_is_nonzero)
2518 dshape2.Mult(nh, dshape2dn);
2520 for (
int i = 0; i < ndof1; i++)
2521 for (
int j = 0; j < ndof2; j++)
2523 elmat(i, ndof1 + j) += shape1(i) * dshape2dn(j);
2526 for (
int i = 0; i < ndof2; i++)
2527 for (
int j = 0; j < ndof1; j++)
2529 elmat(ndof1 + i, j) -= shape2(i) * dshape1dn(j);
2532 for (
int i = 0; i < ndof2; i++)
2533 for (
int j = 0; j < ndof2; j++)
2535 elmat(ndof1 + i, ndof1 + j) -= shape2(i) * dshape2dn(j);
2539 if (kappa_is_nonzero)
2543 for (
int i = 0; i < ndof1; i++)
2545 const double wsi = wq*shape1(i);
2546 for (
int j = 0; j <= i; j++)
2548 jmat(i, j) += wsi * shape1(j);
2553 for (
int i = 0; i < ndof2; i++)
2555 const int i2 = ndof1 + i;
2556 const double wsi = wq*shape2(i);
2557 for (
int j = 0; j < ndof1; j++)
2559 jmat(i2, j) -= wsi * shape1(j);
2561 for (
int j = 0; j <= i; j++)
2563 jmat(i2, ndof1 + j) += wsi * shape2(j);
2571 if (kappa_is_nonzero)
2573 for (
int i = 0; i < ndofs; i++)
2575 for (
int j = 0; j < i; j++)
2577 double aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
2578 elmat(i,j) = sigma*aji - aij + mij;
2579 elmat(j,i) = sigma*aij - aji + mij;
2581 elmat(i,i) = (sigma - 1.)*elmat(i,i) + jmat(i,i);
2586 for (
int i = 0; i < ndofs; i++)
2588 for (
int j = 0; j < i; j++)
2590 double aij = elmat(i,j), aji = elmat(j,i);
2591 elmat(i,j) = sigma*aji - aij;
2592 elmat(j,i) = sigma*aij - aji;
2594 elmat(i,i) *= (sigma - 1.);
2601 void DGElasticityIntegrator::AssembleBlock(
2602 const int dim,
const int row_ndofs,
const int col_ndofs,
2603 const int row_offset,
const int col_offset,
2604 const double jmatcoef,
const Vector &col_nL,
const Vector &col_nM,
2609 for (
int jm = 0, j = col_offset; jm <
dim; ++jm)
2611 for (
int jdof = 0; jdof < col_ndofs; ++jdof, ++j)
2613 const double t2 = col_dshape_dnM(jdof);
2614 for (
int im = 0, i = row_offset; im <
dim; ++im)
2616 const double t1 = col_dshape(jdof, jm) * col_nL(im);
2617 const double t3 = col_dshape(jdof, im) * col_nM(jm);
2618 const double tt = t1 + ((im == jm) ? t2 : 0.0) + t3;
2619 for (
int idof = 0; idof < row_ndofs; ++idof, ++i)
2621 elmat(i, j) += row_shape(idof) * tt;
2627 if (jmatcoef == 0.0) {
return; }
2629 for (
int d = 0; d <
dim; ++d)
2631 const int jo = col_offset + d*col_ndofs;
2632 const int io = row_offset + d*row_ndofs;
2633 for (
int jdof = 0, j = jo; jdof < col_ndofs; ++jdof, ++j)
2635 const double sj = jmatcoef * col_shape(jdof);
2636 for (
int i = max(io,j), idof = i - io; idof < row_ndofs; ++idof, ++i)
2638 jmat(i, j) += row_shape(idof) * sj;
2644 void DGElasticityIntegrator::AssembleFaceMatrix(
2648 #ifdef MFEM_THREAD_SAFE
2657 Vector dshape1_dnM, dshape2_dnM;
2662 const int ndofs1 = el1.
GetDof();
2664 const int nvdofs = dim*(ndofs1 + ndofs2);
2674 const bool kappa_is_nonzero = (
kappa != 0.0);
2675 if (kappa_is_nonzero)
2684 dshape1_ps.
SetSize(ndofs1, dim);
2694 dshape2_ps.
SetSize(ndofs2, dim);
2708 for (
int pind = 0; pind < ir->
GetNPoints(); ++pind)
2720 Mult(dshape1, adjJ, dshape1_ps);
2724 nor(0) = 2*eip1.
x - 1.0;
2739 Mult(dshape2, adjJ, dshape2_ps);
2743 const double wL2 = w2 * lambda->Eval(*Trans.
Elem2, eip2);
2744 const double wM2 = w2 * mu->Eval(*Trans.
Elem2, eip2);
2747 wLM = (wL2 + 2.0*wM2);
2748 dshape2_ps.
Mult(nM2, dshape2_dnM);
2758 const double wL1 = w1 * lambda->Eval(*Trans.
Elem1, eip1);
2759 const double wM1 = w1 * mu->Eval(*Trans.
Elem1, eip1);
2762 wLM += (wL1 + 2.0*wM1);
2763 dshape1_ps.
Mult(nM1, dshape1_dnM);
2766 const double jmatcoef =
kappa * (nor*nor) * wLM;
2770 dim, ndofs1, ndofs1, 0, 0, jmatcoef, nL1, nM1,
2771 shape1, shape1, dshape1_dnM, dshape1_ps, elmat, jmat);
2773 if (ndofs2 == 0) {
continue; }
2780 dim, ndofs1, ndofs2, 0, dim*ndofs1, jmatcoef, nL2, nM2,
2781 shape1, shape2, dshape2_dnM, dshape2_ps, elmat, jmat);
2784 dim, ndofs2, ndofs1, dim*ndofs1, 0, jmatcoef, nL1, nM1,
2785 shape2, shape1, dshape1_dnM, dshape1_ps, elmat, jmat);
2788 dim, ndofs2, ndofs2, dim*ndofs1, dim*ndofs1, jmatcoef, nL2, nM2,
2789 shape2, shape2, dshape2_dnM, dshape2_ps, elmat, jmat);
2793 if (kappa_is_nonzero)
2795 for (
int i = 0; i < nvdofs; ++i)
2797 for (
int j = 0; j < i; ++j)
2799 double aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
2800 elmat(i,j) =
alpha*aji - aij + mij;
2801 elmat(j,i) =
alpha*aij - aji + mij;
2803 elmat(i,i) = (
alpha - 1.)*elmat(i,i) + jmat(i,i);
2808 for (
int i = 0; i < nvdofs; ++i)
2810 for (
int j = 0; j < i; ++j)
2812 double aij = elmat(i,j), aji = elmat(j,i);
2813 elmat(i,j) =
alpha*aji - aij;
2814 elmat(j,i) =
alpha*aij - aji;
2816 elmat(i,i) *= (
alpha - 1.);
2822 void TraceJumpIntegrator::AssembleFaceMatrix(
2827 int i, j, face_ndof, ndof1, ndof2;
2832 face_ndof = trial_face_fe.
GetDof();
2833 ndof1 = test_fe1.
GetDof();
2835 face_shape.SetSize(face_ndof);
2836 shape1.SetSize(ndof1);
2840 ndof2 = test_fe2.
GetDof();
2841 shape2.SetSize(ndof2);
2848 elmat.
SetSize(ndof1 + ndof2, face_ndof);
2863 if (trial_face_fe.
GetMapType() == FiniteElement::VALUE)
2876 trial_face_fe.
CalcShape(ip, face_shape);
2889 if (trial_face_fe.
GetMapType() == FiniteElement::VALUE)
2894 for (i = 0; i < ndof1; i++)
2895 for (j = 0; j < face_ndof; j++)
2897 elmat(i, j) += shape1(i) * face_shape(j);
2902 for (i = 0; i < ndof2; i++)
2903 for (j = 0; j < face_ndof; j++)
2905 elmat(ndof1+i, j) -= shape2(i) * face_shape(j);
2911 void NormalTraceJumpIntegrator::AssembleFaceMatrix(
2916 int i, j, face_ndof, ndof1, ndof2,
dim;
2919 MFEM_VERIFY(trial_face_fe.
GetMapType() == FiniteElement::VALUE,
"");
2921 face_ndof = trial_face_fe.
GetDof();
2922 ndof1 = test_fe1.
GetDof();
2925 face_shape.SetSize(face_ndof);
2926 normal.SetSize(dim);
2927 shape1.SetSize(ndof1,dim);
2928 shape1_n.SetSize(ndof1);
2932 ndof2 = test_fe2.
GetDof();
2933 shape2.SetSize(ndof2,dim);
2934 shape2_n.SetSize(ndof2);
2941 elmat.
SetSize(ndof1 + ndof2, face_ndof);
2964 trial_face_fe.
CalcShape(ip, face_shape);
2970 shape1.Mult(normal, shape1_n);
2978 shape2.Mult(normal, shape2_n);
2981 for (i = 0; i < ndof1; i++)
2982 for (j = 0; j < face_ndof; j++)
2984 elmat(i, j) -= shape1_n(i) * face_shape(j);
2989 for (i = 0; i < ndof2; i++)
2990 for (j = 0; j < face_ndof; j++)
2992 elmat(ndof1+i, j) += shape2_n(i) * face_shape(j);
2999 void NormalInterpolator::AssembleElementMatrix2(
3008 for (
int i = 0; i < ran_nodes.Size(); i++)
3014 for (
int j = 0; j < shape.Size(); j++)
3016 for (
int d = 0; d < spaceDim; d++)
3018 elmat(i, j+d*shape.Size()) = shape(j)*n(d);
int GetNPoints() const
Returns the number of the points in the integration rule.
Abstract class for Finite Elements.
void MultABt(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt)
Multiply a matrix A with the transpose of a matrix B: A*Bt.
int GetDim() const
Returns the reference space dimension for the finite element.
void AddMultVWt(const Vector &v, const Vector &w, DenseMatrix &VWt)
VWt += v w^t.
Class for an integration rule - an Array of IntegrationPoint.
void NewDataAndSize(double *d, int s)
Set the Vector data and size, deleting the old data, if owned.
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 MultVWt(const Vector &v, const Vector &w, DenseMatrix &VWt)
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
void SetSize(int s)
Resize the vector to size s.
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
double InnerProduct(const double *x, const double *y) const
Compute y^t A x.
void CalcAdjugate(const DenseMatrix &a, DenseMatrix &adja)
int GetOrder() const
Returns the order of the finite element.
Data type dense matrix using column-major storage.
int Space() const
Returns the type of space on each element.
void AddMult_a_ABt(double a, const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt)
ABt += a * A * B^t.
double * GetData() const
Returns the matrix data array.
void CalcOrtho(const DenseMatrix &J, Vector &n)
virtual void ProjectCurl(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
void MultTranspose(const double *x, double *y) const
Multiply a vector with the transpose matrix.
void Reset(double *d, int h, int w)
Change the data array and the size of the DenseMatrix.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
void AddMult_a_VWt(const double a, const Vector &v, const Vector &w, DenseMatrix &VWt)
VWt += a * v w^t.
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...
For scalar fields; preserves point values.
void Invert()
Replaces the current matrix with its inverse.
const IntegrationRule & GetNodes() const
void AddMult_a_VVt(const double a, const Vector &v, DenseMatrix &VVt)
VVt += a * v v^t.
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
int GetGeomType() const
Returns the Geometry::Type of the reference element.
void Transpose()
(*this) = (*this)^t
void MultVVt(const Vector &v, DenseMatrix &vvt)
Make a matrix from a vector V.Vt.
void AddMultABt(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt)
ABt += A * B^t.
int GetDof() const
Returns the number of degrees of freedom in the finite element.
void mfem_error(const char *msg)
void MultAAt(const DenseMatrix &a, DenseMatrix &aat)
Calculate the matrix A.At.
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 AddMatrix(DenseMatrix &A, int ro, int co)
Perform (ro+i,co+j)+=A(i,j) for 0<=i<A.Height, 0<=j<A.Width.
void SetDataAndSize(double *d, int s)
Set the Vector data and size.
Vector & Set(const double a, const Vector &x)
(*this) = a * x
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 AddMultADBt(const DenseMatrix &A, const Vector &D, const DenseMatrix &B, DenseMatrix &ADBt)
ADBt = A D B^t, where D is diagonal.
Class for integration point with weight.
void GradToCurl(DenseMatrix &curl)
void MultAtB(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &AtB)
Multiply the transpose of a matrix A with a matrix B: At*B.
void Mult(const double *x, double *y) const
Matrix vector multiplication.
IntegrationRules RefinedIntRules(1, Quadrature1D::GaussLegendre)
A global object with all refined integration rules.
void AddMultADAt(const DenseMatrix &A, const Vector &D, DenseMatrix &ADAt)
ADAt += A D A^t, where D is diagonal.
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
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...
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
void AddMult_a_AAt(double a, const DenseMatrix &A, DenseMatrix &AAt)
AAt += a * A * A^t.
void Neg()
(*this) = -(*this)