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];
130 void DiffusionIntegrator::AssembleElementMatrix
137 bool square = (dim == spaceDim);
140 #ifdef MFEM_THREAD_SAFE
141 DenseMatrix dshape(nd,dim), dshapedxt(nd,spaceDim), invdfdx(dim,spaceDim);
143 dshape.SetSize(nd,dim);
144 dshapedxt.SetSize(nd,spaceDim);
153 if (el.
Space() == FunctionSpace::Pk)
163 if (el.
Space() == FunctionSpace::rQk)
184 w = ip.
weight / (square ? w : w*w*w);
185 Mult(dshape, invdfdx, dshapedxt);
190 w *= Q->Eval(Trans, ip);
196 MQ->Eval(invdfdx, Trans, ip);
198 Mult(dshapedxt, invdfdx, dshape);
204 void DiffusionIntegrator::AssembleElementMatrix2(
208 int tr_nd = trial_fe.
GetDof();
209 int te_nd = test_fe.
GetDof();
212 bool square = (dim == spaceDim);
215 #ifdef MFEM_THREAD_SAFE
216 DenseMatrix dshape(tr_nd, dim), dshapedxt(tr_nd, spaceDim);
217 DenseMatrix te_dshape(te_nd, dim), te_dshapedxt(te_nd, spaceDim);
220 dshape.SetSize(tr_nd, dim);
221 dshapedxt.
SetSize(tr_nd, spaceDim);
222 te_dshape.SetSize(te_nd, dim);
223 te_dshapedxt.
SetSize(te_nd, spaceDim);
224 invdfdx.
SetSize(dim, spaceDim);
232 if (trial_fe.
Space() == FunctionSpace::Pk)
241 if (trial_fe.
Space() == FunctionSpace::rQk)
261 w = ip.
weight / (square ? w : w*w*w);
262 Mult(dshape, invdfdx, dshapedxt);
263 Mult(te_dshape, invdfdx, te_dshapedxt);
269 w *= Q->Eval(Trans, ip);
276 MQ->Eval(invdfdx, Trans, ip);
278 Mult(te_dshapedxt, invdfdx, te_dshape);
284 void DiffusionIntegrator::AssembleElementVector(
292 #ifdef MFEM_THREAD_SAFE
295 dshape.SetSize(nd,dim);
296 invdfdx.SetSize(dim);
300 pointflux.SetSize(dim);
308 if (el.
Space() == FunctionSpace::Pk)
318 if (el.
Space() == FunctionSpace::rQk)
340 dshape.MultTranspose(elfun, vec);
341 invdfdx.MultTranspose(vec, pointflux);
344 w *= Q->Eval(Tr, ip);
350 dshape.MultTranspose(elfun, pointflux);
351 invdfdx.MultTranspose(pointflux, vec);
352 MQ->Eval(mq, Tr, ip);
353 mq.
Mult(vec, pointflux);
356 invdfdx.Mult(pointflux, vec);
357 dshape.AddMult(vec, elvect);
361 void DiffusionIntegrator::ComputeElementFlux
365 int i, j, nd,
dim, spaceDim, fnd;
371 #ifdef MFEM_THREAD_SAFE
372 DenseMatrix dshape(nd,dim), invdfdx(dim, spaceDim);
374 dshape.SetSize(nd,dim);
375 invdfdx.
SetSize(dim, spaceDim);
378 pointflux.SetSize(spaceDim);
382 flux.
SetSize( fnd * spaceDim );
384 for (i = 0; i < fnd; i++)
388 dshape.MultTranspose(u, vec);
398 pointflux *= Q->Eval(Trans,ip);
400 for (j = 0; j < spaceDim; j++)
402 flux(fnd*j+i) = pointflux(j);
408 MFEM_ASSERT(dim == spaceDim,
"TODO");
409 MQ->Eval(invdfdx, Trans, ip);
410 invdfdx.
Mult(pointflux, vec);
411 for (j = 0; j <
dim; j++)
413 flux(fnd*j+i) = vec(j);
419 double DiffusionIntegrator::ComputeFluxEnergy
423 int nd = fluxelem.
GetDof();
427 #ifdef MFEM_THREAD_SAFE
432 pointflux.SetSize(spaceDim);
433 if (d_energy) { vec.SetSize(dim); }
436 int order = 2 * fluxelem.
GetOrder();
440 if (d_energy) { *d_energy = 0.0; }
448 for (
int k = 0; k < spaceDim; k++)
450 for (
int j = 0; j < nd; j++)
452 pointflux(k) += flux(k*nd+j)*shape(j);
461 double e = (pointflux * pointflux);
462 if (Q) { e *= Q->Eval(Trans, ip); }
467 MQ->Eval(mq, Trans, ip);
475 for (
int k = 0; k <
dim; k++)
477 (*d_energy)[k] += w * vec[k] * vec[k];
487 void MassIntegrator::AssembleElementMatrix
504 if (el.
Space() == FunctionSpace::rQk)
524 w *= Q -> Eval(Trans, ip);
531 void MassIntegrator::AssembleElementMatrix2(
535 int tr_nd = trial_fe.
GetDof();
536 int te_nd = test_fe.
GetDof();
541 shape.SetSize (tr_nd);
542 te_shape.SetSize (te_nd);
563 w *= Q -> Eval(Trans, ip);
572 void BoundaryMassIntegrator::AssembleFaceMatrix(
577 "support for interior faces is not implemented");
605 w *= Q -> Eval(*Trans.
Face, ip);
613 void ConvectionIntegrator::AssembleElementMatrix(
620 dshape.SetSize(nd,dim);
635 Q.Eval(Q_ir, Trans, *ir);
646 Q_ir.GetColumnReference(i, vec1);
649 adjJ.Mult(vec1, vec2);
650 dshape.Mult(vec2, BdFidxT);
657 void GroupConvectionIntegrator::AssembleElementMatrix(
664 dshape.SetSize(nd,dim);
667 grad.SetSize(nd,dim);
676 Q.Eval(Q_nodal, Trans, el.
GetNodes());
688 Mult(dshape, adjJ, grad);
693 for (
int k = 0; k < nd; k++)
695 double wsk = w*shape(k);
696 for (
int l = 0; l < nd; l++)
699 for (
int s = 0; s <
dim; s++)
701 a += Q_nodal(s,k)*grad(l,s);
710 void VectorMassIntegrator::AssembleElementMatrix
720 int vdim = (VQ) ? (VQ -> GetVDim()) : ((MQ) ? (MQ -> GetVDim()) : spaceDim);
724 partelmat.SetSize(nd);
731 mcoeff.SetSize(vdim);
739 if (el.
Space() == FunctionSpace::rQk)
762 VQ->Eval(vec, Trans, ip);
763 for (
int k = 0; k < vdim; k++)
765 elmat.
AddMatrix(norm*vec(k), partelmat, nd*k, nd*k);
770 MQ->Eval(mcoeff, Trans, ip);
771 for (
int i = 0; i < vdim; i++)
772 for (
int j = 0; j < vdim; j++)
774 elmat.
AddMatrix(norm*mcoeff(i,j), partelmat, nd*i, nd*j);
781 norm *= Q->Eval(Trans, ip);
784 for (
int k = 0; k < vdim; k++)
792 void VectorMassIntegrator::AssembleElementMatrix2(
796 int tr_nd = trial_fe.
GetDof();
797 int te_nd = test_fe.
GetDof();
804 vdim = (VQ) ? (VQ -> GetVDim()) : ((MQ) ? (MQ -> GetVDim()) : (dim));
806 elmat.
SetSize(te_nd*vdim, tr_nd*vdim);
807 shape.SetSize(tr_nd);
808 te_shape.SetSize(te_nd);
809 partelmat.SetSize(te_nd, tr_nd);
816 mcoeff.SetSize(vdim);
823 Trans.
OrderW() + Q_order);
825 if (trial_fe.
Space() == FunctionSpace::rQk)
845 MultVWt(te_shape, shape, partelmat);
849 VQ->Eval(vec, Trans, ip);
850 for (
int k = 0; k < vdim; k++)
852 elmat.
AddMatrix(norm*vec(k), partelmat, te_nd*k, tr_nd*k);
857 MQ->Eval(mcoeff, Trans, ip);
858 for (
int i = 0; i < vdim; i++)
859 for (
int j = 0; j < vdim; j++)
861 elmat.
AddMatrix(norm*mcoeff(i,j), partelmat, te_nd*i, tr_nd*j);
868 norm *= Q->Eval(Trans, ip);
871 for (
int k = 0; k < vdim; k++)
873 elmat.
AddMatrix(partelmat, te_nd*k, tr_nd*k);
879 void VectorFEDivergenceIntegrator::AssembleElementMatrix2(
883 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
885 #ifdef MFEM_THREAD_SAFE
886 Vector divshape(trial_nd), shape(test_nd);
888 divshape.SetSize(trial_nd);
892 elmat.
SetSize(test_nd, trial_nd);
911 w *= Q->Eval(Trans, ip);
918 void VectorFECurlIntegrator::AssembleElementMatrix2(
922 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
925 #ifdef MFEM_THREAD_SAFE
930 curlshapeTrial.
SetSize(trial_nd, dim);
931 curlshapeTrial_dFT.
SetSize(trial_nd, dim);
932 vshapeTest.
SetSize(test_nd, dim);
935 elmat.
SetSize(test_nd, trial_nd);
957 w *= Q->Eval(Trans, ip);
960 AddMultABt(vshapeTest, curlshapeTrial_dFT, elmat);
964 void DerivativeIntegrator::AssembleElementMatrix2 (
971 int trial_nd = trial_fe.
GetDof();
972 int test_nd = test_fe.
GetDof();
977 elmat.
SetSize (test_nd,trial_nd);
978 dshape.SetSize (trial_nd,dim);
979 dshapedxt.SetSize(trial_nd,dim);
980 dshapedxi.SetSize(trial_nd);
981 invdfdx.SetSize(dim);
982 shape.SetSize (test_nd);
988 if (trial_fe.
Space() == FunctionSpace::Pk)
997 if (trial_fe.
Space() == FunctionSpace::rQk)
1017 Mult (dshape, invdfdx, dshapedxt);
1021 for (l = 0; l < trial_nd; l++)
1023 dshapedxi(l) = dshapedxt(l,xi);
1026 shape *= Q.Eval(Trans,ip) * det * ip.
weight;
1031 void CurlCurlIntegrator::AssembleElementMatrix
1037 int dimc = (dim == 3) ? 3 : 1;
1040 #ifdef MFEM_THREAD_SAFE
1041 DenseMatrix curlshape(nd,dimc), curlshape_dFt(nd,dimc);
1043 curlshape.SetSize(nd,dimc);
1044 curlshape_dFt.
SetSize(nd,dimc);
1052 if (el.
Space() == FunctionSpace::Pk)
1085 w *= Q->Eval(Trans, ip);
1092 void CurlCurlIntegrator
1097 #ifdef MFEM_THREAD_SAFE
1104 projcurl.
Mult(u, flux);
1113 int nd = fluxelem.
GetDof();
1116 #ifdef MFEM_THREAD_SAFE
1120 pointflux.SetSize(dim);
1121 if (d_energy) { vec.SetSize(dim); }
1123 int order = 2 * fluxelem.
GetOrder();
1126 double energy = 0.0;
1127 if (d_energy) { *d_energy = 0.0; }
1146 double e = w * (pointflux * pointflux);
1155 #if ANISO_EXPERIMENTAL
1175 #if ANISO_EXPERIMENTAL
1179 int n = (int) round(pow(ir.
GetNPoints(), 1.0/3.0));
1183 for (
int k = 0; k < n; k++)
1184 for (
int l = 0; l < n; l++)
1185 for (
int m = 0; m < n; m++)
1187 Vector &vec = pfluxes[(k*n + l)*n + m];
1190 tmp = vec; tmp -= pfluxes[(k*n + l)*n + (m-1)];
1191 (*d_energy)[0] += (tmp * tmp);
1195 tmp = vec; tmp -= pfluxes[(k*n + (l-1))*n + m];
1196 (*d_energy)[1] += (tmp * tmp);
1200 tmp = vec; tmp -= pfluxes[((k-1)*n + l)*n + m];
1201 (*d_energy)[2] += (tmp * tmp);
1214 void VectorCurlCurlIntegrator::AssembleElementMatrix(
1219 int cld = (dim*(dim-1))/2;
1221 #ifdef MFEM_THREAD_SAFE
1222 DenseMatrix dshape_hat(dof, dim), dshape(dof, dim);
1225 dshape_hat.SetSize(dof, dim);
1227 curlshape.SetSize(dim*dof, cld);
1249 Mult(dshape_hat, Jadj, dshape);
1254 w *= Q->Eval(Trans, ip);
1261 double VectorCurlCurlIntegrator::GetElementEnergy(
1267 #ifdef MFEM_THREAD_SAFE
1268 DenseMatrix dshape_hat(dof, dim), Jadj(dim), grad_hat(dim), grad(dim);
1270 dshape_hat.SetSize(dof, dim);
1273 grad_hat.SetSize(dim);
1287 for (
int i = 0; i < ir->GetNPoints(); i++)
1292 MultAtB(elfun_mat, dshape_hat, grad_hat);
1298 Mult(grad_hat, Jadj, grad);
1302 double curl = grad(0,1) - grad(1,0);
1307 double curl_x = grad(2,1) - grad(1,2);
1308 double curl_y = grad(0,2) - grad(2,0);
1309 double curl_z = grad(1,0) - grad(0,1);
1310 w *= curl_x * curl_x + curl_y * curl_y + curl_z * curl_z;
1315 w *= Q->Eval(Tr, ip);
1321 elfun_mat.ClearExternalData();
1323 return 0.5 * energy;
1327 void VectorFEMassIntegrator::AssembleElementMatrix(
1337 #ifdef MFEM_THREAD_SAFE
1338 Vector D(VQ ? VQ->GetVDim() : 0);
1340 DenseMatrix K(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
1342 trial_vshape.
SetSize(dof, spaceDim);
1343 D.SetSize(VQ ? VQ->GetVDim() : 0);
1344 K.SetSize(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
1346 DenseMatrix tmp(trial_vshape.Height(), K.Width());
1370 MQ->Eval(K, Trans, ip);
1372 Mult(trial_vshape,K,tmp);
1377 VQ->Eval(D, Trans, ip);
1385 w *= Q -> Eval (Trans, ip);
1392 void VectorFEMassIntegrator::AssembleElementMatrix2(
1396 if ( test_fe.
GetRangeType() == FiniteElement::SCALAR && VQ )
1400 int trial_dof = trial_fe.
GetDof();
1401 int test_dof = test_fe.
GetDof();
1405 mfem_error(
"VectorFEMassIntegrator::AssembleElementMatrix2(...)\n"
1406 " is not implemented for tensor materials");
1408 #ifdef MFEM_THREAD_SAFE
1413 trial_vshape.
SetSize(trial_dof, dim);
1418 elmat.
SetSize (test_dof, trial_dof);
1438 VQ->Eval(D, Trans, ip);
1441 for (
int d = 0; d <
dim; d++)
1443 for (
int j = 0; j < test_dof; j++)
1445 for (
int k = 0; k < trial_dof; k++)
1447 elmat(j, k) += D[d] * shape(j) * trial_vshape(k, d);
1453 else if ( test_fe.
GetRangeType() == FiniteElement::SCALAR )
1457 int trial_dof = trial_fe.
GetDof();
1458 int test_dof = test_fe.
GetDof();
1462 mfem_error(
"VectorFEMassIntegrator::AssembleElementMatrix2(...)\n"
1463 " is not implemented for vector/tensor permeability");
1465 #ifdef MFEM_THREAD_SAFE
1469 trial_vshape.
SetSize(trial_dof, dim);
1473 elmat.
SetSize (dim*test_dof, trial_dof);
1495 w *= Q -> Eval (Trans, ip);
1498 for (
int d = 0; d <
dim; d++)
1500 for (
int j = 0; j < test_dof; j++)
1502 for (
int k = 0; k < trial_dof; k++)
1504 elmat(d * test_dof + j, k) += w * shape(j) * trial_vshape(k, d);
1514 int trial_dof = trial_fe.
GetDof();
1515 int test_dof = test_fe.
GetDof();
1519 mfem_error(
"VectorFEMassIntegrator::AssembleElementMatrix2(...)\n"
1520 " is not implemented for vector/tensor permeability");
1522 #ifdef MFEM_THREAD_SAFE
1526 trial_vshape.
SetSize(trial_dof, dim);
1527 test_vshape.
SetSize(test_dof,dim);
1530 elmat.
SetSize (test_dof, trial_dof);
1552 w *= Q -> Eval (Trans, ip);
1555 for (
int d = 0; d <
dim; d++)
1557 for (
int j = 0; j < test_dof; j++)
1559 for (
int k = 0; k < trial_dof; k++)
1561 elmat(j, k) += w * test_vshape(j, d) * trial_vshape(k, d);
1569 void VectorDivergenceIntegrator::AssembleElementMatrix2(
1576 int trial_dof = trial_fe.
GetDof();
1577 int test_dof = test_fe.
GetDof();
1580 dshape.SetSize (trial_dof, dim);
1581 gshape.SetSize (trial_dof, dim);
1583 divshape.SetSize (dim*trial_dof);
1584 shape.SetSize (test_dof);
1586 elmat.
SetSize (test_dof, dim*trial_dof);
1597 for (
int i = 0; i < ir -> GetNPoints(); i++)
1607 Mult (dshape, Jadj, gshape);
1609 gshape.GradToDiv (divshape);
1614 c *= Q -> Eval (Trans, ip);
1624 void DivDivIntegrator::AssembleElementMatrix(
1632 #ifdef MFEM_THREAD_SAFE
1648 for (
int i = 0; i < ir -> GetNPoints(); i++)
1659 c *= Q -> Eval (Trans, ip);
1668 void VectorDiffusionIntegrator::AssembleElementMatrix(
1680 Jinv. SetSize (dim);
1681 dshape.SetSize (dof, dim);
1682 gshape.SetSize (dof, dim);
1683 pelmat.SetSize (dof);
1690 if (el.
Space() == FunctionSpace::rQk)
1702 for (
int i = 0; i < ir -> GetNPoints(); i++)
1712 Mult (dshape, Jinv, gshape);
1718 norm *= Q -> Eval (Trans, ip);
1723 for (
int d = 0; d <
dim; d++)
1725 for (
int k = 0; k < dof; k++)
1726 for (
int l = 0; l < dof; l++)
1728 elmat (dof*d+k, dof*d+l) += pelmat (k, l);
1735 void ElasticityIntegrator::AssembleElementMatrix(
1742 #ifdef MFEM_THREAD_SAFE
1743 DenseMatrix dshape(dof, dim), Jinv(dim), gshape(dof, dim), pelmat(dof);
1744 Vector divshape(dim*dof);
1747 dshape.SetSize(dof, dim);
1748 gshape.SetSize(dof, dim);
1764 for (
int i = 0; i < ir -> GetNPoints(); i++)
1773 Mult(dshape, Jinv, gshape);
1775 gshape.GradToDiv (divshape);
1777 M = mu->Eval(Trans, ip);
1780 L = lambda->Eval(Trans, ip);
1795 for (
int d = 0; d <
dim; d++)
1797 for (
int k = 0; k < dof; k++)
1798 for (
int l = 0; l < dof; l++)
1800 elmat (dof*d+k, dof*d+l) += (M * w) * pelmat(k, l);
1803 for (
int i = 0; i <
dim; i++)
1804 for (
int j = 0; j <
dim; j++)
1806 for (
int k = 0; k < dof; k++)
1807 for (
int l = 0; l < dof; l++)
1808 elmat(dof*i+k, dof*j+l) +=
1809 (M * w) * gshape(k, j) * gshape(l, i);
1821 int dim, ndof1, ndof2;
1827 Vector vu(dim), nor(dim);
1838 shape1.SetSize(ndof1);
1839 shape2.SetSize(ndof2);
1855 if (el1.
Space() == FunctionSpace::Pk)
1876 u->Eval(vu, *Trans.
Elem1, eip1);
1880 nor(0) = 2*eip1.
x - 1.0;
1888 a = 0.5 *
alpha * un;
1889 b = beta * fabs(un);
1897 if (un >= 0.0 && ndof2)
1900 rho_p = rho->Eval(*Trans.
Elem2, eip2);
1904 rho_p = rho->Eval(*Trans.
Elem1, eip1);
1913 for (
int i = 0; i < ndof1; i++)
1914 for (
int j = 0; j < ndof1; j++)
1916 elmat(i, j) += w * shape1(i) * shape1(j);
1925 for (
int i = 0; i < ndof2; i++)
1926 for (
int j = 0; j < ndof1; j++)
1928 elmat(ndof1+i, j) -= w * shape2(i) * shape1(j);
1934 for (
int i = 0; i < ndof2; i++)
1935 for (
int j = 0; j < ndof2; j++)
1937 elmat(ndof1+i, ndof1+j) += w * shape2(i) * shape2(j);
1940 for (
int i = 0; i < ndof1; i++)
1941 for (
int j = 0; j < ndof2; j++)
1943 elmat(i, ndof1+j) -= w * shape1(i) * shape2(j);
1950 void DGDiffusionIntegrator::AssembleFaceMatrix(
1954 int dim, ndof1, ndof2, ndofs;
1955 bool kappa_is_nonzero = (
kappa != 0.);
1970 shape1.SetSize(ndof1);
1971 dshape1.SetSize(ndof1, dim);
1972 dshape1dn.SetSize(ndof1);
1976 shape2.SetSize(ndof2);
1977 dshape2.SetSize(ndof2, dim);
1978 dshape2dn.SetSize(ndof2);
1985 ndofs = ndof1 + ndof2;
1988 if (kappa_is_nonzero)
2021 nor(0) = 2*eip1.
x - 1.0;
2040 w *= Q->Eval(*Trans.
Elem1, eip1);
2047 MQ->Eval(mq, *Trans.
Elem1, eip1);
2048 mq.MultTranspose(nh, ni);
2052 if (kappa_is_nonzero)
2067 dshape1.Mult(nh, dshape1dn);
2068 for (
int i = 0; i < ndof1; i++)
2069 for (
int j = 0; j < ndof1; j++)
2071 elmat(i, j) += shape1(i) * dshape1dn(j);
2085 w *= Q->Eval(*Trans.
Elem2, eip2);
2092 MQ->Eval(mq, *Trans.
Elem2, eip2);
2093 mq.MultTranspose(nh, ni);
2097 if (kappa_is_nonzero)
2102 dshape2.Mult(nh, dshape2dn);
2104 for (
int i = 0; i < ndof1; i++)
2105 for (
int j = 0; j < ndof2; j++)
2107 elmat(i, ndof1 + j) += shape1(i) * dshape2dn(j);
2110 for (
int i = 0; i < ndof2; i++)
2111 for (
int j = 0; j < ndof1; j++)
2113 elmat(ndof1 + i, j) -= shape2(i) * dshape1dn(j);
2116 for (
int i = 0; i < ndof2; i++)
2117 for (
int j = 0; j < ndof2; j++)
2119 elmat(ndof1 + i, ndof1 + j) -= shape2(i) * dshape2dn(j);
2123 if (kappa_is_nonzero)
2127 for (
int i = 0; i < ndof1; i++)
2129 const double wsi = wq*shape1(i);
2130 for (
int j = 0; j <= i; j++)
2132 jmat(i, j) += wsi * shape1(j);
2137 for (
int i = 0; i < ndof2; i++)
2139 const int i2 = ndof1 + i;
2140 const double wsi = wq*shape2(i);
2141 for (
int j = 0; j < ndof1; j++)
2143 jmat(i2, j) -= wsi * shape1(j);
2145 for (
int j = 0; j <= i; j++)
2147 jmat(i2, ndof1 + j) += wsi * shape2(j);
2155 if (kappa_is_nonzero)
2157 for (
int i = 0; i < ndofs; i++)
2159 for (
int j = 0; j < i; j++)
2161 double aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
2162 elmat(i,j) = sigma*aji - aij + mij;
2163 elmat(j,i) = sigma*aij - aji + mij;
2165 elmat(i,i) = (sigma - 1.)*elmat(i,i) + jmat(i,i);
2170 for (
int i = 0; i < ndofs; i++)
2172 for (
int j = 0; j < i; j++)
2174 double aij = elmat(i,j), aji = elmat(j,i);
2175 elmat(i,j) = sigma*aji - aij;
2176 elmat(j,i) = sigma*aij - aji;
2178 elmat(i,i) *= (sigma - 1.);
2183 void TraceJumpIntegrator::AssembleFaceMatrix(
2188 int i, j, face_ndof, ndof1, ndof2;
2193 face_ndof = trial_face_fe.
GetDof();
2194 ndof1 = test_fe1.
GetDof();
2196 face_shape.SetSize(face_ndof);
2197 shape1.SetSize(ndof1);
2201 ndof2 = test_fe2.
GetDof();
2202 shape2.SetSize(ndof2);
2209 elmat.
SetSize(ndof1 + ndof2, face_ndof);
2224 if (trial_face_fe.
GetMapType() == FiniteElement::VALUE)
2237 trial_face_fe.
CalcShape(ip, face_shape);
2250 if (trial_face_fe.
GetMapType() == FiniteElement::VALUE)
2255 for (i = 0; i < ndof1; i++)
2256 for (j = 0; j < face_ndof; j++)
2258 elmat(i, j) += shape1(i) * face_shape(j);
2263 for (i = 0; i < ndof2; i++)
2264 for (j = 0; j < face_ndof; j++)
2266 elmat(ndof1+i, j) -= shape2(i) * face_shape(j);
2272 void NormalTraceJumpIntegrator::AssembleFaceMatrix(
2277 int i, j, face_ndof, ndof1, ndof2,
dim;
2280 MFEM_VERIFY(trial_face_fe.
GetMapType() == FiniteElement::VALUE,
"");
2282 face_ndof = trial_face_fe.
GetDof();
2283 ndof1 = test_fe1.
GetDof();
2286 face_shape.SetSize(face_ndof);
2287 normal.SetSize(dim);
2288 shape1.SetSize(ndof1,dim);
2289 shape1_n.SetSize(ndof1);
2293 ndof2 = test_fe2.
GetDof();
2294 shape2.SetSize(ndof2,dim);
2295 shape2_n.SetSize(ndof2);
2302 elmat.
SetSize(ndof1 + ndof2, face_ndof);
2325 trial_face_fe.
CalcShape(ip, face_shape);
2331 shape1.Mult(normal, shape1_n);
2339 shape2.Mult(normal, shape2_n);
2342 for (i = 0; i < ndof1; i++)
2343 for (j = 0; j < face_ndof; j++)
2345 elmat(i, j) -= shape1_n(i) * face_shape(j);
2350 for (i = 0; i < ndof2; i++)
2351 for (j = 0; j < face_ndof; j++)
2353 elmat(ndof1+i, j) += shape2_n(i) * face_shape(j);
2360 void NormalInterpolator::AssembleElementMatrix2(
2369 for (
int i = 0; i < ran_nodes.Size(); i++)
2375 for (
int j = 0; j < shape.Size(); j++)
2377 for (
int d = 0; d < spaceDim; d++)
2379 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 space dimension for the finite element.
void AddMultVWt(const Vector &v, const Vector &w, DenseMatrix &VWt)
VWt += v w^t.
Class for integration rule.
virtual void CalcVShape(const IntegrationPoint &ip, DenseMatrix &shape) const
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 if the new size is different.
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 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.
IntegrationRules IntRules(0)
A global object with all integration rules (defined in intrules.cpp)
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows.
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const =0
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:
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 degrees of freedom in the FE space.
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
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.
virtual void CalcCurlShape(const IntegrationPoint &ip, DenseMatrix &curl_shape) const
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.
IntegrationRules RefinedIntRules(1)
A global object with all refined integration rules.
void Mult(const double *x, double *y) const
Matrix vector multiplication.
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
void AddMult_a_AAt(double a, const DenseMatrix &A, DenseMatrix &AAt)
AAt += a * A * A^t.