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
728 #ifdef MFEM_THREAD_SAFE
740 if (el.
Space() == FunctionSpace::rQk)
760 w *= Q -> Eval(Trans, ip);
767 void MassIntegrator::AssembleElementMatrix2(
771 int tr_nd = trial_fe.
GetDof();
772 int te_nd = test_fe.
GetDof();
776 #ifdef MFEM_THREAD_SAFE
802 w *= Q -> Eval(Trans, ip);
811 void BoundaryMassIntegrator::AssembleFaceMatrix(
816 "support for interior faces is not implemented");
821 #ifdef MFEM_THREAD_SAFE
847 w *= Q -> Eval(*Trans.
Face, ip);
855 void ConvectionIntegrator::AssembleElementMatrix(
861 #ifdef MFEM_THREAD_SAFE
863 Vector shape, vec2, BdFidxT;
881 Q.Eval(Q_ir, Trans, *ir);
895 adjJ.
Mult(vec1, vec2);
896 dshape.
Mult(vec2, BdFidxT);
903 void GroupConvectionIntegrator::AssembleElementMatrix(
910 dshape.SetSize(nd,dim);
913 grad.SetSize(nd,dim);
922 Q.Eval(Q_nodal, Trans, el.
GetNodes());
934 Mult(dshape, adjJ, grad);
939 for (
int k = 0; k < nd; k++)
941 double wsk = w*shape(k);
942 for (
int l = 0; l < nd; l++)
945 for (
int s = 0; s <
dim; s++)
947 a += Q_nodal(s,k)*grad(l,s);
956 void VectorMassIntegrator::AssembleElementMatrix
966 int vdim = (VQ) ? (VQ -> GetVDim()) : ((MQ) ? (MQ -> GetVDim()) : spaceDim);
970 partelmat.SetSize(nd);
977 mcoeff.SetSize(vdim);
985 if (el.
Space() == FunctionSpace::rQk)
1008 VQ->Eval(vec, Trans, ip);
1009 for (
int k = 0; k < vdim; k++)
1011 elmat.
AddMatrix(norm*vec(k), partelmat, nd*k, nd*k);
1016 MQ->Eval(mcoeff, Trans, ip);
1017 for (
int i = 0; i < vdim; i++)
1018 for (
int j = 0; j < vdim; j++)
1020 elmat.
AddMatrix(norm*mcoeff(i,j), partelmat, nd*i, nd*j);
1027 norm *= Q->Eval(Trans, ip);
1030 for (
int k = 0; k < vdim; k++)
1038 void VectorMassIntegrator::AssembleElementMatrix2(
1042 int tr_nd = trial_fe.
GetDof();
1043 int te_nd = test_fe.
GetDof();
1050 vdim = (VQ) ? (VQ -> GetVDim()) : ((MQ) ? (MQ -> GetVDim()) : (dim));
1052 elmat.
SetSize(te_nd*vdim, tr_nd*vdim);
1053 shape.SetSize(tr_nd);
1054 te_shape.SetSize(te_nd);
1055 partelmat.SetSize(te_nd, tr_nd);
1062 mcoeff.SetSize(vdim);
1069 Trans.
OrderW() + Q_order);
1071 if (trial_fe.
Space() == FunctionSpace::rQk)
1091 MultVWt(te_shape, shape, partelmat);
1095 VQ->Eval(vec, Trans, ip);
1096 for (
int k = 0; k < vdim; k++)
1098 elmat.
AddMatrix(norm*vec(k), partelmat, te_nd*k, tr_nd*k);
1103 MQ->Eval(mcoeff, Trans, ip);
1104 for (
int i = 0; i < vdim; i++)
1105 for (
int j = 0; j < vdim; j++)
1107 elmat.
AddMatrix(norm*mcoeff(i,j), partelmat, te_nd*i, tr_nd*j);
1114 norm *= Q->Eval(Trans, ip);
1117 for (
int k = 0; k < vdim; k++)
1119 elmat.
AddMatrix(partelmat, te_nd*k, tr_nd*k);
1125 void VectorFEDivergenceIntegrator::AssembleElementMatrix2(
1129 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
1131 #ifdef MFEM_THREAD_SAFE
1132 Vector divshape(trial_nd), shape(test_nd);
1134 divshape.SetSize(trial_nd);
1138 elmat.
SetSize(test_nd, trial_nd);
1157 w *= Q->Eval(Trans, ip);
1164 void VectorFEWeakDivergenceIntegrator::AssembleElementMatrix2(
1168 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
1174 "Trial space must be H(Curl) and test space must be H_1");
1176 #ifdef MFEM_THREAD_SAFE
1182 dshape.SetSize(test_nd, dim);
1183 dshapedxt.
SetSize(test_nd, dim);
1184 vshape.
SetSize(trial_nd, dim);
1188 elmat.
SetSize(test_nd, trial_nd);
1230 Mult(dshape, invdfdx, dshapedxt);
1238 w *= Q->Eval(Trans, ip);
1246 void VectorFECurlIntegrator::AssembleElementMatrix2(
1250 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
1252 int dimc = (dim == 3) ? 3 : 1;
1256 "At least one of the finite elements must be in H(Curl)");
1258 int curl_nd, vec_nd;
1270 #ifdef MFEM_THREAD_SAFE
1275 curlshapeTrial.
SetSize(curl_nd, dimc);
1276 curlshapeTrial_dFT.
SetSize(curl_nd, dimc);
1277 vshapeTest.
SetSize(vec_nd, dimc);
1281 elmat.
SetSize(test_nd, trial_nd);
1328 w *= Q->Eval(Trans, ip);
1334 AddMultABt(vshapeTest, curlshapeTrial_dFT, elmat);
1338 AddMultABt(curlshapeTrial_dFT, vshapeTest, elmat);
1343 void DerivativeIntegrator::AssembleElementMatrix2 (
1350 int trial_nd = trial_fe.
GetDof();
1351 int test_nd = test_fe.
GetDof();
1356 elmat.
SetSize (test_nd,trial_nd);
1357 dshape.SetSize (trial_nd,dim);
1358 dshapedxt.SetSize(trial_nd,dim);
1359 dshapedxi.SetSize(trial_nd);
1360 invdfdx.SetSize(dim);
1361 shape.SetSize (test_nd);
1367 if (trial_fe.
Space() == FunctionSpace::Pk)
1376 if (trial_fe.
Space() == FunctionSpace::rQk)
1396 Mult (dshape, invdfdx, dshapedxt);
1400 for (l = 0; l < trial_nd; l++)
1402 dshapedxi(l) = dshapedxt(l,xi);
1405 shape *= Q.Eval(Trans,ip) * det * ip.
weight;
1410 void CurlCurlIntegrator::AssembleElementMatrix
1416 int dimc = (dim == 3) ? 3 : 1;
1419 #ifdef MFEM_THREAD_SAFE
1420 DenseMatrix curlshape(nd,dimc), curlshape_dFt(nd,dimc), M;
1423 curlshape_dFt.SetSize(nd,dimc);
1432 if (el.
Space() == FunctionSpace::Pk)
1465 MQ->Eval(M, Trans, ip);
1467 Mult(curlshape_dFt, M, curlshape);
1472 w *= Q->Eval(Trans, ip);
1482 void CurlCurlIntegrator
1487 #ifdef MFEM_THREAD_SAFE
1494 projcurl.
Mult(u, flux);
1503 int nd = fluxelem.
GetDof();
1506 #ifdef MFEM_THREAD_SAFE
1510 pointflux.SetSize(dim);
1511 if (d_energy) { vec.SetSize(dim); }
1513 int order = 2 * fluxelem.
GetOrder();
1516 double energy = 0.0;
1517 if (d_energy) { *d_energy = 0.0; }
1536 double e = w * (pointflux * pointflux);
1545 #if ANISO_EXPERIMENTAL
1565 #if ANISO_EXPERIMENTAL
1569 int n = (int) round(pow(ir.
GetNPoints(), 1.0/3.0));
1573 for (
int k = 0; k < n; k++)
1574 for (
int l = 0; l < n; l++)
1575 for (
int m = 0; m < n; m++)
1577 Vector &vec = pfluxes[(k*n + l)*n + m];
1580 tmp = vec; tmp -= pfluxes[(k*n + l)*n + (m-1)];
1581 (*d_energy)[0] += (tmp * tmp);
1585 tmp = vec; tmp -= pfluxes[(k*n + (l-1))*n + m];
1586 (*d_energy)[1] += (tmp * tmp);
1590 tmp = vec; tmp -= pfluxes[((k-1)*n + l)*n + m];
1591 (*d_energy)[2] += (tmp * tmp);
1604 void VectorCurlCurlIntegrator::AssembleElementMatrix(
1609 int cld = (dim*(dim-1))/2;
1611 #ifdef MFEM_THREAD_SAFE
1612 DenseMatrix dshape_hat(dof, dim), dshape(dof, dim);
1615 dshape_hat.SetSize(dof, dim);
1617 curlshape.SetSize(dim*dof, cld);
1639 Mult(dshape_hat, Jadj, dshape);
1644 w *= Q->Eval(Trans, ip);
1651 double VectorCurlCurlIntegrator::GetElementEnergy(
1657 #ifdef MFEM_THREAD_SAFE
1658 DenseMatrix dshape_hat(dof, dim), Jadj(dim), grad_hat(dim), grad(dim);
1660 dshape_hat.SetSize(dof, dim);
1663 grad_hat.SetSize(dim);
1677 for (
int i = 0; i < ir->GetNPoints(); i++)
1682 MultAtB(elfun_mat, dshape_hat, grad_hat);
1688 Mult(grad_hat, Jadj, grad);
1692 double curl = grad(0,1) - grad(1,0);
1697 double curl_x = grad(2,1) - grad(1,2);
1698 double curl_y = grad(0,2) - grad(2,0);
1699 double curl_z = grad(1,0) - grad(0,1);
1700 w *= curl_x * curl_x + curl_y * curl_y + curl_z * curl_z;
1705 w *= Q->Eval(Tr, ip);
1711 elfun_mat.ClearExternalData();
1713 return 0.5 * energy;
1717 void VectorFEMassIntegrator::AssembleElementMatrix(
1727 #ifdef MFEM_THREAD_SAFE
1728 Vector D(VQ ? VQ->GetVDim() : 0);
1730 DenseMatrix K(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
1732 trial_vshape.
SetSize(dof, spaceDim);
1733 D.SetSize(VQ ? VQ->GetVDim() : 0);
1734 K.SetSize(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
1736 DenseMatrix tmp(trial_vshape.Height(), K.Width());
1760 MQ->Eval(K, Trans, ip);
1762 Mult(trial_vshape,K,tmp);
1767 VQ->Eval(D, Trans, ip);
1775 w *= Q -> Eval (Trans, ip);
1782 void VectorFEMassIntegrator::AssembleElementMatrix2(
1786 if ( test_fe.
GetRangeType() == FiniteElement::SCALAR && VQ )
1790 int trial_dof = trial_fe.
GetDof();
1791 int test_dof = test_fe.
GetDof();
1795 mfem_error(
"VectorFEMassIntegrator::AssembleElementMatrix2(...)\n"
1796 " is not implemented for tensor materials");
1798 #ifdef MFEM_THREAD_SAFE
1803 trial_vshape.
SetSize(trial_dof, dim);
1808 elmat.
SetSize (test_dof, trial_dof);
1828 VQ->Eval(D, Trans, ip);
1831 for (
int d = 0; d <
dim; d++)
1833 for (
int j = 0; j < test_dof; j++)
1835 for (
int k = 0; k < trial_dof; k++)
1837 elmat(j, k) += D[d] * shape(j) * trial_vshape(k, d);
1843 else if ( test_fe.
GetRangeType() == FiniteElement::SCALAR )
1847 int trial_dof = trial_fe.
GetDof();
1848 int test_dof = test_fe.
GetDof();
1852 mfem_error(
"VectorFEMassIntegrator::AssembleElementMatrix2(...)\n"
1853 " is not implemented for vector/tensor permeability");
1855 #ifdef MFEM_THREAD_SAFE
1859 trial_vshape.
SetSize(trial_dof, dim);
1863 elmat.
SetSize (dim*test_dof, trial_dof);
1885 w *= Q -> Eval (Trans, ip);
1888 for (
int d = 0; d <
dim; d++)
1890 for (
int j = 0; j < test_dof; j++)
1892 for (
int k = 0; k < trial_dof; k++)
1894 elmat(d * test_dof + j, k) += w * shape(j) * trial_vshape(k, d);
1904 int trial_dof = trial_fe.
GetDof();
1905 int test_dof = test_fe.
GetDof();
1909 mfem_error(
"VectorFEMassIntegrator::AssembleElementMatrix2(...)\n"
1910 " is not implemented for vector/tensor permeability");
1912 #ifdef MFEM_THREAD_SAFE
1916 trial_vshape.
SetSize(trial_dof, dim);
1917 test_vshape.
SetSize(test_dof,dim);
1920 elmat.
SetSize (test_dof, trial_dof);
1942 w *= Q -> Eval (Trans, ip);
1945 for (
int d = 0; d <
dim; d++)
1947 for (
int j = 0; j < test_dof; j++)
1949 for (
int k = 0; k < trial_dof; k++)
1951 elmat(j, k) += w * test_vshape(j, d) * trial_vshape(k, d);
1959 void VectorDivergenceIntegrator::AssembleElementMatrix2(
1966 int trial_dof = trial_fe.
GetDof();
1967 int test_dof = test_fe.
GetDof();
1970 dshape.SetSize (trial_dof, dim);
1971 gshape.SetSize (trial_dof, dim);
1973 divshape.SetSize (dim*trial_dof);
1974 shape.SetSize (test_dof);
1976 elmat.
SetSize (test_dof, dim*trial_dof);
1987 for (
int i = 0; i < ir -> GetNPoints(); i++)
1997 Mult (dshape, Jadj, gshape);
1999 gshape.GradToDiv (divshape);
2004 c *= Q -> Eval (Trans, ip);
2014 void DivDivIntegrator::AssembleElementMatrix(
2022 #ifdef MFEM_THREAD_SAFE
2038 for (
int i = 0; i < ir -> GetNPoints(); i++)
2049 c *= Q -> Eval (Trans, ip);
2058 void VectorDiffusionIntegrator::AssembleElementMatrix(
2070 Jinv. SetSize (dim);
2071 dshape.SetSize (dof, dim);
2072 gshape.SetSize (dof, dim);
2073 pelmat.SetSize (dof);
2080 if (el.
Space() == FunctionSpace::rQk)
2092 for (
int i = 0; i < ir -> GetNPoints(); i++)
2102 Mult (dshape, Jinv, gshape);
2108 norm *= Q -> Eval (Trans, ip);
2113 for (
int d = 0; d <
dim; d++)
2115 for (
int k = 0; k < dof; k++)
2116 for (
int l = 0; l < dof; l++)
2118 elmat (dof*d+k, dof*d+l) += pelmat (k, l);
2124 void VectorDiffusionIntegrator::AssembleElementVector(
2133 dshape.SetSize(dof, dim);
2134 pelmat.SetSize(dim);
2135 gshape.SetSize(dim);
2146 ir = (el.
Space() == FunctionSpace::rQk) ?
2152 for (
int i = 0; i < ir->GetNPoints(); i++)
2161 w *= Q->Eval(Tr, ip);
2168 MultAtB(mat_in, dshape, pelmat);
2169 MultABt(pelmat, gshape, Jinv);
2175 void ElasticityIntegrator::AssembleElementMatrix(
2182 #ifdef MFEM_THREAD_SAFE
2183 DenseMatrix dshape(dof, dim), Jinv(dim), gshape(dof, dim), pelmat(dof);
2184 Vector divshape(dim*dof);
2187 dshape.SetSize(dof, dim);
2188 gshape.SetSize(dof, dim);
2204 for (
int i = 0; i < ir -> GetNPoints(); i++)
2213 Mult(dshape, Jinv, gshape);
2215 gshape.GradToDiv (divshape);
2217 M = mu->Eval(Trans, ip);
2220 L = lambda->Eval(Trans, ip);
2235 for (
int d = 0; d <
dim; d++)
2237 for (
int k = 0; k < dof; k++)
2238 for (
int l = 0; l < dof; l++)
2240 elmat (dof*d+k, dof*d+l) += (M * w) * pelmat(k, l);
2243 for (
int i = 0; i <
dim; i++)
2244 for (
int j = 0; j <
dim; j++)
2246 for (
int k = 0; k < dof; k++)
2247 for (
int l = 0; l < dof; l++)
2248 elmat(dof*i+k, dof*j+l) +=
2249 (M * w) * gshape(k, j) * gshape(l, i);
2261 int dim, ndof1, ndof2;
2267 Vector vu(dim), nor(dim);
2278 shape1.SetSize(ndof1);
2279 shape2.SetSize(ndof2);
2295 if (el1.
Space() == FunctionSpace::Pk)
2316 u->Eval(vu, *Trans.
Elem1, eip1);
2320 nor(0) = 2*eip1.
x - 1.0;
2328 a = 0.5 *
alpha * un;
2329 b = beta * fabs(un);
2337 if (un >= 0.0 && ndof2)
2340 rho_p = rho->Eval(*Trans.
Elem2, eip2);
2344 rho_p = rho->Eval(*Trans.
Elem1, eip1);
2353 for (
int i = 0; i < ndof1; i++)
2354 for (
int j = 0; j < ndof1; j++)
2356 elmat(i, j) += w * shape1(i) * shape1(j);
2365 for (
int i = 0; i < ndof2; i++)
2366 for (
int j = 0; j < ndof1; j++)
2368 elmat(ndof1+i, j) -= w * shape2(i) * shape1(j);
2374 for (
int i = 0; i < ndof2; i++)
2375 for (
int j = 0; j < ndof2; j++)
2377 elmat(ndof1+i, ndof1+j) += w * shape2(i) * shape2(j);
2380 for (
int i = 0; i < ndof1; i++)
2381 for (
int j = 0; j < ndof2; j++)
2383 elmat(i, ndof1+j) -= w * shape1(i) * shape2(j);
2390 void DGDiffusionIntegrator::AssembleFaceMatrix(
2394 int dim, ndof1, ndof2, ndofs;
2395 bool kappa_is_nonzero = (
kappa != 0.);
2410 shape1.SetSize(ndof1);
2411 dshape1.SetSize(ndof1, dim);
2412 dshape1dn.SetSize(ndof1);
2416 shape2.SetSize(ndof2);
2417 dshape2.SetSize(ndof2, dim);
2418 dshape2dn.SetSize(ndof2);
2425 ndofs = ndof1 + ndof2;
2428 if (kappa_is_nonzero)
2461 nor(0) = 2*eip1.
x - 1.0;
2480 w *= Q->Eval(*Trans.
Elem1, eip1);
2487 MQ->Eval(mq, *Trans.
Elem1, eip1);
2488 mq.MultTranspose(nh, ni);
2492 if (kappa_is_nonzero)
2507 dshape1.Mult(nh, dshape1dn);
2508 for (
int i = 0; i < ndof1; i++)
2509 for (
int j = 0; j < ndof1; j++)
2511 elmat(i, j) += shape1(i) * dshape1dn(j);
2525 w *= Q->Eval(*Trans.
Elem2, eip2);
2532 MQ->Eval(mq, *Trans.
Elem2, eip2);
2533 mq.MultTranspose(nh, ni);
2537 if (kappa_is_nonzero)
2542 dshape2.Mult(nh, dshape2dn);
2544 for (
int i = 0; i < ndof1; i++)
2545 for (
int j = 0; j < ndof2; j++)
2547 elmat(i, ndof1 + j) += shape1(i) * dshape2dn(j);
2550 for (
int i = 0; i < ndof2; i++)
2551 for (
int j = 0; j < ndof1; j++)
2553 elmat(ndof1 + i, j) -= shape2(i) * dshape1dn(j);
2556 for (
int i = 0; i < ndof2; i++)
2557 for (
int j = 0; j < ndof2; j++)
2559 elmat(ndof1 + i, ndof1 + j) -= shape2(i) * dshape2dn(j);
2563 if (kappa_is_nonzero)
2567 for (
int i = 0; i < ndof1; i++)
2569 const double wsi = wq*shape1(i);
2570 for (
int j = 0; j <= i; j++)
2572 jmat(i, j) += wsi * shape1(j);
2577 for (
int i = 0; i < ndof2; i++)
2579 const int i2 = ndof1 + i;
2580 const double wsi = wq*shape2(i);
2581 for (
int j = 0; j < ndof1; j++)
2583 jmat(i2, j) -= wsi * shape1(j);
2585 for (
int j = 0; j <= i; j++)
2587 jmat(i2, ndof1 + j) += wsi * shape2(j);
2595 if (kappa_is_nonzero)
2597 for (
int i = 0; i < ndofs; i++)
2599 for (
int j = 0; j < i; j++)
2601 double aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
2602 elmat(i,j) = sigma*aji - aij + mij;
2603 elmat(j,i) = sigma*aij - aji + mij;
2605 elmat(i,i) = (sigma - 1.)*elmat(i,i) + jmat(i,i);
2610 for (
int i = 0; i < ndofs; i++)
2612 for (
int j = 0; j < i; j++)
2614 double aij = elmat(i,j), aji = elmat(j,i);
2615 elmat(i,j) = sigma*aji - aij;
2616 elmat(j,i) = sigma*aij - aji;
2618 elmat(i,i) *= (sigma - 1.);
2625 void DGElasticityIntegrator::AssembleBlock(
2626 const int dim,
const int row_ndofs,
const int col_ndofs,
2627 const int row_offset,
const int col_offset,
2628 const double jmatcoef,
const Vector &col_nL,
const Vector &col_nM,
2633 for (
int jm = 0, j = col_offset; jm <
dim; ++jm)
2635 for (
int jdof = 0; jdof < col_ndofs; ++jdof, ++j)
2637 const double t2 = col_dshape_dnM(jdof);
2638 for (
int im = 0, i = row_offset; im <
dim; ++im)
2640 const double t1 = col_dshape(jdof, jm) * col_nL(im);
2641 const double t3 = col_dshape(jdof, im) * col_nM(jm);
2642 const double tt = t1 + ((im == jm) ? t2 : 0.0) + t3;
2643 for (
int idof = 0; idof < row_ndofs; ++idof, ++i)
2645 elmat(i, j) += row_shape(idof) * tt;
2651 if (jmatcoef == 0.0) {
return; }
2653 for (
int d = 0; d <
dim; ++d)
2655 const int jo = col_offset + d*col_ndofs;
2656 const int io = row_offset + d*row_ndofs;
2657 for (
int jdof = 0, j = jo; jdof < col_ndofs; ++jdof, ++j)
2659 const double sj = jmatcoef * col_shape(jdof);
2660 for (
int i = max(io,j), idof = i - io; idof < row_ndofs; ++idof, ++i)
2662 jmat(i, j) += row_shape(idof) * sj;
2668 void DGElasticityIntegrator::AssembleFaceMatrix(
2672 #ifdef MFEM_THREAD_SAFE
2681 Vector dshape1_dnM, dshape2_dnM;
2686 const int ndofs1 = el1.
GetDof();
2688 const int nvdofs = dim*(ndofs1 + ndofs2);
2698 const bool kappa_is_nonzero = (
kappa != 0.0);
2699 if (kappa_is_nonzero)
2708 dshape1_ps.
SetSize(ndofs1, dim);
2718 dshape2_ps.
SetSize(ndofs2, dim);
2732 for (
int pind = 0; pind < ir->
GetNPoints(); ++pind)
2744 Mult(dshape1, adjJ, dshape1_ps);
2748 nor(0) = 2*eip1.
x - 1.0;
2763 Mult(dshape2, adjJ, dshape2_ps);
2767 const double wL2 = w2 * lambda->Eval(*Trans.
Elem2, eip2);
2768 const double wM2 = w2 * mu->Eval(*Trans.
Elem2, eip2);
2771 wLM = (wL2 + 2.0*wM2);
2772 dshape2_ps.
Mult(nM2, dshape2_dnM);
2782 const double wL1 = w1 * lambda->Eval(*Trans.
Elem1, eip1);
2783 const double wM1 = w1 * mu->Eval(*Trans.
Elem1, eip1);
2786 wLM += (wL1 + 2.0*wM1);
2787 dshape1_ps.
Mult(nM1, dshape1_dnM);
2790 const double jmatcoef =
kappa * (nor*nor) * wLM;
2794 dim, ndofs1, ndofs1, 0, 0, jmatcoef, nL1, nM1,
2795 shape1, shape1, dshape1_dnM, dshape1_ps, elmat, jmat);
2797 if (ndofs2 == 0) {
continue; }
2804 dim, ndofs1, ndofs2, 0, dim*ndofs1, jmatcoef, nL2, nM2,
2805 shape1, shape2, dshape2_dnM, dshape2_ps, elmat, jmat);
2808 dim, ndofs2, ndofs1, dim*ndofs1, 0, jmatcoef, nL1, nM1,
2809 shape2, shape1, dshape1_dnM, dshape1_ps, elmat, jmat);
2812 dim, ndofs2, ndofs2, dim*ndofs1, dim*ndofs1, jmatcoef, nL2, nM2,
2813 shape2, shape2, dshape2_dnM, dshape2_ps, elmat, jmat);
2817 if (kappa_is_nonzero)
2819 for (
int i = 0; i < nvdofs; ++i)
2821 for (
int j = 0; j < i; ++j)
2823 double aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
2824 elmat(i,j) =
alpha*aji - aij + mij;
2825 elmat(j,i) =
alpha*aij - aji + mij;
2827 elmat(i,i) = (
alpha - 1.)*elmat(i,i) + jmat(i,i);
2832 for (
int i = 0; i < nvdofs; ++i)
2834 for (
int j = 0; j < i; ++j)
2836 double aij = elmat(i,j), aji = elmat(j,i);
2837 elmat(i,j) =
alpha*aji - aij;
2838 elmat(j,i) =
alpha*aij - aji;
2840 elmat(i,i) *= (
alpha - 1.);
2846 void TraceJumpIntegrator::AssembleFaceMatrix(
2851 int i, j, face_ndof, ndof1, ndof2;
2856 face_ndof = trial_face_fe.
GetDof();
2857 ndof1 = test_fe1.
GetDof();
2859 face_shape.SetSize(face_ndof);
2860 shape1.SetSize(ndof1);
2864 ndof2 = test_fe2.
GetDof();
2865 shape2.SetSize(ndof2);
2872 elmat.
SetSize(ndof1 + ndof2, face_ndof);
2887 if (trial_face_fe.
GetMapType() == FiniteElement::VALUE)
2900 trial_face_fe.
CalcShape(ip, face_shape);
2913 if (trial_face_fe.
GetMapType() == FiniteElement::VALUE)
2918 for (i = 0; i < ndof1; i++)
2919 for (j = 0; j < face_ndof; j++)
2921 elmat(i, j) += shape1(i) * face_shape(j);
2926 for (i = 0; i < ndof2; i++)
2927 for (j = 0; j < face_ndof; j++)
2929 elmat(ndof1+i, j) -= shape2(i) * face_shape(j);
2935 void NormalTraceJumpIntegrator::AssembleFaceMatrix(
2940 int i, j, face_ndof, ndof1, ndof2,
dim;
2943 MFEM_VERIFY(trial_face_fe.
GetMapType() == FiniteElement::VALUE,
"");
2945 face_ndof = trial_face_fe.
GetDof();
2946 ndof1 = test_fe1.
GetDof();
2949 face_shape.SetSize(face_ndof);
2950 normal.SetSize(dim);
2951 shape1.SetSize(ndof1,dim);
2952 shape1_n.SetSize(ndof1);
2956 ndof2 = test_fe2.
GetDof();
2957 shape2.SetSize(ndof2,dim);
2958 shape2_n.SetSize(ndof2);
2965 elmat.
SetSize(ndof1 + ndof2, face_ndof);
2988 trial_face_fe.
CalcShape(ip, face_shape);
2994 shape1.Mult(normal, shape1_n);
3002 shape2.Mult(normal, shape2_n);
3005 for (i = 0; i < ndof1; i++)
3006 for (j = 0; j < face_ndof; j++)
3008 elmat(i, j) -= shape1_n(i) * face_shape(j);
3013 for (i = 0; i < ndof2; i++)
3014 for (j = 0; j < face_ndof; j++)
3016 elmat(ndof1+i, j) += shape2_n(i) * face_shape(j);
3023 void NormalInterpolator::AssembleElementMatrix2(
3032 for (
int i = 0; i < ran_nodes.Size(); i++)
3038 for (
int j = 0; j < shape.Size(); j++)
3040 for (
int d = 0; d < spaceDim; d++)
3042 elmat(i, j+d*shape.Size()) = shape(j)*n(d);
3068 fe.CalcPhysShape(T, V);
3073 ShapeCoefficient dom_shape_coeff(Q, dom_fe);
3079 ran_fe.
Project(dom_shape_coeff, Trans, elmat_as_vec);
3084 ScalarVectorProductInterpolator::AssembleElementMatrix2(
3103 fe.CalcPhysVShape(T, M);
3108 VShapeCoefficient dom_shape_coeff(Q, dom_fe, Trans.
GetSpaceDim());
3119 VectorScalarProductInterpolator::AssembleElementMatrix2(
3134 vc(width), shape(height) { }
3141 fe.CalcPhysShape(T, shape);
3146 VecShapeCoefficient dom_shape_coeff(VQ, dom_fe);
3157 VectorCrossProductInterpolator::AssembleElementMatrix2(
3173 vshape(height, width), vc(width)
3175 MFEM_ASSERT(width == 3,
"");
3183 fe.CalcPhysVShape(T, vshape);
3184 for (
int k = 0; k < height; k++)
3186 M(k,0) = vc(1) * vshape(k,2) - vc(2) * vshape(k,1);
3187 M(k,1) = vc(2) * vshape(k,0) - vc(0) * vshape(k,2);
3188 M(k,2) = vc(0) * vshape(k,1) - vc(1) * vshape(k,0);
3193 VCrossVShapeCoefficient dom_shape_coeff(VQ, dom_fe);
3211 VectorInnerProductInterpolator::AssembleElementMatrix2(
3234 fe.CalcPhysVShape(T, vshape);
3239 VDotVShapeCoefficient dom_shape_coeff(VQ, dom_fe);
3245 ran_fe.
Project(dom_shape_coeff, Trans, elmat_as_vec);
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.
virtual void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const
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)
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
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.
int GetVDim()
Returns dimension of the vector.
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
int GetGeomType() const
Returns the Geometry::Type of the reference element.
double * Data() const
Returns the matrix data array.
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.
Base class Coefficient that may optionally depend on time.
void mfem_error(const char *msg)
void MultAAt(const DenseMatrix &a, DenseMatrix &aat)
Calculate the matrix A.At.
void GetColumnReference(int c, Vector &col)
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.
virtual void ProjectMatrixCoefficient(MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const
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)