25 mfem_error (
"BilinearFormIntegrator::AssemblePA(fes)\n"
26 " is not implemented for this class.");
32 mfem_error (
"BilinearFormIntegrator::AssemblePA(fes, fes)\n"
33 " is not implemented for this class.");
38 mfem_error (
"BilinearFormIntegrator::AssemblePAInteriorFaces(...)\n"
39 " is not implemented for this class.");
44 mfem_error (
"BilinearFormIntegrator::AssemblePABoundaryFaces(...)\n"
45 " is not implemented for this class.");
48 void BilinearFormIntegrator::AssembleDiagonalPA(
Vector &)
50 mfem_error (
"BilinearFormIntegrator::AssembleDiagonalPA(...)\n"
51 " is not implemented for this class.");
58 mfem_error (
"BilinearFormIntegrator::AssembleEA(...)\n"
59 " is not implemented for this class.");
68 mfem_error (
"BilinearFormIntegrator::AssembleEAInteriorFaces(...)\n"
69 " is not implemented for this class.");
77 mfem_error (
"BilinearFormIntegrator::AssembleEABoundaryFaces(...)\n"
78 " is not implemented for this class.");
81 void BilinearFormIntegrator::AssembleDiagonalPA_ADAt(
const Vector &,
Vector &)
83 MFEM_ABORT(
"BilinearFormIntegrator::AssembleDiagonalPA_ADAt(...)\n"
84 " is not implemented for this class.");
87 void BilinearFormIntegrator::AddMultPA(
const Vector &,
Vector &)
const
89 mfem_error (
"BilinearFormIntegrator::MultAssembled(...)\n"
90 " is not implemented for this class.");
93 void BilinearFormIntegrator::AddMultTransposePA(
const Vector &,
Vector &)
const
95 mfem_error (
"BilinearFormIntegrator::AddMultTransposePA(...)\n"
96 " is not implemented for this class.");
101 mfem_error (
"BilinearFormIntegrator::AssembleMF(...)\n"
102 " is not implemented for this class.");
107 mfem_error (
"BilinearFormIntegrator::AddMultMF(...)\n"
108 " is not implemented for this class.");
111 void BilinearFormIntegrator::AddMultTransposeMF(
const Vector &,
Vector &)
const
113 mfem_error (
"BilinearFormIntegrator::AddMultTransposeMF(...)\n"
114 " is not implemented for this class.");
117 void BilinearFormIntegrator::AssembleDiagonalMF(
Vector &)
119 mfem_error (
"BilinearFormIntegrator::AssembleDiagonalMF(...)\n"
120 " is not implemented for this class.");
123 void BilinearFormIntegrator::AssembleElementMatrix (
127 mfem_error (
"BilinearFormIntegrator::AssembleElementMatrix(...)\n"
128 " is not implemented for this class.");
131 void BilinearFormIntegrator::AssembleElementMatrix2 (
135 mfem_error (
"BilinearFormIntegrator::AssembleElementMatrix2(...)\n"
136 " is not implemented for this class.");
139 void BilinearFormIntegrator::AssembleFaceMatrix (
143 mfem_error (
"BilinearFormIntegrator::AssembleFaceMatrix(...)\n"
144 " is not implemented for this class.");
147 void BilinearFormIntegrator::AssembleFaceMatrix(
152 MFEM_ABORT(
"AssembleFaceMatrix (mixed form) is not implemented for this"
153 " Integrator class.");
156 void BilinearFormIntegrator::AssembleElementVector(
162 AssembleElementMatrix(el, Tr, elmat);
164 elmat.
Mult(elfun, elvect);
167 void BilinearFormIntegrator::AssembleFaceVector(
173 AssembleFaceMatrix(el1, el2, Tr, elmat);
175 elmat.
Mult(elfun, elvect);
184 void TransposeIntegrator::AssembleElementMatrix (
187 bfi -> AssembleElementMatrix (el, Trans, bfi_elmat);
192 void TransposeIntegrator::AssembleElementMatrix2 (
196 bfi -> AssembleElementMatrix2 (test_fe, trial_fe, Trans, bfi_elmat);
201 void TransposeIntegrator::AssembleFaceMatrix (
205 bfi -> AssembleFaceMatrix (el1, el2, Trans, bfi_elmat);
216 void LumpedIntegrator::AssembleElementMatrix (
219 bfi -> AssembleElementMatrix (el, Trans, elmat);
226 integrator->SetIntRule(ir);
229 void InverseIntegrator::AssembleElementMatrix(
232 integrator->AssembleElementMatrix(el, Trans, elmat);
239 for (
int i = 0; i < integrators.Size(); i++)
241 integrators[i]->SetIntRule(ir);
245 void SumIntegrator::AssembleElementMatrix(
248 MFEM_ASSERT(integrators.Size() > 0,
"empty SumIntegrator.");
250 integrators[0]->AssembleElementMatrix(el, Trans, elmat);
251 for (
int i = 1; i < integrators.Size(); i++)
253 integrators[i]->AssembleElementMatrix(el, Trans, elem_mat);
258 void SumIntegrator::AssembleElementMatrix2(
262 MFEM_ASSERT(integrators.Size() > 0,
"empty SumIntegrator.");
264 integrators[0]->AssembleElementMatrix2(el1, el2, Trans, elmat);
265 for (
int i = 1; i < integrators.Size(); i++)
267 integrators[i]->AssembleElementMatrix2(el1, el2, Trans, elem_mat);
272 void SumIntegrator::AssembleFaceMatrix(
276 MFEM_ASSERT(integrators.Size() > 0,
"empty SumIntegrator.");
278 integrators[0]->AssembleFaceMatrix(el1, el2, Trans, elmat);
279 for (
int i = 1; i < integrators.Size(); i++)
281 integrators[i]->AssembleFaceMatrix(el1, el2, Trans, elem_mat);
286 void SumIntegrator::AssembleFaceMatrix(
291 MFEM_ASSERT(integrators.Size() > 0,
"empty SumIntegrator.");
293 integrators[0]->AssembleFaceMatrix(tr_fe, te_fe1, te_fe2, Trans, elmat);
294 for (
int i = 1; i < integrators.Size(); i++)
296 integrators[i]->AssembleFaceMatrix(tr_fe, te_fe1, te_fe2, Trans, elem_mat);
303 for (
int i = 0; i < integrators.Size(); i++)
305 integrators[i]->AssemblePA(fes);
309 void SumIntegrator::AssembleDiagonalPA(
Vector &diag)
311 for (
int i = 0; i < integrators.Size(); i++)
313 integrators[i]->AssembleDiagonalPA(diag);
319 for (
int i = 0; i < integrators.Size(); i++)
321 integrators[i]->AssemblePAInteriorFaces(fes);
327 for (
int i = 0; i < integrators.Size(); i++)
329 integrators[i]->AssemblePABoundaryFaces(fes);
335 for (
int i = 0; i < integrators.Size(); i++)
337 integrators[i]->AddMultPA(x, y);
341 void SumIntegrator::AddMultTransposePA(
const Vector &x,
Vector &y)
const
343 for (
int i = 0; i < integrators.Size(); i++)
345 integrators[i]->AddMultTransposePA(x, y);
351 for (
int i = 0; i < integrators.Size(); i++)
353 integrators[i]->AssembleMF(fes);
359 for (
int i = 0; i < integrators.Size(); i++)
361 integrators[i]->AddMultTransposeMF(x, y);
365 void SumIntegrator::AddMultTransposeMF(
const Vector &x,
Vector &y)
const
367 for (
int i = 0; i < integrators.Size(); i++)
369 integrators[i]->AddMultMF(x, y);
373 void SumIntegrator::AssembleDiagonalMF(
Vector &diag)
375 for (
int i = 0; i < integrators.Size(); i++)
377 integrators[i]->AssembleDiagonalMF(diag);
384 for (
int i = 0; i < integrators.Size(); i++)
386 integrators[i]->AssembleEA(fes, emat, add);
395 for (
int i = 0; i < integrators.Size(); i++)
397 integrators[i]->AssembleEAInteriorFaces(fes,ea_data_int,ea_data_ext,add);
405 for (
int i = 0; i < integrators.Size(); i++)
407 integrators[i]->AssembleEABoundaryFaces(fes, ea_data_bdr, add);
411 SumIntegrator::~SumIntegrator()
415 for (
int i = 0; i < integrators.Size(); i++)
417 delete integrators[i];
422 void MixedScalarIntegrator::AssembleElementMatrix2(
426 MFEM_ASSERT(this->VerifyFiniteElementTypes(trial_fe, test_fe),
427 this->FiniteElementTypeFailureMessage());
429 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
430 bool same_shapes = same_calc_shape && (&trial_fe == &test_fe);
432 #ifdef MFEM_THREAD_SAFE
433 Vector test_shape(test_nd);
447 elmat.
SetSize(test_nd, trial_nd);
452 int ir_order = this->GetIntegrationOrder(trial_fe, test_fe, Trans);
462 this->CalcTestShape(test_fe, Trans, test_shape);
463 this->CalcTrialShape(trial_fe, Trans, trial_shape);
469 w *= Q->Eval(Trans, ip);
473 #ifndef MFEM_THREAD_SAFE
481 void MixedVectorIntegrator::AssembleElementMatrix2(
485 MFEM_ASSERT(this->VerifyFiniteElementTypes(trial_fe, test_fe),
486 this->FiniteElementTypeFailureMessage());
488 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
490 bool same_shapes = same_calc_shape && (&trial_fe == &test_fe);
492 #ifdef MFEM_THREAD_SAFE
493 Vector V(VQ ? VQ->GetVDim() : 0);
494 Vector D(DQ ? DQ->GetVDim() : 0);
495 DenseMatrix M(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
500 V.SetSize(VQ ? VQ->GetVDim() : 0);
501 D.SetSize(DQ ? DQ->GetVDim() : 0);
502 M.SetSize(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
503 test_shape.SetSize(test_nd, spaceDim);
504 test_shape_tmp.
SetSize(test_nd, spaceDim);
508 trial_shape.
Reset(test_shape.Data(), trial_nd, spaceDim);
512 trial_shape.
SetSize(trial_nd, spaceDim);
515 elmat.
SetSize(test_nd, trial_nd);
520 int ir_order = this->GetIntegrationOrder(trial_fe, test_fe, Trans);
530 this->CalcTestShape(test_fe, Trans, test_shape);
533 this->CalcTrialShape(trial_fe, Trans, trial_shape);
540 MQ->Eval(M, Trans, ip);
542 Mult(test_shape, M, test_shape_tmp);
543 AddMultABt(test_shape_tmp, trial_shape, elmat);
547 DQ->Eval(D, Trans, ip);
553 VQ->Eval(V, Trans, ip);
555 for (
int j=0; j<test_nd; j++)
557 test_shape_tmp(j,0) = test_shape(j,1) * V(2) -
558 test_shape(j,2) * V(1);
559 test_shape_tmp(j,1) = test_shape(j,2) * V(0) -
560 test_shape(j,0) * V(2);
561 test_shape_tmp(j,2) = test_shape(j,0) * V(1) -
562 test_shape(j,1) * V(0);
564 AddMultABt(test_shape_tmp, trial_shape, elmat);
570 w *= Q -> Eval (Trans, ip);
582 #ifndef MFEM_THREAD_SAFE
590 void MixedScalarVectorIntegrator::AssembleElementMatrix2(
594 MFEM_ASSERT(this->VerifyFiniteElementTypes(trial_fe, test_fe),
595 this->FiniteElementTypeFailureMessage());
600 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
601 int sca_nd = sca_fe->
GetDof();
602 int vec_nd = vec_fe->
GetDof();
606 #ifdef MFEM_THREAD_SAFE
607 Vector V(VQ ? VQ->GetVDim() : 0);
610 Vector vshape_tmp(vec_nd);
612 V.SetSize(VQ ? VQ->GetVDim() : 0);
613 vshape.SetSize(vec_nd, spaceDim);
621 elmat.
SetSize(test_nd, trial_nd);
626 int ir_order = this->GetIntegrationOrder(trial_fe, test_fe, Trans);
636 this->CalcShape(*sca_fe, Trans, shape);
637 this->CalcVShape(*vec_fe, Trans, vshape);
641 VQ->Eval(V, Trans, ip);
644 if ( vec_fe->
GetDim() == 2 && cross_2d )
651 vshape.Mult(V,vshape_tmp);
658 void GradientIntegrator::AssembleElementMatrix2(
663 int trial_dof = trial_fe.
GetDof();
664 int test_dof = test_fe.
GetDof();
668 dshape.
SetSize(trial_dof, dim);
669 gshape.SetSize(trial_dof, dim);
671 shape.SetSize(test_dof);
672 elmat.
SetSize(dim * test_dof, trial_dof);
674 const IntegrationRule *ir = IntRule ? IntRule : &GetRule(trial_fe, test_fe,
678 elmat_comp.
SetSize(test_dof, trial_dof);
690 Mult(dshape, Jadj, gshape);
695 c *= Q->Eval(Trans, ip);
699 for (
int d = 0; d <
dim; ++d)
701 gshape.GetColumnReference(d, d_col);
702 MultVWt(shape, d_col, elmat_comp);
703 for (
int jj = 0; jj < trial_dof; ++jj)
705 for (
int ii = 0; ii < test_dof; ++ii)
707 elmat(d * test_dof + ii, jj) += elmat_comp(ii, jj);
724 void DiffusionIntegrator::AssembleElementMatrix
731 bool square = (dim == spaceDim);
736 MFEM_VERIFY(VQ->GetVDim() == spaceDim,
737 "Unexpected dimension for VectorCoefficient");
741 MFEM_VERIFY(MQ->GetWidth() == spaceDim,
742 "Unexpected width for MatrixCoefficient");
743 MFEM_VERIFY(MQ->GetHeight() == spaceDim,
744 "Unexpected height for MatrixCoefficient");
747 #ifdef MFEM_THREAD_SAFE
748 DenseMatrix dshape(nd, dim), dshapedxt(nd, spaceDim);
750 Vector D(VQ ? VQ->GetVDim() : 0);
753 dshapedxt.
SetSize(nd, spaceDim);
754 dshapedxt_m.
SetSize(nd, MQ ? spaceDim : 0);
755 M.SetSize(MQ ? spaceDim : 0);
756 D.SetSize(VQ ? VQ->GetVDim() : 0);
770 w = ip.
weight / (square ? w : w*w*w);
776 MQ->Eval(M, Trans, ip);
778 Mult(dshapedxt, M, dshapedxt_m);
783 VQ->Eval(D, Trans, ip);
791 w *= Q->Eval(Trans, ip);
798 void DiffusionIntegrator::AssembleElementMatrix2(
802 int tr_nd = trial_fe.
GetDof();
803 int te_nd = test_fe.
GetDof();
806 bool square = (dim == spaceDim);
811 MFEM_VERIFY(VQ->GetVDim() == spaceDim,
812 "Unexpected dimension for VectorCoefficient");
816 MFEM_VERIFY(MQ->GetWidth() == spaceDim,
817 "Unexpected width for MatrixCoefficient");
818 MFEM_VERIFY(MQ->GetHeight() == spaceDim,
819 "Unexpected height for MatrixCoefficient");
822 #ifdef MFEM_THREAD_SAFE
823 DenseMatrix dshape(tr_nd, dim), dshapedxt(tr_nd, spaceDim);
824 DenseMatrix te_dshape(te_nd, dim), te_dshapedxt(te_nd, spaceDim);
828 Vector D(VQ ? VQ->GetVDim() : 0);
831 dshapedxt.
SetSize(tr_nd, spaceDim);
832 te_dshape.SetSize(te_nd, dim);
833 te_dshapedxt.
SetSize(te_nd, spaceDim);
834 invdfdx.
SetSize(dim, spaceDim);
835 dshapedxt_m.
SetSize(te_nd, MQ ? spaceDim : 0);
837 D.SetSize(VQ ? VQ->GetVDim() : 0);
841 const IntegrationRule *ir = IntRule ? IntRule : &GetRule(trial_fe, test_fe);
853 w = ip.
weight / (square ? w : w*w*w);
854 Mult(dshape, invdfdx, dshapedxt);
855 Mult(te_dshape, invdfdx, te_dshapedxt);
859 MQ->Eval(M, Trans, ip);
861 Mult(te_dshapedxt, M, dshapedxt_m);
866 VQ->Eval(D, Trans, ip);
874 w *= Q->Eval(Trans, ip);
882 void DiffusionIntegrator::AssembleElementVector(
893 MFEM_VERIFY(VQ->GetVDim() == spaceDim,
894 "Unexpected dimension for VectorCoefficient");
898 MFEM_VERIFY(MQ->GetWidth() == spaceDim,
899 "Unexpected width for MatrixCoefficient");
900 MFEM_VERIFY(MQ->GetHeight() == spaceDim,
901 "Unexpected height for MatrixCoefficient");
904 #ifdef MFEM_THREAD_SAFE
905 DenseMatrix dshape(nd,dim), invdfdx(dim, spaceDim), M(MQ ? spaceDim : 0);
906 Vector D(VQ ? VQ->GetVDim() : 0);
909 invdfdx.SetSize(dim, spaceDim);
911 D.SetSize(VQ ? VQ->GetVDim() : 0);
914 vecdxt.SetSize((VQ || MQ) ? spaceDim : 0);
915 pointflux.SetSize(spaceDim);
933 dshape.MultTranspose(elfun, vec);
934 invdfdx.MultTranspose(vec, pointflux);
937 w *= Q->Eval(Tr, ip);
942 dshape.MultTranspose(elfun, vec);
943 invdfdx.MultTranspose(vec, vecdxt);
947 M.
Mult(vecdxt, pointflux);
952 for (
int j=0; j<spaceDim; ++j)
954 pointflux[j] = D[j] * vecdxt[j];
959 invdfdx.Mult(pointflux, vec);
960 dshape.AddMult(vec, elvect);
964 void DiffusionIntegrator::ComputeElementFlux
968 int i, j, nd,
dim, spaceDim, fnd;
976 MFEM_VERIFY(VQ->GetVDim() == spaceDim,
977 "Unexpected dimension for VectorCoefficient");
981 MFEM_VERIFY(MQ->GetWidth() == spaceDim,
982 "Unexpected width for MatrixCoefficient");
983 MFEM_VERIFY(MQ->GetHeight() == spaceDim,
984 "Unexpected height for MatrixCoefficient");
987 #ifdef MFEM_THREAD_SAFE
988 DenseMatrix dshape(nd,dim), invdfdx(dim, spaceDim);
990 Vector D(VQ ? VQ->GetVDim() : 0);
993 invdfdx.
SetSize(dim, spaceDim);
995 D.SetSize(VQ ? VQ->GetVDim() : 0);
998 vecdxt.SetSize(spaceDim);
999 pointflux.SetSize(MQ ? spaceDim : 0);
1003 flux.
SetSize( fnd * spaceDim );
1005 for (i = 0; i < fnd; i++)
1009 dshape.MultTranspose(u, vec);
1019 vecdxt *= Q->Eval(Trans,ip);
1021 for (j = 0; j < spaceDim; j++)
1023 flux(fnd*j+i) = vecdxt(j);
1030 MQ->Eval(M, Trans, ip);
1031 M.
Mult(vecdxt, pointflux);
1035 VQ->Eval(D, Trans, ip);
1036 for (
int j=0; j<spaceDim; ++j)
1038 pointflux[j] = D[j] * vecdxt[j];
1042 for (j = 0; j < spaceDim; j++)
1044 flux(fnd*j+i) = pointflux(j);
1050 double DiffusionIntegrator::ComputeFluxEnergy
1054 int nd = fluxelem.
GetDof();
1058 #ifdef MFEM_THREAD_SAFE
1063 pointflux.SetSize(spaceDim);
1064 if (d_energy) { vec.SetSize(spaceDim); }
1065 if (MQ) { M.
SetSize(spaceDim); }
1067 int order = 2 * fluxelem.
GetOrder();
1070 double energy = 0.0;
1071 if (d_energy) { *d_energy = 0.0; }
1079 for (
int k = 0; k < spaceDim; k++)
1081 for (
int j = 0; j < nd; j++)
1083 pointflux(k) += flux(k*nd+j)*shape(j);
1092 double e = (pointflux * pointflux);
1093 if (Q) { e *= Q->Eval(Trans, ip); }
1098 MQ->Eval(M, Trans, ip);
1106 for (
int k = 0; k <
dim; k++)
1108 (*d_energy)[k] += w * vec[k] * vec[k];
1121 if (trial_fe.
Space() == FunctionSpace::Pk)
1131 if (trial_fe.
Space() == FunctionSpace::rQk)
1139 void MassIntegrator::AssembleElementMatrix
1147 #ifdef MFEM_THREAD_SAFE
1153 const IntegrationRule *ir = IntRule ? IntRule : &GetRule(el, el, Trans);
1166 w *= Q -> Eval(Trans, ip);
1173 void MassIntegrator::AssembleElementMatrix2(
1177 int tr_nd = trial_fe.
GetDof();
1178 int te_nd = test_fe.
GetDof();
1181 #ifdef MFEM_THREAD_SAFE
1189 &GetRule(trial_fe, test_fe, Trans);
1202 w *= Q -> Eval(Trans, ip);
1217 if (trial_fe.
Space() == FunctionSpace::rQk)
1225 void BoundaryMassIntegrator::AssembleFaceMatrix(
1229 MFEM_ASSERT(Trans.
Elem2No < 0,
1230 "support for interior faces is not implemented");
1235 #ifdef MFEM_THREAD_SAFE
1264 w *= Q -> Eval(Trans, ip);
1271 void ConvectionIntegrator::AssembleElementMatrix(
1277 #ifdef MFEM_THREAD_SAFE
1279 Vector shape, vec2, BdFidxT;
1297 Q->Eval(Q_ir, Trans, *ir);
1311 adjJ.
Mult(vec1, vec2);
1312 dshape.
Mult(vec2, BdFidxT);
1319 void GroupConvectionIntegrator::AssembleElementMatrix(
1326 dshape.SetSize(nd,dim);
1329 grad.SetSize(nd,dim);
1338 Q->Eval(Q_nodal, Trans, el.
GetNodes());
1350 Mult(dshape, adjJ, grad);
1355 for (
int k = 0; k < nd; k++)
1357 double wsk = w*shape(k);
1358 for (
int l = 0; l < nd; l++)
1361 for (
int s = 0;
s <
dim;
s++)
1363 a += Q_nodal(
s,k)*grad(l,
s);
1365 elmat(k,l) += wsk*
a;
1383 return GetRule(el,el,Trans);
1386 void VectorMassIntegrator::AssembleElementMatrix
1396 vdim = (vdim == -1) ? spaceDim : vdim;
1400 partelmat.SetSize(nd);
1407 mcoeff.SetSize(vdim);
1415 if (el.
Space() == FunctionSpace::rQk)
1438 VQ->Eval(vec, Trans, ip);
1439 for (
int k = 0; k < vdim; k++)
1441 elmat.
AddMatrix(norm*vec(k), partelmat, nd*k, nd*k);
1446 MQ->Eval(mcoeff, Trans, ip);
1447 for (
int i = 0; i < vdim; i++)
1448 for (
int j = 0; j < vdim; j++)
1450 elmat.
AddMatrix(norm*mcoeff(i,j), partelmat, nd*i, nd*j);
1457 norm *= Q->Eval(Trans, ip);
1460 for (
int k = 0; k < vdim; k++)
1468 void VectorMassIntegrator::AssembleElementMatrix2(
1472 int tr_nd = trial_fe.
GetDof();
1473 int te_nd = test_fe.
GetDof();
1480 elmat.
SetSize(te_nd*vdim, tr_nd*vdim);
1481 shape.SetSize(tr_nd);
1482 te_shape.SetSize(te_nd);
1483 partelmat.SetSize(te_nd, tr_nd);
1490 mcoeff.SetSize(vdim);
1497 Trans.
OrderW() + Q_order);
1499 if (trial_fe.
Space() == FunctionSpace::rQk)
1519 MultVWt(te_shape, shape, partelmat);
1523 VQ->Eval(vec, Trans, ip);
1524 for (
int k = 0; k < vdim; k++)
1526 elmat.
AddMatrix(norm*vec(k), partelmat, te_nd*k, tr_nd*k);
1531 MQ->Eval(mcoeff, Trans, ip);
1532 for (
int i = 0; i < vdim; i++)
1533 for (
int j = 0; j < vdim; j++)
1535 elmat.
AddMatrix(norm*mcoeff(i,j), partelmat, te_nd*i, tr_nd*j);
1542 norm *= Q->Eval(Trans, ip);
1545 for (
int k = 0; k < vdim; k++)
1547 elmat.
AddMatrix(partelmat, te_nd*k, tr_nd*k);
1553 void VectorFEDivergenceIntegrator::AssembleElementMatrix2(
1557 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
1559 #ifdef MFEM_THREAD_SAFE
1560 Vector divshape(trial_nd), shape(test_nd);
1562 divshape.SetSize(trial_nd);
1566 elmat.
SetSize(test_nd, trial_nd);
1585 w *= Q->Eval(Trans, ip);
1592 void VectorFEWeakDivergenceIntegrator::AssembleElementMatrix2(
1596 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
1602 "Trial space must be H(Curl) and test space must be H_1");
1604 #ifdef MFEM_THREAD_SAFE
1610 dshape.SetSize(test_nd, dim);
1611 dshapedxt.
SetSize(test_nd, dim);
1612 vshape.
SetSize(trial_nd, dim);
1616 elmat.
SetSize(test_nd, trial_nd);
1658 Mult(dshape, invdfdx, dshapedxt);
1666 w *= Q->Eval(Trans, ip);
1674 void VectorFECurlIntegrator::AssembleElementMatrix2(
1678 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
1680 int dimc = (dim == 3) ? 3 : 1;
1684 "At least one of the finite elements must be in H(Curl)");
1686 int curl_nd, vec_nd;
1698 #ifdef MFEM_THREAD_SAFE
1703 curlshapeTrial.
SetSize(curl_nd, dimc);
1704 curlshapeTrial_dFT.
SetSize(curl_nd, dimc);
1705 vshapeTest.
SetSize(vec_nd, dimc);
1709 elmat.
SetSize(test_nd, trial_nd);
1756 w *= Q->Eval(Trans, ip);
1762 AddMultABt(vshapeTest, curlshapeTrial_dFT, elmat);
1766 AddMultABt(curlshapeTrial_dFT, vshapeTest, elmat);
1771 void DerivativeIntegrator::AssembleElementMatrix2 (
1778 int trial_nd = trial_fe.
GetDof();
1779 int test_nd = test_fe.
GetDof();
1785 elmat.
SetSize (test_nd,trial_nd);
1786 dshape.SetSize (trial_nd,dim);
1787 dshapedxt.SetSize(trial_nd, spaceDim);
1788 dshapedxi.SetSize(trial_nd);
1789 invdfdx.SetSize(dim, spaceDim);
1790 shape.SetSize (test_nd);
1796 if (trial_fe.
Space() == FunctionSpace::Pk)
1805 if (trial_fe.
Space() == FunctionSpace::rQk)
1825 Mult (dshape, invdfdx, dshapedxt);
1829 for (l = 0; l < trial_nd; l++)
1831 dshapedxi(l) = dshapedxt(l,xi);
1834 shape *= Q->Eval(Trans,ip) * det * ip.
weight;
1839 void CurlCurlIntegrator::AssembleElementMatrix
1845 int dimc = (dim == 3) ? 3 : 1;
1848 #ifdef MFEM_THREAD_SAFE
1850 DenseMatrix curlshape(nd,dimc), curlshape_dFt(nd,dimc), M;
1853 curlshape_dFt.SetSize(nd,dimc);
1863 if (el.
Space() == FunctionSpace::Pk)
1896 MQ->Eval(M, Trans, ip);
1898 Mult(curlshape_dFt, M, curlshape);
1903 DQ->Eval(D, Trans, ip);
1909 w *= Q->Eval(Trans, ip);
1919 void CurlCurlIntegrator
1924 #ifdef MFEM_THREAD_SAFE
1931 projcurl.
Mult(u, flux);
1940 int nd = fluxelem.
GetDof();
1943 #ifdef MFEM_THREAD_SAFE
1947 pointflux.SetSize(dim);
1948 if (d_energy) { vec.SetSize(dim); }
1950 int order = 2 * fluxelem.
GetOrder();
1953 double energy = 0.0;
1954 if (d_energy) { *d_energy = 0.0; }
1973 double e = w * (pointflux * pointflux);
1982 #if ANISO_EXPERIMENTAL
2002 #if ANISO_EXPERIMENTAL
2006 int n = (int) round(pow(ir.
GetNPoints(), 1.0/3.0));
2010 for (
int k = 0; k < n; k++)
2011 for (
int l = 0; l < n; l++)
2012 for (
int m = 0; m < n; m++)
2014 Vector &vec = pfluxes[(k*n + l)*n + m];
2017 tmp = vec; tmp -= pfluxes[(k*n + l)*n + (m-1)];
2018 (*d_energy)[0] += (tmp * tmp);
2022 tmp = vec; tmp -= pfluxes[(k*n + (l-1))*n + m];
2023 (*d_energy)[1] += (tmp * tmp);
2027 tmp = vec; tmp -= pfluxes[((k-1)*n + l)*n + m];
2028 (*d_energy)[2] += (tmp * tmp);
2041 void VectorCurlCurlIntegrator::AssembleElementMatrix(
2046 int cld = (dim*(dim-1))/2;
2048 #ifdef MFEM_THREAD_SAFE
2049 DenseMatrix dshape_hat(dof, dim), dshape(dof, dim);
2052 dshape_hat.SetSize(dof, dim);
2054 curlshape.SetSize(dim*dof, cld);
2077 Mult(dshape_hat, Jadj, dshape);
2082 w *= Q->Eval(Trans, ip);
2089 double VectorCurlCurlIntegrator::GetElementEnergy(
2095 #ifdef MFEM_THREAD_SAFE
2096 DenseMatrix dshape_hat(dof, dim), Jadj(dim), grad_hat(dim), grad(dim);
2098 dshape_hat.SetSize(dof, dim);
2101 grad_hat.SetSize(dim);
2115 for (
int i = 0; i < ir->GetNPoints(); i++)
2120 MultAtB(elfun_mat, dshape_hat, grad_hat);
2126 Mult(grad_hat, Jadj, grad);
2130 double curl = grad(0,1) - grad(1,0);
2135 double curl_x = grad(2,1) - grad(1,2);
2136 double curl_y = grad(0,2) - grad(2,0);
2137 double curl_z = grad(1,0) - grad(0,1);
2138 w *= curl_x * curl_x + curl_y * curl_y + curl_z * curl_z;
2143 w *= Q->Eval(Tr, ip);
2149 elfun_mat.ClearExternalData();
2151 return 0.5 * energy;
2155 void VectorFEMassIntegrator::AssembleElementMatrix(
2165 #ifdef MFEM_THREAD_SAFE
2166 Vector D(DQ ? DQ->GetVDim() : 0);
2168 DenseMatrix K(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
2170 trial_vshape.
SetSize(dof, spaceDim);
2171 D.SetSize(DQ ? DQ->GetVDim() : 0);
2172 K.SetSize(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
2174 DenseMatrix tmp(trial_vshape.Height(), K.Width());
2198 MQ->Eval(K, Trans, ip);
2200 Mult(trial_vshape,K,tmp);
2205 DQ->Eval(D, Trans, ip);
2213 w *= Q -> Eval (Trans, ip);
2220 void VectorFEMassIntegrator::AssembleElementMatrix2(
2229 int vdim = MQ ? MQ->GetHeight() : spaceDim;
2230 int trial_dof = trial_fe.
GetDof();
2231 int test_dof = test_fe.
GetDof();
2234 #ifdef MFEM_THREAD_SAFE
2237 Vector D(DQ ? DQ->GetVDim() : 0);
2238 DenseMatrix K(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
2240 trial_vshape.
SetSize(trial_dof, spaceDim);
2242 D.SetSize(DQ ? DQ->GetVDim() : 0);
2243 K.SetSize(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
2246 elmat.
SetSize(vdim*test_dof, trial_dof);
2268 DQ->Eval(D, Trans, ip);
2270 for (
int d = 0; d < vdim; d++)
2272 for (
int j = 0; j < test_dof; j++)
2274 for (
int k = 0; k < trial_dof; k++)
2276 elmat(d * test_dof + j, k) +=
2277 shape(j) * D(d) * trial_vshape(k, d);
2284 MQ->Eval(K, Trans, ip);
2286 for (
int d = 0; d < vdim; d++)
2288 for (
int j = 0; j < test_dof; j++)
2290 for (
int k = 0; k < trial_dof; k++)
2293 for (
int vd = 0; vd < spaceDim; vd++)
2295 Kv += K(d, vd) * trial_vshape(k, vd);
2297 elmat(d * test_dof + j, k) += shape(j) * Kv;
2306 w *= Q->Eval(Trans, ip);
2308 for (
int d = 0; d < vdim; d++)
2310 for (
int j = 0; j < test_dof; j++)
2312 for (
int k = 0; k < trial_dof; k++)
2314 elmat(d * test_dof + j, k) +=
2315 w * shape(j) * trial_vshape(k, d);
2322 else if (test_fe.
GetRangeType() == FiniteElement::VECTOR
2327 int trial_dof = trial_fe.
GetDof();
2328 int test_dof = test_fe.
GetDof();
2331 #ifdef MFEM_THREAD_SAFE
2334 Vector D(DQ ? DQ->GetVDim() : 0);
2335 DenseMatrix K(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
2337 trial_vshape.
SetSize(trial_dof,spaceDim);
2338 test_vshape.
SetSize(test_dof,spaceDim);
2339 D.SetSize(DQ ? DQ->GetVDim() : 0);
2340 K.SetSize(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
2344 elmat.
SetSize (test_dof, trial_dof);
2366 MQ->Eval(K, Trans, ip);
2368 Mult(test_vshape,K,tmp);
2373 DQ->Eval(D, Trans, ip);
2381 w *= Q -> Eval (Trans, ip);
2389 mfem_error(
"VectorFEMassIntegrator::AssembleElementMatrix2(...)\n"
2390 " is not implemented for given trial and test bases.");
2394 void VectorDivergenceIntegrator::AssembleElementMatrix2(
2401 int trial_dof = trial_fe.
GetDof();
2402 int test_dof = test_fe.
GetDof();
2405 dshape.SetSize (trial_dof, dim);
2406 gshape.SetSize (trial_dof, dim);
2408 divshape.SetSize (dim*trial_dof);
2409 shape.SetSize (test_dof);
2411 elmat.
SetSize (test_dof, dim*trial_dof);
2413 const IntegrationRule *ir = IntRule ? IntRule : &GetRule(trial_fe, test_fe,
2418 for (
int i = 0; i < ir -> GetNPoints(); i++)
2428 Mult (dshape, Jadj, gshape);
2430 gshape.GradToDiv (divshape);
2435 c *= Q -> Eval (Trans, ip);
2454 void DivDivIntegrator::AssembleElementMatrix(
2462 #ifdef MFEM_THREAD_SAFE
2478 for (
int i = 0; i < ir -> GetNPoints(); i++)
2489 c *= Q -> Eval (Trans, ip);
2498 void VectorDiffusionIntegrator::AssembleElementMatrix(
2504 const int dof = el.
GetDof();
2508 vdim = (vdim <= 0) ? sdim : vdim;
2509 const bool square = (dim == sdim);
2513 vcoeff.SetSize(vdim);
2517 mcoeff.SetSize(vdim);
2520 dshape.SetSize(dof, dim);
2521 dshapedxt.SetSize(dof, sdim);
2524 pelmat.SetSize(dof);
2529 ir = &DiffusionIntegrator::GetRule(el,el);
2534 for (
int i = 0; i < ir -> GetNPoints(); i++)
2541 double w = Trans.
Weight();
2542 w = ip.
weight / (square ? w : w*w*w);
2549 VQ->Eval(vcoeff, Trans, ip);
2550 for (
int k = 0; k < vdim; ++k)
2558 MQ->Eval(mcoeff, Trans, ip);
2559 for (
int i = 0; i < vdim; ++i)
2561 for (
int j = 0; j < vdim; ++j)
2563 Mult_a_AAt(w*mcoeff(i,j), dshapedxt, pelmat);
2570 if (Q) { w *= Q->Eval(Trans, ip); }
2572 for (
int k = 0; k < vdim; ++k)
2580 void VectorDiffusionIntegrator::AssembleElementVector(
2585 const int dof = el.
GetDof();
2589 vdim = (vdim <= 0) ? sdim : vdim;
2590 const bool square = (dim == sdim);
2594 vcoeff.SetSize(vdim);
2598 mcoeff.SetSize(vdim);
2601 dshape.SetSize(dof, dim);
2602 dshapedxt.SetSize(dof, dim);
2616 ir = &DiffusionIntegrator::GetRule(el,el);
2620 for (
int i = 0; i < ir->GetNPoints(); i++)
2627 w = ip.
weight / (square ? w : w*w*w);
2633 VQ->Eval(vcoeff, Tr, ip);
2634 for (
int k = 0; k < vdim; ++k)
2636 pelmat *= w*vcoeff(k);
2637 const Vector vec_in(mat_in.GetColumn(k), dof);
2638 Vector vec_out(mat_out.GetColumn(k), dof);
2639 pelmat.AddMult(vec_in, vec_out);
2644 MQ->Eval(mcoeff, Tr, ip);
2645 for (
int i = 0; i < vdim; ++i)
2647 Vector vec_out(mat_out.GetColumn(i), dof);
2648 for (
int j = 0; j < vdim; ++j)
2650 pelmat *= w*mcoeff(i,j);
2651 const Vector vec_in(mat_in.GetColumn(j), dof);
2652 pelmat.Mult(vec_in, vec_out);
2658 if (Q) { w *= Q->Eval(Tr, ip); }
2660 for (
int k = 0; k < vdim; ++k)
2662 const Vector vec_in(mat_in.GetColumn(k), dof);
2663 Vector vec_out(mat_out.GetColumn(k), dof);
2664 pelmat.AddMult(vec_in, vec_out);
2671 void ElasticityIntegrator::AssembleElementMatrix(
2680 #ifdef MFEM_THREAD_SAFE
2681 DenseMatrix dshape(dof, dim), gshape(dof, dim), pelmat(dof);
2682 Vector divshape(dim*dof);
2684 dshape.SetSize(dof, dim);
2685 gshape.SetSize(dof, dim);
2686 pelmat.SetSize(dof);
2701 for (
int i = 0; i < ir -> GetNPoints(); i++)
2711 gshape.GradToDiv (divshape);
2713 M =
mu->Eval(Trans, ip);
2716 L = lambda->Eval(Trans, ip);
2731 for (
int d = 0; d <
dim; d++)
2733 for (
int k = 0; k < dof; k++)
2734 for (
int l = 0; l < dof; l++)
2736 elmat (dof*d+k, dof*d+l) += (M * w) * pelmat(k, l);
2739 for (
int i = 0; i <
dim; i++)
2740 for (
int j = 0; j <
dim; j++)
2742 for (
int k = 0; k < dof; k++)
2743 for (
int l = 0; l < dof; l++)
2745 elmat(dof*i+k, dof*j+l) +=
2746 (M * w) * gshape(k, j) * gshape(l, i);
2753 void ElasticityIntegrator::ComputeElementFlux(
2758 const int dof = el.
GetDof();
2760 const int tdim = dim*(dim+1)/2;
2763 MFEM_ASSERT(dim == 2 || dim == 3,
2764 "dimension is not supported: dim = " << dim);
2766 MFEM_ASSERT(fluxelem.
GetMapType() == FiniteElement::VALUE,
"");
2767 MFEM_ASSERT(dynamic_cast<const NodalFiniteElement*>(&fluxelem),
"");
2769 #ifdef MFEM_THREAD_SAFE
2775 double gh_data[9], grad_data[9];
2784 for (
int i = 0; i < fnd; i++)
2788 MultAtB(loc_data_mat, dshape, gh);
2793 M =
mu->Eval(Trans, ip);
2796 L = lambda->Eval(Trans, ip);
2806 const double M2 = 2.0*M;
2809 L *= (grad(0,0) + grad(1,1));
2811 flux(i+fnd*0) = M2*grad(0,0) + L;
2812 flux(i+fnd*1) = M2*grad(1,1) + L;
2813 flux(i+fnd*2) = M*(grad(0,1) + grad(1,0));
2817 L *= (grad(0,0) + grad(1,1) + grad(2,2));
2819 flux(i+fnd*0) = M2*grad(0,0) + L;
2820 flux(i+fnd*1) = M2*grad(1,1) + L;
2821 flux(i+fnd*2) = M2*grad(2,2) + L;
2822 flux(i+fnd*3) = M*(grad(0,1) + grad(1,0));
2823 flux(i+fnd*4) = M*(grad(0,2) + grad(2,0));
2824 flux(i+fnd*5) = M*(grad(1,2) + grad(2,1));
2833 const int dof = fluxelem.
GetDof();
2835 const int tdim = dim*(dim+1)/2;
2840 MFEM_ASSERT(d_energy == NULL,
"anisotropic estimates are not supported");
2841 MFEM_ASSERT(flux.
Size() == dof*tdim,
"invalid 'flux' vector");
2843 #ifndef MFEM_THREAD_SAFE
2848 double pointstress_data[6];
2849 Vector pointstress(pointstress_data, tdim);
2860 int order = 2 * Trans.
OrderGrad(&fluxelem);
2864 double energy = 0.0;
2866 for (
int i = 0; i < ir->GetNPoints(); i++)
2871 flux_mat.MultTranspose(shape, pointstress);
2876 M =
mu->Eval(Trans, ip);
2879 L = lambda->Eval(Trans, ip);
2899 const double *
s = pointstress_data;
2903 const double tr_e = (s[0] + s[1])/(2*(M + L));
2905 pt_e = (0.25/M)*(s[0]*(s[0] - L) + s[1]*(s[1] - L) + 2*s[2]*s[2]);
2910 const double tr_e = (s[0] + s[1] + s[2])/(2*M + 3*L);
2912 pt_e = (0.25/M)*(s[0]*(s[0] - L) + s[1]*(s[1] - L) + s[2]*(s[2] - L) +
2913 2*(s[3]*s[3] + s[4]*s[4] + s[5]*s[5]));
2927 int dim, ndof1, ndof2;
2933 Vector vu(dim), nor(dim);
2944 shape1.SetSize(ndof1);
2945 shape2.SetSize(ndof2);
2961 if (el1.
Space() == FunctionSpace::Pk)
2982 u->Eval(vu, *Trans.
Elem1, eip1);
2986 nor(0) = 2*eip1.
x - 1.0;
2994 a = 0.5 *
alpha * un;
2995 b = beta * fabs(un);
3003 if (un >= 0.0 && ndof2)
3005 rho_p = rho->Eval(*Trans.
Elem2, eip2);
3009 rho_p = rho->Eval(*Trans.
Elem1, eip1);
3018 for (
int i = 0; i < ndof1; i++)
3019 for (
int j = 0; j < ndof1; j++)
3021 elmat(i, j) += w * shape1(i) * shape1(j);
3030 for (
int i = 0; i < ndof2; i++)
3031 for (
int j = 0; j < ndof1; j++)
3033 elmat(ndof1+i, j) -= w * shape2(i) * shape1(j);
3039 for (
int i = 0; i < ndof2; i++)
3040 for (
int j = 0; j < ndof2; j++)
3042 elmat(ndof1+i, ndof1+j) += w * shape2(i) * shape2(j);
3045 for (
int i = 0; i < ndof1; i++)
3046 for (
int j = 0; j < ndof2; j++)
3048 elmat(i, ndof1+j) -= w * shape1(i) * shape2(j);
3063 void DGDiffusionIntegrator::AssembleFaceMatrix(
3067 int dim, ndof1, ndof2, ndofs;
3068 bool kappa_is_nonzero = (
kappa != 0.);
3083 shape1.SetSize(ndof1);
3084 dshape1.SetSize(ndof1, dim);
3085 dshape1dn.SetSize(ndof1);
3089 shape2.SetSize(ndof2);
3090 dshape2.SetSize(ndof2, dim);
3091 dshape2dn.SetSize(ndof2);
3098 ndofs = ndof1 + ndof2;
3101 if (kappa_is_nonzero)
3139 nor(0) = 2*eip1.
x - 1.0;
3157 w *= Q->Eval(*Trans.
Elem1, eip1);
3164 MQ->Eval(mq, *Trans.
Elem1, eip1);
3165 mq.MultTranspose(nh, ni);
3169 if (kappa_is_nonzero)
3184 dshape1.Mult(nh, dshape1dn);
3185 for (
int i = 0; i < ndof1; i++)
3186 for (
int j = 0; j < ndof1; j++)
3188 elmat(i, j) += shape1(i) * dshape1dn(j);
3200 w *= Q->Eval(*Trans.
Elem2, eip2);
3207 MQ->Eval(mq, *Trans.
Elem2, eip2);
3208 mq.MultTranspose(nh, ni);
3212 if (kappa_is_nonzero)
3217 dshape2.Mult(nh, dshape2dn);
3219 for (
int i = 0; i < ndof1; i++)
3220 for (
int j = 0; j < ndof2; j++)
3222 elmat(i, ndof1 + j) += shape1(i) * dshape2dn(j);
3225 for (
int i = 0; i < ndof2; i++)
3226 for (
int j = 0; j < ndof1; j++)
3228 elmat(ndof1 + i, j) -= shape2(i) * dshape1dn(j);
3231 for (
int i = 0; i < ndof2; i++)
3232 for (
int j = 0; j < ndof2; j++)
3234 elmat(ndof1 + i, ndof1 + j) -= shape2(i) * dshape2dn(j);
3238 if (kappa_is_nonzero)
3242 for (
int i = 0; i < ndof1; i++)
3244 const double wsi = wq*shape1(i);
3245 for (
int j = 0; j <= i; j++)
3247 jmat(i, j) += wsi * shape1(j);
3252 for (
int i = 0; i < ndof2; i++)
3254 const int i2 = ndof1 + i;
3255 const double wsi = wq*shape2(i);
3256 for (
int j = 0; j < ndof1; j++)
3258 jmat(i2, j) -= wsi * shape1(j);
3260 for (
int j = 0; j <= i; j++)
3262 jmat(i2, ndof1 + j) += wsi * shape2(j);
3270 if (kappa_is_nonzero)
3272 for (
int i = 0; i < ndofs; i++)
3274 for (
int j = 0; j < i; j++)
3276 double aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
3277 elmat(i,j) =
sigma*aji - aij + mij;
3278 elmat(j,i) =
sigma*aij - aji + mij;
3280 elmat(i,i) = (
sigma - 1.)*elmat(i,i) + jmat(i,i);
3285 for (
int i = 0; i < ndofs; i++)
3287 for (
int j = 0; j < i; j++)
3289 double aij = elmat(i,j), aji = elmat(j,i);
3290 elmat(i,j) =
sigma*aji - aij;
3291 elmat(j,i) =
sigma*aij - aji;
3293 elmat(i,i) *= (
sigma - 1.);
3300 void DGElasticityIntegrator::AssembleBlock(
3301 const int dim,
const int row_ndofs,
const int col_ndofs,
3302 const int row_offset,
const int col_offset,
3303 const double jmatcoef,
const Vector &col_nL,
const Vector &col_nM,
3308 for (
int jm = 0, j = col_offset; jm <
dim; ++jm)
3310 for (
int jdof = 0; jdof < col_ndofs; ++jdof, ++j)
3312 const double t2 = col_dshape_dnM(jdof);
3313 for (
int im = 0, i = row_offset; im <
dim; ++im)
3315 const double t1 = col_dshape(jdof, jm) * col_nL(im);
3316 const double t3 = col_dshape(jdof, im) * col_nM(jm);
3317 const double tt = t1 + ((im == jm) ? t2 : 0.0) + t3;
3318 for (
int idof = 0; idof < row_ndofs; ++idof, ++i)
3320 elmat(i, j) += row_shape(idof) * tt;
3326 if (jmatcoef == 0.0) {
return; }
3328 for (
int d = 0; d <
dim; ++d)
3330 const int jo = col_offset + d*col_ndofs;
3331 const int io = row_offset + d*row_ndofs;
3332 for (
int jdof = 0, j = jo; jdof < col_ndofs; ++jdof, ++j)
3334 const double sj = jmatcoef * col_shape(jdof);
3335 for (
int i = max(io,j), idof = i - io; idof < row_ndofs; ++idof, ++i)
3337 jmat(i, j) += row_shape(idof) * sj;
3343 void DGElasticityIntegrator::AssembleFaceMatrix(
3347 #ifdef MFEM_THREAD_SAFE
3356 Vector dshape1_dnM, dshape2_dnM;
3361 const int ndofs1 = el1.
GetDof();
3363 const int nvdofs = dim*(ndofs1 + ndofs2);
3373 const bool kappa_is_nonzero = (
kappa != 0.0);
3374 if (kappa_is_nonzero)
3383 dshape1_ps.
SetSize(ndofs1, dim);
3393 dshape2_ps.
SetSize(ndofs2, dim);
3407 for (
int pind = 0; pind < ir->
GetNPoints(); ++pind)
3423 Mult(dshape1, adjJ, dshape1_ps);
3427 nor(0) = 2*eip1.
x - 1.0;
3440 Mult(dshape2, adjJ, dshape2_ps);
3444 const double wL2 = w2 * lambda->Eval(*Trans.
Elem2, eip2);
3445 const double wM2 = w2 *
mu->Eval(*Trans.
Elem2, eip2);
3448 wLM = (wL2 + 2.0*wM2);
3449 dshape2_ps.
Mult(nM2, dshape2_dnM);
3459 const double wL1 = w1 * lambda->Eval(*Trans.
Elem1, eip1);
3460 const double wM1 = w1 *
mu->Eval(*Trans.
Elem1, eip1);
3463 wLM += (wL1 + 2.0*wM1);
3464 dshape1_ps.
Mult(nM1, dshape1_dnM);
3467 const double jmatcoef =
kappa * (nor*nor) * wLM;
3471 dim, ndofs1, ndofs1, 0, 0, jmatcoef, nL1, nM1,
3472 shape1, shape1, dshape1_dnM, dshape1_ps, elmat, jmat);
3474 if (ndofs2 == 0) {
continue; }
3481 dim, ndofs1, ndofs2, 0, dim*ndofs1, jmatcoef, nL2, nM2,
3482 shape1, shape2, dshape2_dnM, dshape2_ps, elmat, jmat);
3485 dim, ndofs2, ndofs1, dim*ndofs1, 0, jmatcoef, nL1, nM1,
3486 shape2, shape1, dshape1_dnM, dshape1_ps, elmat, jmat);
3489 dim, ndofs2, ndofs2, dim*ndofs1, dim*ndofs1, jmatcoef, nL2, nM2,
3490 shape2, shape2, dshape2_dnM, dshape2_ps, elmat, jmat);
3494 if (kappa_is_nonzero)
3496 for (
int i = 0; i < nvdofs; ++i)
3498 for (
int j = 0; j < i; ++j)
3500 double aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
3501 elmat(i,j) =
alpha*aji - aij + mij;
3502 elmat(j,i) =
alpha*aij - aji + mij;
3504 elmat(i,i) = (
alpha - 1.)*elmat(i,i) + jmat(i,i);
3509 for (
int i = 0; i < nvdofs; ++i)
3511 for (
int j = 0; j < i; ++j)
3513 double aij = elmat(i,j), aji = elmat(j,i);
3514 elmat(i,j) =
alpha*aji - aij;
3515 elmat(j,i) =
alpha*aij - aji;
3517 elmat(i,i) *= (
alpha - 1.);
3523 void TraceJumpIntegrator::AssembleFaceMatrix(
3528 int i, j, face_ndof, ndof1, ndof2;
3533 face_ndof = trial_face_fe.
GetDof();
3534 ndof1 = test_fe1.
GetDof();
3536 face_shape.SetSize(face_ndof);
3537 shape1.SetSize(ndof1);
3541 ndof2 = test_fe2.
GetDof();
3542 shape2.SetSize(ndof2);
3549 elmat.
SetSize(ndof1 + ndof2, face_ndof);
3564 if (trial_face_fe.
GetMapType() == FiniteElement::VALUE)
3584 trial_face_fe.
CalcShape(ip, face_shape);
3593 if (trial_face_fe.
GetMapType() == FiniteElement::VALUE)
3598 for (i = 0; i < ndof1; i++)
3599 for (j = 0; j < face_ndof; j++)
3601 elmat(i, j) += shape1(i) * face_shape(j);
3606 for (i = 0; i < ndof2; i++)
3607 for (j = 0; j < face_ndof; j++)
3609 elmat(ndof1+i, j) -= shape2(i) * face_shape(j);
3615 void NormalTraceJumpIntegrator::AssembleFaceMatrix(
3620 int i, j, face_ndof, ndof1, ndof2,
dim;
3623 MFEM_VERIFY(trial_face_fe.
GetMapType() == FiniteElement::VALUE,
"");
3625 face_ndof = trial_face_fe.
GetDof();
3626 ndof1 = test_fe1.
GetDof();
3629 face_shape.SetSize(face_ndof);
3630 normal.SetSize(dim);
3631 shape1.SetSize(ndof1,dim);
3632 shape1_n.SetSize(ndof1);
3636 ndof2 = test_fe2.
GetDof();
3637 shape2.SetSize(ndof2,dim);
3638 shape2_n.SetSize(ndof2);
3645 elmat.
SetSize(ndof1 + ndof2, face_ndof);
3668 trial_face_fe.
CalcShape(ip, face_shape);
3674 shape1.Mult(normal, shape1_n);
3682 shape2.Mult(normal, shape2_n);
3685 for (i = 0; i < ndof1; i++)
3686 for (j = 0; j < face_ndof; j++)
3688 elmat(i, j) -= shape1_n(i) * face_shape(j);
3693 for (i = 0; i < ndof2; i++)
3694 for (j = 0; j < face_ndof; j++)
3696 elmat(ndof1+i, j) += shape2_n(i) * face_shape(j);
3703 void NormalInterpolator::AssembleElementMatrix2(
3712 for (
int i = 0; i < ran_nodes.Size(); i++)
3718 for (
int j = 0; j < shape.Size(); j++)
3720 for (
int d = 0; d < spaceDim; d++)
3722 elmat(i, j+d*shape.Size()) = shape(j)*n(d);
3742 using VectorCoefficient::Eval;
3743 virtual void Eval(Vector &V, ElementTransformation &T,
3744 const IntegrationPoint &ip)
3747 fe.CalcPhysShape(T, V);
3760 internal::ShapeCoefficient dom_shape_coeff(*Q, dom_fe);
3766 ran_fe.
Project(dom_shape_coeff, Trans, elmat_as_vec);
3771 ScalarVectorProductInterpolator::AssembleElementMatrix2(
3790 fe.CalcPhysVShape(T, M);
3795 VShapeCoefficient dom_shape_coeff(*Q, dom_fe, Trans.
GetSpaceDim());
3806 VectorScalarProductInterpolator::AssembleElementMatrix2(
3821 vc(width), shape(height) { }
3828 fe.CalcPhysShape(T, shape);
3833 VecShapeCoefficient dom_shape_coeff(*VQ, dom_fe);
3844 ScalarCrossProductInterpolator::AssembleElementMatrix2(
3862 using VectorCoefficient::Eval;
3868 fe.CalcPhysVShape(T, vshape);
3869 for (
int k = 0; k < vdim; k++)
3871 V(k) = vc(0) * vshape(k,1) - vc(1) * vshape(k,0);
3876 VCrossVShapeCoefficient dom_shape_coeff(*VQ, dom_fe);
3882 ran_fe.
Project(dom_shape_coeff, Trans, elmat_as_vec);
3886 VectorCrossProductInterpolator::AssembleElementMatrix2(
3902 vshape(height, width), vc(width)
3904 MFEM_ASSERT(width == 3,
"");
3912 fe.CalcPhysVShape(T, vshape);
3913 for (
int k = 0; k < height; k++)
3915 M(k,0) = vc(1) * vshape(k,2) - vc(2) * vshape(k,1);
3916 M(k,1) = vc(2) * vshape(k,0) - vc(0) * vshape(k,2);
3917 M(k,2) = vc(0) * vshape(k,1) - vc(1) * vshape(k,0);
3922 VCrossVShapeCoefficient dom_shape_coeff(*VQ, dom_fe);
3953 vshape(vdim, vq.GetVDim()), vc(vq.GetVDim()) { }
3955 using VectorCoefficient::Eval;
3956 virtual void Eval(Vector &V, ElementTransformation &T,
3957 const IntegrationPoint &ip)
3961 fe.CalcPhysVShape(T, vshape);
3969 VectorInnerProductInterpolator::AssembleElementMatrix2(
3975 internal::VDotVShapeCoefficient dom_shape_coeff(*VQ, dom_fe);
3981 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 all 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.
Base class for vector Coefficients that optionally depend on time and space.
virtual void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const
Given a coefficient and a transformation, compute its projection (approximation) in the local finite ...
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the vector coefficient in the element described by T at the point ip, storing the result in ...
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 Size() const
Returns the size of the vector.
int Space() const
Returns the type of FunctionSpace on the element.
void AddMult_a_ABt(double a, const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt)
ABt += a * A * B^t.
int GetMapType() const
Returns the FiniteElement::MapType of the element describing how reference functions are mapped to ph...
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)
void Mult_a_AAt(double a, const DenseMatrix &A, DenseMatrix &AAt)
AAt = a * A * A^t.
void add(const Vector &v1, const Vector &v2, Vector &v)
virtual void ProjectCurl(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
Compute the discrete curl matrix from the given FiniteElement onto 'this' FiniteElement. The ElementTransformation is included to support cases when the matrix depends on it.
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
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
Get a const reference to the nodes of the element.
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)
double * Data() const
Returns the matrix data array.
double p(const Vector &x, double t)
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.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
int GetDof() const
Returns the number of degrees of freedom in the finite element.
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
void CalcPhysShape(ElementTransformation &Trans, Vector &shape) const
Evaluate the values of all shape functions of a scalar finite element in physical space at the point ...
Base class for Matrix Coefficients that optionally depend on time and space.
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
Given a matrix coefficient and a transformation, compute an approximation ("projection") in the local...
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.
double u(const Vector &xvec)
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...
int GetRangeType() const
Returns the FiniteElement::RangeType of the element, one of {SCALAR, VECTOR}.
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)