23 void BilinearFormIntegrator::AssembleElementMatrix (
27 mfem_error (
"BilinearFormIntegrator::AssembleElementMatrix (...)\n"
28 " is not implemented for this class.");
31 void BilinearFormIntegrator::AssembleElementMatrix2 (
35 mfem_error (
"BilinearFormIntegrator::AssembleElementMatrix2 (...)\n"
36 " is not implemented for this class.");
39 void BilinearFormIntegrator::AssembleFaceMatrix (
43 mfem_error (
"BilinearFormIntegrator::AssembleFaceMatrix (...)\n"
44 " is not implemented for 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 for 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);
1640 Mult(dshape_hat, Jadj, dshape);
1645 w *= Q->Eval(Trans, ip);
1652 double VectorCurlCurlIntegrator::GetElementEnergy(
1658 #ifdef MFEM_THREAD_SAFE
1659 DenseMatrix dshape_hat(dof, dim), Jadj(dim), grad_hat(dim), grad(dim);
1661 dshape_hat.SetSize(dof, dim);
1664 grad_hat.SetSize(dim);
1678 for (
int i = 0; i < ir->GetNPoints(); i++)
1683 MultAtB(elfun_mat, dshape_hat, grad_hat);
1689 Mult(grad_hat, Jadj, grad);
1693 double curl = grad(0,1) - grad(1,0);
1698 double curl_x = grad(2,1) - grad(1,2);
1699 double curl_y = grad(0,2) - grad(2,0);
1700 double curl_z = grad(1,0) - grad(0,1);
1701 w *= curl_x * curl_x + curl_y * curl_y + curl_z * curl_z;
1706 w *= Q->Eval(Tr, ip);
1712 elfun_mat.ClearExternalData();
1714 return 0.5 * energy;
1718 void VectorFEMassIntegrator::AssembleElementMatrix(
1728 #ifdef MFEM_THREAD_SAFE
1729 Vector D(VQ ? VQ->GetVDim() : 0);
1731 DenseMatrix K(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
1733 trial_vshape.
SetSize(dof, spaceDim);
1734 D.SetSize(VQ ? VQ->GetVDim() : 0);
1735 K.SetSize(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
1737 DenseMatrix tmp(trial_vshape.Height(), K.Width());
1761 MQ->Eval(K, Trans, ip);
1763 Mult(trial_vshape,K,tmp);
1768 VQ->Eval(D, Trans, ip);
1776 w *= Q -> Eval (Trans, ip);
1783 void VectorFEMassIntegrator::AssembleElementMatrix2(
1787 if ( test_fe.
GetRangeType() == FiniteElement::SCALAR && VQ )
1791 int trial_dof = trial_fe.
GetDof();
1792 int test_dof = test_fe.
GetDof();
1796 mfem_error(
"VectorFEMassIntegrator::AssembleElementMatrix2(...)\n"
1797 " is not implemented for tensor materials");
1799 #ifdef MFEM_THREAD_SAFE
1804 trial_vshape.
SetSize(trial_dof, dim);
1809 elmat.
SetSize (test_dof, trial_dof);
1829 VQ->Eval(D, Trans, ip);
1832 for (
int d = 0; d <
dim; d++)
1834 for (
int j = 0; j < test_dof; j++)
1836 for (
int k = 0; k < trial_dof; k++)
1838 elmat(j, k) += D[d] * shape(j) * trial_vshape(k, d);
1844 else if ( test_fe.
GetRangeType() == FiniteElement::SCALAR )
1848 int trial_dof = trial_fe.
GetDof();
1849 int test_dof = test_fe.
GetDof();
1853 mfem_error(
"VectorFEMassIntegrator::AssembleElementMatrix2(...)\n"
1854 " is not implemented for vector/tensor permeability");
1856 #ifdef MFEM_THREAD_SAFE
1860 trial_vshape.
SetSize(trial_dof, dim);
1864 elmat.
SetSize (dim*test_dof, trial_dof);
1886 w *= Q -> Eval (Trans, ip);
1889 for (
int d = 0; d <
dim; d++)
1891 for (
int j = 0; j < test_dof; j++)
1893 for (
int k = 0; k < trial_dof; k++)
1895 elmat(d * test_dof + j, k) += w * shape(j) * trial_vshape(k, d);
1905 int trial_dof = trial_fe.
GetDof();
1906 int test_dof = test_fe.
GetDof();
1910 mfem_error(
"VectorFEMassIntegrator::AssembleElementMatrix2(...)\n"
1911 " is not implemented for vector/tensor permeability");
1913 #ifdef MFEM_THREAD_SAFE
1917 trial_vshape.
SetSize(trial_dof, dim);
1918 test_vshape.
SetSize(test_dof,dim);
1921 elmat.
SetSize (test_dof, trial_dof);
1943 w *= Q -> Eval (Trans, ip);
1946 for (
int d = 0; d <
dim; d++)
1948 for (
int j = 0; j < test_dof; j++)
1950 for (
int k = 0; k < trial_dof; k++)
1952 elmat(j, k) += w * test_vshape(j, d) * trial_vshape(k, d);
1960 void VectorDivergenceIntegrator::AssembleElementMatrix2(
1967 int trial_dof = trial_fe.
GetDof();
1968 int test_dof = test_fe.
GetDof();
1971 dshape.SetSize (trial_dof, dim);
1972 gshape.SetSize (trial_dof, dim);
1974 divshape.SetSize (dim*trial_dof);
1975 shape.SetSize (test_dof);
1977 elmat.
SetSize (test_dof, dim*trial_dof);
1988 for (
int i = 0; i < ir -> GetNPoints(); i++)
1998 Mult (dshape, Jadj, gshape);
2000 gshape.GradToDiv (divshape);
2005 c *= Q -> Eval (Trans, ip);
2015 void DivDivIntegrator::AssembleElementMatrix(
2023 #ifdef MFEM_THREAD_SAFE
2039 for (
int i = 0; i < ir -> GetNPoints(); i++)
2050 c *= Q -> Eval (Trans, ip);
2059 void VectorDiffusionIntegrator::AssembleElementMatrix(
2071 Jinv. SetSize (dim);
2072 dshape.SetSize (dof, dim);
2073 gshape.SetSize (dof, dim);
2074 pelmat.SetSize (dof);
2081 if (el.
Space() == FunctionSpace::rQk)
2093 for (
int i = 0; i < ir -> GetNPoints(); i++)
2103 Mult (dshape, Jinv, gshape);
2109 norm *= Q -> Eval (Trans, ip);
2114 for (
int d = 0; d <
dim; d++)
2116 for (
int k = 0; k < dof; k++)
2117 for (
int l = 0; l < dof; l++)
2119 elmat (dof*d+k, dof*d+l) += pelmat (k, l);
2125 void VectorDiffusionIntegrator::AssembleElementVector(
2134 dshape.SetSize(dof, dim);
2135 pelmat.SetSize(dim);
2136 gshape.SetSize(dim);
2147 ir = (el.
Space() == FunctionSpace::rQk) ?
2153 for (
int i = 0; i < ir->GetNPoints(); i++)
2162 w *= Q->Eval(Tr, ip);
2169 MultAtB(mat_in, dshape, pelmat);
2170 MultABt(pelmat, gshape, Jinv);
2176 void ElasticityIntegrator::AssembleElementMatrix(
2183 #ifdef MFEM_THREAD_SAFE
2184 DenseMatrix dshape(dof, dim), Jinv(dim), gshape(dof, dim), pelmat(dof);
2185 Vector divshape(dim*dof);
2188 dshape.SetSize(dof, dim);
2189 gshape.SetSize(dof, dim);
2205 for (
int i = 0; i < ir -> GetNPoints(); i++)
2214 Mult(dshape, Jinv, gshape);
2216 gshape.GradToDiv (divshape);
2218 M = mu->Eval(Trans, ip);
2221 L = lambda->Eval(Trans, ip);
2236 for (
int d = 0; d <
dim; d++)
2238 for (
int k = 0; k < dof; k++)
2239 for (
int l = 0; l < dof; l++)
2241 elmat (dof*d+k, dof*d+l) += (M * w) * pelmat(k, l);
2244 for (
int i = 0; i <
dim; i++)
2245 for (
int j = 0; j <
dim; j++)
2247 for (
int k = 0; k < dof; k++)
2248 for (
int l = 0; l < dof; l++)
2249 elmat(dof*i+k, dof*j+l) +=
2250 (M * w) * gshape(k, j) * gshape(l, i);
2262 int dim, ndof1, ndof2;
2268 Vector vu(dim), nor(dim);
2279 shape1.SetSize(ndof1);
2280 shape2.SetSize(ndof2);
2296 if (el1.
Space() == FunctionSpace::Pk)
2317 u->Eval(vu, *Trans.
Elem1, eip1);
2321 nor(0) = 2*eip1.
x - 1.0;
2329 a = 0.5 *
alpha * un;
2330 b = beta * fabs(un);
2338 if (un >= 0.0 && ndof2)
2341 rho_p = rho->Eval(*Trans.
Elem2, eip2);
2345 rho_p = rho->Eval(*Trans.
Elem1, eip1);
2354 for (
int i = 0; i < ndof1; i++)
2355 for (
int j = 0; j < ndof1; j++)
2357 elmat(i, j) += w * shape1(i) * shape1(j);
2366 for (
int i = 0; i < ndof2; i++)
2367 for (
int j = 0; j < ndof1; j++)
2369 elmat(ndof1+i, j) -= w * shape2(i) * shape1(j);
2375 for (
int i = 0; i < ndof2; i++)
2376 for (
int j = 0; j < ndof2; j++)
2378 elmat(ndof1+i, ndof1+j) += w * shape2(i) * shape2(j);
2381 for (
int i = 0; i < ndof1; i++)
2382 for (
int j = 0; j < ndof2; j++)
2384 elmat(i, ndof1+j) -= w * shape1(i) * shape2(j);
2391 void DGDiffusionIntegrator::AssembleFaceMatrix(
2395 int dim, ndof1, ndof2, ndofs;
2396 bool kappa_is_nonzero = (
kappa != 0.);
2411 shape1.SetSize(ndof1);
2412 dshape1.SetSize(ndof1, dim);
2413 dshape1dn.SetSize(ndof1);
2417 shape2.SetSize(ndof2);
2418 dshape2.SetSize(ndof2, dim);
2419 dshape2dn.SetSize(ndof2);
2426 ndofs = ndof1 + ndof2;
2429 if (kappa_is_nonzero)
2462 nor(0) = 2*eip1.
x - 1.0;
2481 w *= Q->Eval(*Trans.
Elem1, eip1);
2488 MQ->Eval(mq, *Trans.
Elem1, eip1);
2489 mq.MultTranspose(nh, ni);
2493 if (kappa_is_nonzero)
2508 dshape1.Mult(nh, dshape1dn);
2509 for (
int i = 0; i < ndof1; i++)
2510 for (
int j = 0; j < ndof1; j++)
2512 elmat(i, j) += shape1(i) * dshape1dn(j);
2526 w *= Q->Eval(*Trans.
Elem2, eip2);
2533 MQ->Eval(mq, *Trans.
Elem2, eip2);
2534 mq.MultTranspose(nh, ni);
2538 if (kappa_is_nonzero)
2543 dshape2.Mult(nh, dshape2dn);
2545 for (
int i = 0; i < ndof1; i++)
2546 for (
int j = 0; j < ndof2; j++)
2548 elmat(i, ndof1 + j) += shape1(i) * dshape2dn(j);
2551 for (
int i = 0; i < ndof2; i++)
2552 for (
int j = 0; j < ndof1; j++)
2554 elmat(ndof1 + i, j) -= shape2(i) * dshape1dn(j);
2557 for (
int i = 0; i < ndof2; i++)
2558 for (
int j = 0; j < ndof2; j++)
2560 elmat(ndof1 + i, ndof1 + j) -= shape2(i) * dshape2dn(j);
2564 if (kappa_is_nonzero)
2568 for (
int i = 0; i < ndof1; i++)
2570 const double wsi = wq*shape1(i);
2571 for (
int j = 0; j <= i; j++)
2573 jmat(i, j) += wsi * shape1(j);
2578 for (
int i = 0; i < ndof2; i++)
2580 const int i2 = ndof1 + i;
2581 const double wsi = wq*shape2(i);
2582 for (
int j = 0; j < ndof1; j++)
2584 jmat(i2, j) -= wsi * shape1(j);
2586 for (
int j = 0; j <= i; j++)
2588 jmat(i2, ndof1 + j) += wsi * shape2(j);
2596 if (kappa_is_nonzero)
2598 for (
int i = 0; i < ndofs; i++)
2600 for (
int j = 0; j < i; j++)
2602 double aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
2603 elmat(i,j) =
sigma*aji - aij + mij;
2604 elmat(j,i) =
sigma*aij - aji + mij;
2606 elmat(i,i) = (
sigma - 1.)*elmat(i,i) + jmat(i,i);
2611 for (
int i = 0; i < ndofs; i++)
2613 for (
int j = 0; j < i; j++)
2615 double aij = elmat(i,j), aji = elmat(j,i);
2616 elmat(i,j) =
sigma*aji - aij;
2617 elmat(j,i) =
sigma*aij - aji;
2619 elmat(i,i) *= (
sigma - 1.);
2626 void DGElasticityIntegrator::AssembleBlock(
2627 const int dim,
const int row_ndofs,
const int col_ndofs,
2628 const int row_offset,
const int col_offset,
2629 const double jmatcoef,
const Vector &col_nL,
const Vector &col_nM,
2634 for (
int jm = 0, j = col_offset; jm <
dim; ++jm)
2636 for (
int jdof = 0; jdof < col_ndofs; ++jdof, ++j)
2638 const double t2 = col_dshape_dnM(jdof);
2639 for (
int im = 0, i = row_offset; im <
dim; ++im)
2641 const double t1 = col_dshape(jdof, jm) * col_nL(im);
2642 const double t3 = col_dshape(jdof, im) * col_nM(jm);
2643 const double tt = t1 + ((im == jm) ? t2 : 0.0) + t3;
2644 for (
int idof = 0; idof < row_ndofs; ++idof, ++i)
2646 elmat(i, j) += row_shape(idof) * tt;
2652 if (jmatcoef == 0.0) {
return; }
2654 for (
int d = 0; d <
dim; ++d)
2656 const int jo = col_offset + d*col_ndofs;
2657 const int io = row_offset + d*row_ndofs;
2658 for (
int jdof = 0, j = jo; jdof < col_ndofs; ++jdof, ++j)
2660 const double sj = jmatcoef * col_shape(jdof);
2661 for (
int i = max(io,j), idof = i - io; idof < row_ndofs; ++idof, ++i)
2663 jmat(i, j) += row_shape(idof) * sj;
2669 void DGElasticityIntegrator::AssembleFaceMatrix(
2673 #ifdef MFEM_THREAD_SAFE
2682 Vector dshape1_dnM, dshape2_dnM;
2687 const int ndofs1 = el1.
GetDof();
2689 const int nvdofs = dim*(ndofs1 + ndofs2);
2699 const bool kappa_is_nonzero = (
kappa != 0.0);
2700 if (kappa_is_nonzero)
2709 dshape1_ps.
SetSize(ndofs1, dim);
2719 dshape2_ps.
SetSize(ndofs2, dim);
2733 for (
int pind = 0; pind < ir->
GetNPoints(); ++pind)
2745 Mult(dshape1, adjJ, dshape1_ps);
2749 nor(0) = 2*eip1.
x - 1.0;
2764 Mult(dshape2, adjJ, dshape2_ps);
2768 const double wL2 = w2 * lambda->Eval(*Trans.
Elem2, eip2);
2769 const double wM2 = w2 * mu->Eval(*Trans.
Elem2, eip2);
2772 wLM = (wL2 + 2.0*wM2);
2773 dshape2_ps.
Mult(nM2, dshape2_dnM);
2783 const double wL1 = w1 * lambda->Eval(*Trans.
Elem1, eip1);
2784 const double wM1 = w1 * mu->Eval(*Trans.
Elem1, eip1);
2787 wLM += (wL1 + 2.0*wM1);
2788 dshape1_ps.
Mult(nM1, dshape1_dnM);
2791 const double jmatcoef =
kappa * (nor*nor) * wLM;
2795 dim, ndofs1, ndofs1, 0, 0, jmatcoef, nL1, nM1,
2796 shape1, shape1, dshape1_dnM, dshape1_ps, elmat, jmat);
2798 if (ndofs2 == 0) {
continue; }
2805 dim, ndofs1, ndofs2, 0, dim*ndofs1, jmatcoef, nL2, nM2,
2806 shape1, shape2, dshape2_dnM, dshape2_ps, elmat, jmat);
2809 dim, ndofs2, ndofs1, dim*ndofs1, 0, jmatcoef, nL1, nM1,
2810 shape2, shape1, dshape1_dnM, dshape1_ps, elmat, jmat);
2813 dim, ndofs2, ndofs2, dim*ndofs1, dim*ndofs1, jmatcoef, nL2, nM2,
2814 shape2, shape2, dshape2_dnM, dshape2_ps, elmat, jmat);
2818 if (kappa_is_nonzero)
2820 for (
int i = 0; i < nvdofs; ++i)
2822 for (
int j = 0; j < i; ++j)
2824 double aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
2825 elmat(i,j) =
alpha*aji - aij + mij;
2826 elmat(j,i) =
alpha*aij - aji + mij;
2828 elmat(i,i) = (
alpha - 1.)*elmat(i,i) + jmat(i,i);
2833 for (
int i = 0; i < nvdofs; ++i)
2835 for (
int j = 0; j < i; ++j)
2837 double aij = elmat(i,j), aji = elmat(j,i);
2838 elmat(i,j) =
alpha*aji - aij;
2839 elmat(j,i) =
alpha*aij - aji;
2841 elmat(i,i) *= (
alpha - 1.);
2847 void TraceJumpIntegrator::AssembleFaceMatrix(
2852 int i, j, face_ndof, ndof1, ndof2;
2857 face_ndof = trial_face_fe.
GetDof();
2858 ndof1 = test_fe1.
GetDof();
2860 face_shape.SetSize(face_ndof);
2861 shape1.SetSize(ndof1);
2865 ndof2 = test_fe2.
GetDof();
2866 shape2.SetSize(ndof2);
2873 elmat.
SetSize(ndof1 + ndof2, face_ndof);
2888 if (trial_face_fe.
GetMapType() == FiniteElement::VALUE)
2901 trial_face_fe.
CalcShape(ip, face_shape);
2914 if (trial_face_fe.
GetMapType() == FiniteElement::VALUE)
2919 for (i = 0; i < ndof1; i++)
2920 for (j = 0; j < face_ndof; j++)
2922 elmat(i, j) += shape1(i) * face_shape(j);
2927 for (i = 0; i < ndof2; i++)
2928 for (j = 0; j < face_ndof; j++)
2930 elmat(ndof1+i, j) -= shape2(i) * face_shape(j);
2936 void NormalTraceJumpIntegrator::AssembleFaceMatrix(
2941 int i, j, face_ndof, ndof1, ndof2,
dim;
2944 MFEM_VERIFY(trial_face_fe.
GetMapType() == FiniteElement::VALUE,
"");
2946 face_ndof = trial_face_fe.
GetDof();
2947 ndof1 = test_fe1.
GetDof();
2950 face_shape.SetSize(face_ndof);
2951 normal.SetSize(dim);
2952 shape1.SetSize(ndof1,dim);
2953 shape1_n.SetSize(ndof1);
2957 ndof2 = test_fe2.
GetDof();
2958 shape2.SetSize(ndof2,dim);
2959 shape2_n.SetSize(ndof2);
2966 elmat.
SetSize(ndof1 + ndof2, face_ndof);
2989 trial_face_fe.
CalcShape(ip, face_shape);
2995 shape1.Mult(normal, shape1_n);
3003 shape2.Mult(normal, shape2_n);
3006 for (i = 0; i < ndof1; i++)
3007 for (j = 0; j < face_ndof; j++)
3009 elmat(i, j) -= shape1_n(i) * face_shape(j);
3014 for (i = 0; i < ndof2; i++)
3015 for (j = 0; j < face_ndof; j++)
3017 elmat(ndof1+i, j) += shape2_n(i) * face_shape(j);
3024 void NormalInterpolator::AssembleElementMatrix2(
3033 for (
int i = 0; i < ran_nodes.Size(); i++)
3039 for (
int j = 0; j < shape.Size(); j++)
3041 for (
int d = 0; d < spaceDim; d++)
3043 elmat(i, j+d*shape.Size()) = shape(j)*n(d);
3065 using VectorCoefficient::Eval;
3070 fe.CalcPhysShape(T, V);
3075 ShapeCoefficient dom_shape_coeff(Q, dom_fe);
3081 ran_fe.
Project(dom_shape_coeff, Trans, elmat_as_vec);
3086 ScalarVectorProductInterpolator::AssembleElementMatrix2(
3105 fe.CalcPhysVShape(T, M);
3110 VShapeCoefficient dom_shape_coeff(Q, dom_fe, Trans.
GetSpaceDim());
3121 VectorScalarProductInterpolator::AssembleElementMatrix2(
3136 vc(width), shape(height) { }
3143 fe.CalcPhysShape(T, shape);
3148 VecShapeCoefficient dom_shape_coeff(VQ, dom_fe);
3159 VectorCrossProductInterpolator::AssembleElementMatrix2(
3175 vshape(height, width), vc(width)
3177 MFEM_ASSERT(width == 3,
"");
3185 fe.CalcPhysVShape(T, vshape);
3186 for (
int k = 0; k < height; k++)
3188 M(k,0) = vc(1) * vshape(k,2) - vc(2) * vshape(k,1);
3189 M(k,1) = vc(2) * vshape(k,0) - vc(0) * vshape(k,2);
3190 M(k,2) = vc(0) * vshape(k,1) - vc(1) * vshape(k,0);
3195 VCrossVShapeCoefficient dom_shape_coeff(VQ, dom_fe);
3213 VectorInnerProductInterpolator::AssembleElementMatrix2(
3231 using VectorCoefficient::Eval;
3237 fe.CalcPhysVShape(T, vshape);
3242 VDotVShapeCoefficient dom_shape_coeff(VQ, dom_fe);
3248 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.
For scalar fields; preserves point values.
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. In the case of anisotropic orders, returns the maximum order...
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.
double * GetData() const
Return a pointer to the beginning of the Vector data.
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 mfem_error(const char *msg)
Function called when an error is encountered. Used by the macros MFEM_ABORT, MFEM_ASSERT, MFEM_VERIFY.
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...
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 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)
double sigma(const Vector &x)