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);
453 ir = &
IntRules.
Get(trial_fe.GetGeomType(), ir_order);
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());
489 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
490 int test_vdim = GetTestVDim(test_fe);
491 int trial_vdim = GetTrialVDim(trial_fe);
492 bool same_shapes = same_calc_shape && (&trial_fe == &test_fe);
496 MFEM_VERIFY(MQ->GetHeight() == test_vdim,
497 "Dimension mismatch in height of matrix coefficient.");
498 MFEM_VERIFY(MQ->GetWidth() == trial_vdim,
499 "Dimension mismatch in width of matrix coefficient.");
503 MFEM_VERIFY(trial_vdim == test_vdim,
504 "Diagonal matrix coefficient requires matching "
505 "test and trial vector dimensions.");
506 MFEM_VERIFY(DQ->GetVDim() == trial_vdim,
507 "Dimension mismatch in diagonal matrix coefficient.");
511 MFEM_VERIFY(VQ->GetVDim() == 3,
"Vector coefficient must have "
512 "dimension equal to three.");
515 #ifdef MFEM_THREAD_SAFE
516 Vector V(VQ ? VQ->GetVDim() : 0);
517 Vector D(DQ ? DQ->GetVDim() : 0);
518 DenseMatrix M(MQ ? MQ->GetHeight() : 0, MQ ? MQ->GetWidth() : 0);
523 V.SetSize(VQ ? VQ->GetVDim() : 0);
524 D.SetSize(DQ ? DQ->GetVDim() : 0);
525 M.SetSize(MQ ? MQ->GetHeight() : 0, MQ ? MQ->GetWidth() : 0);
526 test_shape.SetSize(test_nd, test_vdim);
527 shape_tmp.
SetSize(test_nd, trial_vdim);
531 trial_shape.
Reset(test_shape.Data(), trial_nd, trial_vdim);
535 trial_shape.
SetSize(trial_nd, trial_vdim);
538 elmat.
SetSize(test_nd, trial_nd);
543 int ir_order = this->GetIntegrationOrder(trial_fe, test_fe, Trans);
544 ir = &
IntRules.
Get(trial_fe.GetGeomType(), ir_order);
553 this->CalcTestShape(test_fe, Trans, test_shape);
556 this->CalcTrialShape(trial_fe, Trans, trial_shape);
563 MQ->Eval(M, Trans, ip);
565 Mult(test_shape, M, shape_tmp);
570 DQ->Eval(D, Trans, ip);
576 VQ->Eval(V, Trans, ip);
579 for (
int j=0; j<test_nd; j++)
585 if (test_vdim == 3 && trial_vdim == 3)
587 shape_tmp(j,0) = test_shape(j,1) * V(2) -
588 test_shape(j,2) * V(1);
589 shape_tmp(j,1) = test_shape(j,2) * V(0) -
590 test_shape(j,0) * V(2);
591 shape_tmp(j,2) = test_shape(j,0) * V(1) -
592 test_shape(j,1) * V(0);
594 else if (test_vdim == 3 && trial_vdim == 2)
596 shape_tmp(j,0) = test_shape(j,1) * V(2) -
597 test_shape(j,2) * V(1);
598 shape_tmp(j,1) = test_shape(j,2) * V(0) -
599 test_shape(j,0) * V(2);
601 else if (test_vdim == 3 && trial_vdim == 1)
603 shape_tmp(j,0) = test_shape(j,1) * V(2) -
604 test_shape(j,2) * V(1);
606 else if (test_vdim == 2 && trial_vdim == 3)
608 shape_tmp(j,0) = test_shape(j,1) * V(2);
609 shape_tmp(j,1) = -test_shape(j,0) * V(2);
610 shape_tmp(j,2) = test_shape(j,0) * V(1) -
611 test_shape(j,1) * V(0);
613 else if (test_vdim == 2 && trial_vdim == 2)
615 shape_tmp(j,0) = test_shape(j,1) * V(2);
616 shape_tmp(j,1) = -test_shape(j,0) * V(2);
618 else if (test_vdim == 1 && trial_vdim == 3)
620 shape_tmp(j,0) = 0.0;
621 shape_tmp(j,1) = -test_shape(j,0) * V(2);
622 shape_tmp(j,2) = test_shape(j,0) * V(1);
624 else if (test_vdim == 1 && trial_vdim == 1)
626 shape_tmp(j,0) = 0.0;
635 w *= Q -> Eval (Trans, ip);
647 #ifndef MFEM_THREAD_SAFE
655 void MixedScalarVectorIntegrator::AssembleElementMatrix2(
659 MFEM_ASSERT(this->VerifyFiniteElementTypes(trial_fe, test_fe),
660 this->FiniteElementTypeFailureMessage());
662 MFEM_VERIFY(VQ,
"MixedScalarVectorIntegrator: "
663 "VectorCoefficient must be set");
669 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
670 int sca_nd = sca_fe->
GetDof();
671 int vec_nd = vec_fe->
GetDof();
672 int vdim = GetVDim(*vec_fe);
675 MFEM_VERIFY(VQ->GetVDim() == vdim,
"MixedScalarVectorIntegrator: "
676 "Dimensions of VectorCoefficient and Vector-valued basis "
677 "functions must match");
679 #ifdef MFEM_THREAD_SAFE
683 Vector vshape_tmp(vec_nd);
694 elmat.
SetSize(test_nd, trial_nd);
699 int ir_order = this->GetIntegrationOrder(trial_fe, test_fe, Trans);
709 this->CalcShape(*sca_fe, Trans, shape);
710 this->CalcVShape(*vec_fe, Trans, vshape);
714 VQ->Eval(V, Trans, ip);
717 if ( vdim == 2 && cross_2d )
724 vshape.
Mult(V,vshape_tmp);
730 void GradientIntegrator::AssembleElementMatrix2(
735 int trial_dof = trial_fe.
GetDof();
736 int test_dof = test_fe.
GetDof();
741 gshape.SetSize(trial_dof,
dim);
743 shape.SetSize(test_dof);
746 const IntegrationRule *ir = IntRule ? IntRule : &GetRule(trial_fe, test_fe,
750 elmat_comp.
SetSize(test_dof, trial_dof);
762 Mult(dshape, Jadj, gshape);
767 c *= Q->Eval(Trans, ip);
771 for (
int d = 0; d <
dim; ++d)
773 gshape.GetColumnReference(d, d_col);
774 MultVWt(shape, d_col, elmat_comp);
775 for (
int jj = 0; jj < trial_dof; ++jj)
777 for (
int ii = 0; ii < test_dof; ++ii)
779 elmat(d * test_dof + ii, jj) += elmat_comp(ii, jj);
796 void DiffusionIntegrator::AssembleElementMatrix
803 bool square = (
dim == spaceDim);
808 MFEM_VERIFY(VQ->GetVDim() == spaceDim,
809 "Unexpected dimension for VectorCoefficient");
813 MFEM_VERIFY(MQ->GetWidth() == spaceDim,
814 "Unexpected width for MatrixCoefficient");
815 MFEM_VERIFY(MQ->GetHeight() == spaceDim,
816 "Unexpected height for MatrixCoefficient");
819 #ifdef MFEM_THREAD_SAFE
823 Vector D(VQ ? VQ->GetVDim() : 0);
826 dshapedxt.
SetSize(nd, spaceDim);
827 dshapedxt_m.
SetSize(nd, MQ ? spaceDim : 0);
829 D.SetSize(VQ ? VQ->GetVDim() : 0);
843 w = ip.
weight / (square ? w : w*w*w);
849 MQ->Eval(M, Trans, ip);
851 Mult(dshapedxt, M, dshapedxt_m);
856 VQ->Eval(D, Trans, ip);
864 w *= Q->Eval(Trans, ip);
871 void DiffusionIntegrator::AssembleElementMatrix2(
875 int tr_nd = trial_fe.
GetDof();
876 int te_nd = test_fe.
GetDof();
879 bool square = (
dim == spaceDim);
884 MFEM_VERIFY(VQ->GetVDim() == spaceDim,
885 "Unexpected dimension for VectorCoefficient");
889 MFEM_VERIFY(MQ->GetWidth() == spaceDim,
890 "Unexpected width for MatrixCoefficient");
891 MFEM_VERIFY(MQ->GetHeight() == spaceDim,
892 "Unexpected height for MatrixCoefficient");
895 #ifdef MFEM_THREAD_SAFE
901 Vector D(VQ ? VQ->GetVDim() : 0);
904 dshapedxt.
SetSize(tr_nd, spaceDim);
905 te_dshape.SetSize(te_nd,
dim);
906 te_dshapedxt.
SetSize(te_nd, spaceDim);
908 dshapedxt_m.
SetSize(te_nd, MQ ? spaceDim : 0);
910 D.SetSize(VQ ? VQ->GetVDim() : 0);
914 const IntegrationRule *ir = IntRule ? IntRule : &GetRule(trial_fe, test_fe);
926 w = ip.
weight / (square ? w : w*w*w);
927 Mult(dshape, invdfdx, dshapedxt);
928 Mult(te_dshape, invdfdx, te_dshapedxt);
932 MQ->Eval(M, Trans, ip);
934 Mult(te_dshapedxt, M, dshapedxt_m);
939 VQ->Eval(D, Trans, ip);
947 w *= Q->Eval(Trans, ip);
955 void DiffusionIntegrator::AssembleElementVector(
966 MFEM_VERIFY(VQ->GetVDim() == spaceDim,
967 "Unexpected dimension for VectorCoefficient");
971 MFEM_VERIFY(MQ->GetWidth() == spaceDim,
972 "Unexpected width for MatrixCoefficient");
973 MFEM_VERIFY(MQ->GetHeight() == spaceDim,
974 "Unexpected height for MatrixCoefficient");
977 #ifdef MFEM_THREAD_SAFE
979 Vector D(VQ ? VQ->GetVDim() : 0);
982 invdfdx.SetSize(
dim, spaceDim);
984 D.SetSize(VQ ? VQ->GetVDim() : 0);
987 vecdxt.SetSize((VQ || MQ) ? spaceDim : 0);
988 pointflux.SetSize(spaceDim);
1006 dshape.MultTranspose(elfun, vec);
1007 invdfdx.MultTranspose(vec, pointflux);
1010 w *= Q->Eval(Tr, ip);
1015 dshape.MultTranspose(elfun, vec);
1016 invdfdx.MultTranspose(vec, vecdxt);
1019 MQ->Eval(M, Tr, ip);
1020 M.
Mult(vecdxt, pointflux);
1024 VQ->Eval(D, Tr, ip);
1025 for (
int j=0; j<spaceDim; ++j)
1027 pointflux[j] = D[j] * vecdxt[j];
1032 invdfdx.Mult(pointflux, vec);
1033 dshape.AddMult(vec, elvect);
1037 void DiffusionIntegrator::ComputeElementFlux
1041 int nd, spaceDim, fnd;
1049 MFEM_VERIFY(VQ->GetVDim() == spaceDim,
1050 "Unexpected dimension for VectorCoefficient");
1054 MFEM_VERIFY(MQ->GetWidth() == spaceDim,
1055 "Unexpected width for MatrixCoefficient");
1056 MFEM_VERIFY(MQ->GetHeight() == spaceDim,
1057 "Unexpected height for MatrixCoefficient");
1060 MFEM_VERIFY(!SMQ,
"SymmetricMatrixCoefficient not supported here");
1062 #ifdef MFEM_THREAD_SAFE
1065 Vector D(VQ ? VQ->GetVDim() : 0);
1070 D.SetSize(VQ ? VQ->GetVDim() : 0);
1073 vecdxt.SetSize(spaceDim);
1074 pointflux.SetSize(MQ || VQ ? spaceDim : 0);
1078 flux.
SetSize( fnd * spaceDim );
1080 for (
int i = 0; i < fnd; i++)
1084 dshape.MultTranspose(u, vec);
1096 vecdxt *= Q->Eval(Trans,ip);
1098 for (
int j = 0; j < spaceDim; j++)
1100 flux(fnd*j+i) = vecdxt(j);
1107 MQ->Eval(M, Trans, ip);
1108 M.
Mult(vecdxt, pointflux);
1112 VQ->Eval(D, Trans, ip);
1113 for (
int j=0; j<spaceDim; ++j)
1115 pointflux[j] = D[j] * vecdxt[j];
1118 for (
int j = 0; j < spaceDim; j++)
1120 flux(fnd*j+i) = pointflux(j);
1126 for (
int j = 0; j < spaceDim; j++)
1128 flux(fnd*j+i) = vecdxt(j);
1134 double DiffusionIntegrator::ComputeFluxEnergy
1138 int nd = fluxelem.
GetDof();
1142 #ifdef MFEM_THREAD_SAFE
1144 Vector D(VQ ? VQ->GetVDim() : 0);
1146 D.
SetSize(VQ ? VQ->GetVDim() : 0);
1149 MFEM_VERIFY(!SMQ,
"SymmetricMatrixCoefficient not supported here");
1152 pointflux.SetSize(spaceDim);
1153 if (d_energy) { vec.SetSize(spaceDim); }
1154 if (MQ) { M.
SetSize(spaceDim); }
1156 int order = 2 * fluxelem.
GetOrder();
1159 double energy = 0.0;
1160 if (d_energy) { *d_energy = 0.0; }
1168 for (
int k = 0; k < spaceDim; k++)
1170 for (
int j = 0; j < nd; j++)
1172 pointflux(k) += flux(k*nd+j)*shape(j);
1181 MQ->Eval(M, Trans, ip);
1186 VQ->Eval(D, Trans, ip);
1188 energy += w * (D * pointflux);
1192 double e = (pointflux * pointflux);
1193 if (Q) { e *= Q->Eval(Trans, ip); }
1201 for (
int k = 0; k <
dim; k++)
1203 (*d_energy)[k] += w * vec[k] * vec[k];
1216 if (trial_fe.
Space() == FunctionSpace::Pk)
1226 if (trial_fe.
Space() == FunctionSpace::rQk)
1234 void MassIntegrator::AssembleElementMatrix
1242 #ifdef MFEM_THREAD_SAFE
1248 const IntegrationRule *ir = IntRule ? IntRule : &GetRule(el, el, Trans);
1261 w *= Q -> Eval(Trans, ip);
1268 void MassIntegrator::AssembleElementMatrix2(
1272 int tr_nd = trial_fe.
GetDof();
1273 int te_nd = test_fe.
GetDof();
1276 #ifdef MFEM_THREAD_SAFE
1284 &GetRule(trial_fe, test_fe, Trans);
1297 w *= Q -> Eval(Trans, ip);
1312 if (trial_fe.
Space() == FunctionSpace::rQk)
1320 void BoundaryMassIntegrator::AssembleFaceMatrix(
1324 MFEM_ASSERT(Trans.
Elem2No < 0,
1325 "support for interior faces is not implemented");
1330 #ifdef MFEM_THREAD_SAFE
1359 w *= Q -> Eval(Trans, ip);
1366 void ConvectionIntegrator::AssembleElementMatrix(
1372 #ifdef MFEM_THREAD_SAFE
1374 Vector shape, vec2, BdFidxT;
1392 Q->Eval(Q_ir, Trans, *ir);
1406 adjJ.
Mult(vec1, vec2);
1407 dshape.
Mult(vec2, BdFidxT);
1414 void GroupConvectionIntegrator::AssembleElementMatrix(
1421 dshape.SetSize(nd,dim);
1424 grad.SetSize(nd,dim);
1433 Q->Eval(Q_nodal, Trans, el.
GetNodes());
1445 Mult(dshape, adjJ, grad);
1450 for (
int k = 0; k < nd; k++)
1452 double wsk = w*shape(k);
1453 for (
int l = 0; l < nd; l++)
1456 for (
int s = 0;
s <
dim;
s++)
1458 a += Q_nodal(
s,k)*grad(l,
s);
1460 elmat(k,l) += wsk*
a;
1478 return GetRule(el,el,Trans);
1481 void VectorMassIntegrator::AssembleElementMatrix
1491 vdim = (vdim == -1) ? spaceDim : vdim;
1495 partelmat.SetSize(nd);
1502 mcoeff.SetSize(vdim);
1510 if (el.
Space() == FunctionSpace::rQk)
1533 VQ->Eval(vec, Trans, ip);
1534 for (
int k = 0; k < vdim; k++)
1536 elmat.
AddMatrix(norm*vec(k), partelmat, nd*k, nd*k);
1541 MQ->Eval(mcoeff, Trans, ip);
1542 for (
int i = 0; i < vdim; i++)
1543 for (
int j = 0; j < vdim; j++)
1545 elmat.
AddMatrix(norm*mcoeff(i,j), partelmat, nd*i, nd*j);
1552 norm *= Q->Eval(Trans, ip);
1555 for (
int k = 0; k < vdim; k++)
1563 void VectorMassIntegrator::AssembleElementMatrix2(
1567 int tr_nd = trial_fe.
GetDof();
1568 int te_nd = test_fe.
GetDof();
1575 elmat.
SetSize(te_nd*vdim, tr_nd*vdim);
1576 shape.SetSize(tr_nd);
1577 te_shape.SetSize(te_nd);
1578 partelmat.SetSize(te_nd, tr_nd);
1585 mcoeff.SetSize(vdim);
1592 Trans.
OrderW() + Q_order);
1594 if (trial_fe.
Space() == FunctionSpace::rQk)
1614 MultVWt(te_shape, shape, partelmat);
1618 VQ->Eval(vec, Trans, ip);
1619 for (
int k = 0; k < vdim; k++)
1621 elmat.
AddMatrix(norm*vec(k), partelmat, te_nd*k, tr_nd*k);
1626 MQ->Eval(mcoeff, Trans, ip);
1627 for (
int i = 0; i < vdim; i++)
1628 for (
int j = 0; j < vdim; j++)
1630 elmat.
AddMatrix(norm*mcoeff(i,j), partelmat, te_nd*i, tr_nd*j);
1637 norm *= Q->Eval(Trans, ip);
1640 for (
int k = 0; k < vdim; k++)
1642 elmat.
AddMatrix(partelmat, te_nd*k, tr_nd*k);
1648 void VectorFEDivergenceIntegrator::AssembleElementMatrix2(
1652 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
1654 #ifdef MFEM_THREAD_SAFE
1655 Vector divshape(trial_nd), shape(test_nd);
1657 divshape.SetSize(trial_nd);
1661 elmat.
SetSize(test_nd, trial_nd);
1680 w *= Q->Eval(Trans, ip);
1687 void VectorFEWeakDivergenceIntegrator::AssembleElementMatrix2(
1691 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
1697 "Trial space must be H(Curl) and test space must be H_1");
1699 #ifdef MFEM_THREAD_SAFE
1705 dshape.SetSize(test_nd, dim);
1706 dshapedxt.
SetSize(test_nd, dim);
1707 vshape.
SetSize(trial_nd, dim);
1711 elmat.
SetSize(test_nd, trial_nd);
1739 int ir_order = (trial_fe.
Space() == FunctionSpace::Pk) ?
1753 Mult(dshape, invdfdx, dshapedxt);
1761 w *= Q->Eval(Trans, ip);
1769 void VectorFECurlIntegrator::AssembleElementMatrix2(
1773 int trial_nd = trial_fe.
GetDof(), test_nd = test_fe.
GetDof(), i;
1775 int dimc = (dim == 3) ? 3 : 1;
1779 "At least one of the finite elements must be in H(Curl)");
1781 int curl_nd, vec_nd;
1793 #ifdef MFEM_THREAD_SAFE
1798 curlshapeTrial.
SetSize(curl_nd, dimc);
1799 curlshapeTrial_dFT.
SetSize(curl_nd, dimc);
1800 vshapeTest.
SetSize(vec_nd, dimc);
1804 elmat.
SetSize(test_nd, trial_nd);
1851 w *= Q->Eval(Trans, ip);
1857 AddMultABt(vshapeTest, curlshapeTrial_dFT, elmat);
1861 AddMultABt(curlshapeTrial_dFT, vshapeTest, elmat);
1866 void DerivativeIntegrator::AssembleElementMatrix2 (
1873 int trial_nd = trial_fe.
GetDof();
1874 int test_nd = test_fe.
GetDof();
1880 elmat.
SetSize (test_nd,trial_nd);
1881 dshape.SetSize (trial_nd,dim);
1882 dshapedxt.SetSize(trial_nd, spaceDim);
1883 dshapedxi.SetSize(trial_nd);
1884 invdfdx.SetSize(dim, spaceDim);
1885 shape.SetSize (test_nd);
1891 if (trial_fe.
Space() == FunctionSpace::Pk)
1900 if (trial_fe.
Space() == FunctionSpace::rQk)
1920 Mult (dshape, invdfdx, dshapedxt);
1924 for (l = 0; l < trial_nd; l++)
1926 dshapedxi(l) = dshapedxt(l,xi);
1929 shape *= Q->Eval(Trans,ip) * det * ip.
weight;
1934 void CurlCurlIntegrator::AssembleElementMatrix
1943 #ifdef MFEM_THREAD_SAFE
1945 DenseMatrix curlshape(nd,dimc), curlshape_dFt(nd,dimc), M;
1948 curlshape_dFt.SetSize(nd,dimc);
1958 if (el.
Space() == FunctionSpace::Pk)
1982 MQ->Eval(M, Trans, ip);
1984 Mult(curlshape_dFt, M, curlshape);
1989 DQ->Eval(D, Trans, ip);
1995 w *= Q->Eval(Trans, ip);
2005 void CurlCurlIntegrator
2010 #ifdef MFEM_THREAD_SAFE
2017 projcurl.
Mult(u, flux);
2026 int nd = fluxelem.
GetDof();
2029 #ifdef MFEM_THREAD_SAFE
2033 pointflux.SetSize(
dim);
2034 if (d_energy) { vec.SetSize(
dim); }
2036 int order = 2 * fluxelem.
GetOrder();
2039 double energy = 0.0;
2040 if (d_energy) { *d_energy = 0.0; }
2059 double e = w * (pointflux * pointflux);
2068 #if ANISO_EXPERIMENTAL
2088 #if ANISO_EXPERIMENTAL
2096 for (
int k = 0; k < n; k++)
2097 for (
int l = 0; l < n; l++)
2098 for (
int m = 0; m < n; m++)
2100 Vector &vec = pfluxes[(k*n + l)*n + m];
2103 tmp = vec; tmp -= pfluxes[(k*n + l)*n + (m-1)];
2104 (*d_energy)[0] += (tmp * tmp);
2108 tmp = vec; tmp -= pfluxes[(k*n + (l-1))*n + m];
2109 (*d_energy)[1] += (tmp * tmp);
2113 tmp = vec; tmp -= pfluxes[((k-1)*n + l)*n + m];
2114 (*d_energy)[2] += (tmp * tmp);
2127 void VectorCurlCurlIntegrator::AssembleElementMatrix(
2132 int cld = (dim*(dim-1))/2;
2134 #ifdef MFEM_THREAD_SAFE
2135 DenseMatrix dshape_hat(dof, dim), dshape(dof, dim);
2138 dshape_hat.SetSize(dof, dim);
2140 curlshape.SetSize(dim*dof, cld);
2163 Mult(dshape_hat, Jadj, dshape);
2168 w *= Q->Eval(Trans, ip);
2175 double VectorCurlCurlIntegrator::GetElementEnergy(
2181 #ifdef MFEM_THREAD_SAFE
2182 DenseMatrix dshape_hat(dof, dim), Jadj(dim), grad_hat(dim), grad(dim);
2184 dshape_hat.SetSize(dof, dim);
2187 grad_hat.SetSize(dim);
2201 for (
int i = 0; i < ir->GetNPoints(); i++)
2206 MultAtB(elfun_mat, dshape_hat, grad_hat);
2212 Mult(grad_hat, Jadj, grad);
2216 double curl = grad(0,1) - grad(1,0);
2221 double curl_x = grad(2,1) - grad(1,2);
2222 double curl_y = grad(0,2) - grad(2,0);
2223 double curl_z = grad(1,0) - grad(0,1);
2224 w *= curl_x * curl_x + curl_y * curl_y + curl_z * curl_z;
2229 w *= Q->Eval(Tr, ip);
2235 elfun_mat.ClearExternalData();
2237 return 0.5 * energy;
2241 void VectorFEMassIntegrator::AssembleElementMatrix(
2248 int vdim = std::max(spaceDim, el.
GetVDim());
2252 #ifdef MFEM_THREAD_SAFE
2253 Vector D(DQ ? DQ->GetVDim() : 0);
2255 DenseMatrix K(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
2257 trial_vshape.
SetSize(dof, vdim);
2258 D.SetSize(DQ ? DQ->GetVDim() : 0);
2259 K.SetSize(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
2261 DenseMatrix tmp(trial_vshape.Height(), K.Width());
2285 MQ->Eval(K, Trans, ip);
2287 Mult(trial_vshape,K,tmp);
2292 DQ->Eval(D, Trans, ip);
2300 w *= Q -> Eval (Trans, ip);
2307 void VectorFEMassIntegrator::AssembleElementMatrix2(
2316 int vdim = std::max(spaceDim, trial_fe.
GetVDim());
2317 int trial_dof = trial_fe.
GetDof();
2318 int test_dof = test_fe.
GetDof();
2321 #ifdef MFEM_THREAD_SAFE
2324 Vector D(DQ ? DQ->GetVDim() : 0);
2325 DenseMatrix K(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
2327 trial_vshape.
SetSize(trial_dof, spaceDim);
2329 D.SetSize(DQ ? DQ->GetVDim() : 0);
2330 K.SetSize(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
2333 elmat.
SetSize(vdim*test_dof, trial_dof);
2355 DQ->Eval(D, Trans, ip);
2357 for (
int d = 0; d < vdim; d++)
2359 for (
int j = 0; j < test_dof; j++)
2361 for (
int k = 0; k < trial_dof; k++)
2363 elmat(d * test_dof + j, k) +=
2364 shape(j) * D(d) * trial_vshape(k, d);
2371 MQ->Eval(K, Trans, ip);
2373 for (
int d = 0; d < vdim; d++)
2375 for (
int j = 0; j < test_dof; j++)
2377 for (
int k = 0; k < trial_dof; k++)
2380 for (
int vd = 0; vd < spaceDim; vd++)
2382 Kv += K(d, vd) * trial_vshape(k, vd);
2384 elmat(d * test_dof + j, k) += shape(j) * Kv;
2393 w *= Q->Eval(Trans, ip);
2395 for (
int d = 0; d < vdim; d++)
2397 for (
int j = 0; j < test_dof; j++)
2399 for (
int k = 0; k < trial_dof; k++)
2401 elmat(d * test_dof + j, k) +=
2402 w * shape(j) * trial_vshape(k, d);
2409 else if (test_fe.
GetRangeType() == FiniteElement::VECTOR
2414 int trial_vdim = std::max(spaceDim, trial_fe.
GetVDim());
2415 int test_vdim = std::max(spaceDim, test_fe.
GetVDim());
2416 int trial_dof = trial_fe.
GetDof();
2417 int test_dof = test_fe.
GetDof();
2420 #ifdef MFEM_THREAD_SAFE
2423 Vector D(DQ ? DQ->GetVDim() : 0);
2424 DenseMatrix K(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
2426 trial_vshape.
SetSize(trial_dof,trial_vdim);
2427 test_vshape.
SetSize(test_dof,test_vdim);
2428 D.SetSize(DQ ? DQ->GetVDim() : 0);
2429 K.SetSize(MQ ? MQ->GetVDim() : 0, MQ ? MQ->GetVDim() : 0);
2433 elmat.
SetSize (test_dof, trial_dof);
2455 MQ->Eval(K, Trans, ip);
2457 Mult(test_vshape,K,tmp);
2462 DQ->Eval(D, Trans, ip);
2470 w *= Q -> Eval (Trans, ip);
2478 mfem_error(
"VectorFEMassIntegrator::AssembleElementMatrix2(...)\n"
2479 " is not implemented for given trial and test bases.");
2483 void VectorDivergenceIntegrator::AssembleElementMatrix2(
2490 int trial_dof = trial_fe.
GetDof();
2491 int test_dof = test_fe.
GetDof();
2494 dshape.SetSize (trial_dof,
dim);
2495 gshape.SetSize (trial_dof,
dim);
2497 divshape.SetSize (
dim*trial_dof);
2498 shape.SetSize (test_dof);
2502 const IntegrationRule *ir = IntRule ? IntRule : &GetRule(trial_fe, test_fe,
2507 for (
int i = 0; i < ir -> GetNPoints(); i++)
2517 Mult (dshape, Jadj, gshape);
2519 gshape.GradToDiv (divshape);
2524 c *= Q -> Eval (Trans, ip);
2543 void DivDivIntegrator::AssembleElementMatrix(
2551 #ifdef MFEM_THREAD_SAFE
2567 for (
int i = 0; i < ir -> GetNPoints(); i++)
2578 c *= Q -> Eval (Trans, ip);
2587 void VectorDiffusionIntegrator::AssembleElementMatrix(
2592 const int dof = el.
GetDof();
2597 vdim = (vdim <= 0) ? sdim : vdim;
2598 const bool square = (
dim == sdim);
2602 vcoeff.SetSize(vdim);
2606 mcoeff.SetSize(vdim);
2609 dshape.SetSize(dof,
dim);
2610 dshapedxt.SetSize(dof, sdim);
2613 pelmat.SetSize(dof);
2618 ir = &DiffusionIntegrator::GetRule(el,el);
2623 for (
int i = 0; i < ir -> GetNPoints(); i++)
2630 double w = Trans.
Weight();
2631 w = ip.
weight / (square ? w : w*w*w);
2638 VQ->Eval(vcoeff, Trans, ip);
2639 for (
int k = 0; k < vdim; ++k)
2647 MQ->Eval(mcoeff, Trans, ip);
2648 for (
int ii = 0; ii < vdim; ++ii)
2650 for (
int jj = 0; jj < vdim; ++jj)
2652 Mult_a_AAt(w*mcoeff(ii,jj), dshapedxt, pelmat);
2653 elmat.
AddMatrix(pelmat, dof*ii, dof*jj);
2659 if (Q) { w *= Q->Eval(Trans, ip); }
2661 for (
int k = 0; k < vdim; ++k)
2669 void VectorDiffusionIntegrator::AssembleElementVector(
2673 const int dof = el.
GetDof();
2678 vdim = (vdim <= 0) ? sdim : vdim;
2679 const bool square = (
dim == sdim);
2683 vcoeff.SetSize(vdim);
2687 mcoeff.SetSize(vdim);
2690 dshape.SetSize(dof,
dim);
2691 dshapedxt.SetSize(dof,
dim);
2705 ir = &DiffusionIntegrator::GetRule(el,el);
2709 for (
int i = 0; i < ir->GetNPoints(); i++)
2716 w = ip.
weight / (square ? w : w*w*w);
2722 VQ->Eval(vcoeff, Tr, ip);
2723 for (
int k = 0; k < vdim; ++k)
2725 pelmat *= w*vcoeff(k);
2726 const Vector vec_in(mat_in.GetColumn(k), dof);
2727 Vector vec_out(mat_out.GetColumn(k), dof);
2728 pelmat.AddMult(vec_in, vec_out);
2733 MQ->Eval(mcoeff, Tr, ip);
2734 for (
int ii = 0; ii < vdim; ++ii)
2736 Vector vec_out(mat_out.GetColumn(ii), dof);
2737 for (
int jj = 0; jj < vdim; ++jj)
2739 pelmat *= w*mcoeff(ii,jj);
2740 const Vector vec_in(mat_in.GetColumn(jj), dof);
2741 pelmat.Mult(vec_in, vec_out);
2747 if (Q) { w *= Q->Eval(Tr, ip); }
2749 for (
int k = 0; k < vdim; ++k)
2751 const Vector vec_in(mat_in.GetColumn(k), dof);
2752 Vector vec_out(mat_out.GetColumn(k), dof);
2753 pelmat.AddMult(vec_in, vec_out);
2760 void ElasticityIntegrator::AssembleElementMatrix(
2769 #ifdef MFEM_THREAD_SAFE
2770 DenseMatrix dshape(dof, dim), gshape(dof, dim), pelmat(dof);
2771 Vector divshape(dim*dof);
2773 dshape.SetSize(dof, dim);
2774 gshape.SetSize(dof, dim);
2775 pelmat.SetSize(dof);
2790 for (
int i = 0; i < ir -> GetNPoints(); i++)
2800 gshape.GradToDiv (divshape);
2802 M =
mu->Eval(Trans, ip);
2805 L = lambda->Eval(Trans, ip);
2820 for (
int d = 0; d <
dim; d++)
2822 for (
int k = 0; k < dof; k++)
2823 for (
int l = 0; l < dof; l++)
2825 elmat (dof*d+k, dof*d+l) += (M * w) * pelmat(k, l);
2828 for (
int ii = 0; ii <
dim; ii++)
2829 for (
int jj = 0; jj <
dim; jj++)
2831 for (
int kk = 0; kk < dof; kk++)
2832 for (
int ll = 0; ll < dof; ll++)
2834 elmat(dof*ii+kk, dof*jj+ll) +=
2835 (M * w) * gshape(kk, jj) * gshape(ll, ii);
2842 void ElasticityIntegrator::ComputeElementFlux(
2847 const int dof = el.
GetDof();
2849 const int tdim = dim*(dim+1)/2;
2852 MFEM_ASSERT(dim == 2 || dim == 3,
2853 "dimension is not supported: dim = " << dim);
2855 MFEM_ASSERT(fluxelem.
GetMapType() == FiniteElement::VALUE,
"");
2856 MFEM_ASSERT(dynamic_cast<const NodalFiniteElement*>(&fluxelem),
"");
2858 #ifdef MFEM_THREAD_SAFE
2864 double gh_data[9], grad_data[9];
2873 for (
int i = 0; i < fnd; i++)
2877 MultAtB(loc_data_mat, dshape, gh);
2882 M =
mu->Eval(Trans, ip);
2885 L = lambda->Eval(Trans, ip);
2895 const double M2 = 2.0*M;
2898 L *= (grad(0,0) + grad(1,1));
2900 flux(i+fnd*0) = M2*grad(0,0) + L;
2901 flux(i+fnd*1) = M2*grad(1,1) + L;
2902 flux(i+fnd*2) = M*(grad(0,1) + grad(1,0));
2906 L *= (grad(0,0) + grad(1,1) + grad(2,2));
2908 flux(i+fnd*0) = M2*grad(0,0) + L;
2909 flux(i+fnd*1) = M2*grad(1,1) + L;
2910 flux(i+fnd*2) = M2*grad(2,2) + L;
2911 flux(i+fnd*3) = M*(grad(0,1) + grad(1,0));
2912 flux(i+fnd*4) = M*(grad(0,2) + grad(2,0));
2913 flux(i+fnd*5) = M*(grad(1,2) + grad(2,1));
2922 const int dof = fluxelem.
GetDof();
2924 const int tdim = dim*(dim+1)/2;
2929 MFEM_ASSERT(d_energy == NULL,
"anisotropic estimates are not supported");
2930 MFEM_ASSERT(flux.
Size() == dof*tdim,
"invalid 'flux' vector");
2932 #ifndef MFEM_THREAD_SAFE
2937 double pointstress_data[6];
2938 Vector pointstress(pointstress_data, tdim);
2949 int order = 2 * Trans.
OrderGrad(&fluxelem);
2953 double energy = 0.0;
2955 for (
int i = 0; i < ir->GetNPoints(); i++)
2960 flux_mat.MultTranspose(shape, pointstress);
2965 M =
mu->Eval(Trans, ip);
2968 L = lambda->Eval(Trans, ip);
2988 const double *
s = pointstress_data;
2992 const double tr_e = (s[0] + s[1])/(2*(M + L));
2994 pt_e = (0.25/M)*(s[0]*(s[0] - L) + s[1]*(s[1] - L) + 2*s[2]*s[2]);
2999 const double tr_e = (s[0] + s[1] + s[2])/(2*M + 3*L);
3001 pt_e = (0.25/M)*(s[0]*(s[0] - L) + s[1]*(s[1] - L) + s[2]*(s[2] - L) +
3002 2*(s[3]*s[3] + s[4]*s[4] + s[5]*s[5]));
3033 shape1.SetSize(ndof1);
3034 shape2.SetSize(ndof2);
3050 if (el1.
Space() == FunctionSpace::Pk)
3071 u->Eval(vu, *Trans.
Elem1, eip1);
3075 nor(0) = 2*eip1.
x - 1.0;
3083 a = 0.5 *
alpha * un;
3084 b = beta * fabs(un);
3092 if (un >= 0.0 && ndof2)
3094 rho_p = rho->Eval(*Trans.
Elem2, eip2);
3098 rho_p = rho->Eval(*Trans.
Elem1, eip1);
3107 for (
int i = 0; i < ndof1; i++)
3108 for (
int j = 0; j < ndof1; j++)
3110 elmat(i, j) += w * shape1(i) * shape1(j);
3119 for (
int i = 0; i < ndof2; i++)
3120 for (
int j = 0; j < ndof1; j++)
3122 elmat(ndof1+i, j) -= w * shape2(i) * shape1(j);
3128 for (
int i = 0; i < ndof2; i++)
3129 for (
int j = 0; j < ndof2; j++)
3131 elmat(ndof1+i, ndof1+j) += w * shape2(i) * shape2(j);
3134 for (
int i = 0; i < ndof1; i++)
3135 for (
int j = 0; j < ndof2; j++)
3137 elmat(i, ndof1+j) -= w * shape1(i) * shape2(j);
3152 void DGDiffusionIntegrator::AssembleFaceMatrix(
3156 int dim, ndof1, ndof2, ndofs;
3157 bool kappa_is_nonzero = (
kappa != 0.);
3172 shape1.SetSize(ndof1);
3173 dshape1.SetSize(ndof1, dim);
3174 dshape1dn.SetSize(ndof1);
3178 shape2.SetSize(ndof2);
3179 dshape2.SetSize(ndof2, dim);
3180 dshape2dn.SetSize(ndof2);
3187 ndofs = ndof1 + ndof2;
3190 if (kappa_is_nonzero)
3228 nor(0) = 2*eip1.
x - 1.0;
3246 w *= Q->Eval(*Trans.
Elem1, eip1);
3253 MQ->Eval(mq, *Trans.
Elem1, eip1);
3254 mq.MultTranspose(nh, ni);
3258 if (kappa_is_nonzero)
3273 dshape1.Mult(nh, dshape1dn);
3274 for (
int i = 0; i < ndof1; i++)
3275 for (
int j = 0; j < ndof1; j++)
3277 elmat(i, j) += shape1(i) * dshape1dn(j);
3289 w *= Q->Eval(*Trans.
Elem2, eip2);
3296 MQ->Eval(mq, *Trans.
Elem2, eip2);
3297 mq.MultTranspose(nh, ni);
3301 if (kappa_is_nonzero)
3306 dshape2.Mult(nh, dshape2dn);
3308 for (
int i = 0; i < ndof1; i++)
3309 for (
int j = 0; j < ndof2; j++)
3311 elmat(i, ndof1 + j) += shape1(i) * dshape2dn(j);
3314 for (
int i = 0; i < ndof2; i++)
3315 for (
int j = 0; j < ndof1; j++)
3317 elmat(ndof1 + i, j) -= shape2(i) * dshape1dn(j);
3320 for (
int i = 0; i < ndof2; i++)
3321 for (
int j = 0; j < ndof2; j++)
3323 elmat(ndof1 + i, ndof1 + j) -= shape2(i) * dshape2dn(j);
3327 if (kappa_is_nonzero)
3331 for (
int i = 0; i < ndof1; i++)
3333 const double wsi = wq*shape1(i);
3334 for (
int j = 0; j <= i; j++)
3336 jmat(i, j) += wsi * shape1(j);
3341 for (
int i = 0; i < ndof2; i++)
3343 const int i2 = ndof1 + i;
3344 const double wsi = wq*shape2(i);
3345 for (
int j = 0; j < ndof1; j++)
3347 jmat(i2, j) -= wsi * shape1(j);
3349 for (
int j = 0; j <= i; j++)
3351 jmat(i2, ndof1 + j) += wsi * shape2(j);
3359 if (kappa_is_nonzero)
3361 for (
int i = 0; i < ndofs; i++)
3363 for (
int j = 0; j < i; j++)
3365 double aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
3366 elmat(i,j) =
sigma*aji - aij + mij;
3367 elmat(j,i) =
sigma*aij - aji + mij;
3369 elmat(i,i) = (
sigma - 1.)*elmat(i,i) + jmat(i,i);
3374 for (
int i = 0; i < ndofs; i++)
3376 for (
int j = 0; j < i; j++)
3378 double aij = elmat(i,j), aji = elmat(j,i);
3379 elmat(i,j) =
sigma*aji - aij;
3380 elmat(j,i) =
sigma*aij - aji;
3382 elmat(i,i) *= (
sigma - 1.);
3389 void DGElasticityIntegrator::AssembleBlock(
3390 const int dim,
const int row_ndofs,
const int col_ndofs,
3391 const int row_offset,
const int col_offset,
3392 const double jmatcoef,
const Vector &col_nL,
const Vector &col_nM,
3397 for (
int jm = 0, j = col_offset; jm <
dim; ++jm)
3399 for (
int jdof = 0; jdof < col_ndofs; ++jdof, ++j)
3401 const double t2 = col_dshape_dnM(jdof);
3402 for (
int im = 0, i = row_offset; im <
dim; ++im)
3404 const double t1 = col_dshape(jdof, jm) * col_nL(im);
3405 const double t3 = col_dshape(jdof, im) * col_nM(jm);
3406 const double tt = t1 + ((im == jm) ? t2 : 0.0) + t3;
3407 for (
int idof = 0; idof < row_ndofs; ++idof, ++i)
3409 elmat(i, j) += row_shape(idof) * tt;
3415 if (jmatcoef == 0.0) {
return; }
3417 for (
int d = 0; d <
dim; ++d)
3419 const int jo = col_offset + d*col_ndofs;
3420 const int io = row_offset + d*row_ndofs;
3421 for (
int jdof = 0, j = jo; jdof < col_ndofs; ++jdof, ++j)
3423 const double sj = jmatcoef * col_shape(jdof);
3424 for (
int i = max(io,j), idof = i - io; idof < row_ndofs; ++idof, ++i)
3426 jmat(i, j) += row_shape(idof) * sj;
3432 void DGElasticityIntegrator::AssembleFaceMatrix(
3436 #ifdef MFEM_THREAD_SAFE
3445 Vector dshape1_dnM, dshape2_dnM;
3450 const int ndofs1 = el1.
GetDof();
3452 const int nvdofs = dim*(ndofs1 + ndofs2);
3462 const bool kappa_is_nonzero = (
kappa != 0.0);
3463 if (kappa_is_nonzero)
3472 dshape1_ps.
SetSize(ndofs1, dim);
3482 dshape2_ps.
SetSize(ndofs2, dim);
3496 for (
int pind = 0; pind < ir->
GetNPoints(); ++pind)
3512 Mult(dshape1, adjJ, dshape1_ps);
3516 nor(0) = 2*eip1.
x - 1.0;
3529 Mult(dshape2, adjJ, dshape2_ps);
3533 const double wL2 = w2 * lambda->Eval(*Trans.
Elem2, eip2);
3534 const double wM2 = w2 *
mu->Eval(*Trans.
Elem2, eip2);
3537 wLM = (wL2 + 2.0*wM2);
3538 dshape2_ps.
Mult(nM2, dshape2_dnM);
3548 const double wL1 = w1 * lambda->Eval(*Trans.
Elem1, eip1);
3549 const double wM1 = w1 *
mu->Eval(*Trans.
Elem1, eip1);
3552 wLM += (wL1 + 2.0*wM1);
3553 dshape1_ps.
Mult(nM1, dshape1_dnM);
3556 const double jmatcoef =
kappa * (nor*nor) * wLM;
3560 dim, ndofs1, ndofs1, 0, 0, jmatcoef, nL1, nM1,
3561 shape1, shape1, dshape1_dnM, dshape1_ps, elmat, jmat);
3563 if (ndofs2 == 0) {
continue; }
3570 dim, ndofs1, ndofs2, 0, dim*ndofs1, jmatcoef, nL2, nM2,
3571 shape1, shape2, dshape2_dnM, dshape2_ps, elmat, jmat);
3574 dim, ndofs2, ndofs1, dim*ndofs1, 0, jmatcoef, nL1, nM1,
3575 shape2, shape1, dshape1_dnM, dshape1_ps, elmat, jmat);
3578 dim, ndofs2, ndofs2, dim*ndofs1, dim*ndofs1, jmatcoef, nL2, nM2,
3579 shape2, shape2, dshape2_dnM, dshape2_ps, elmat, jmat);
3583 if (kappa_is_nonzero)
3585 for (
int i = 0; i < nvdofs; ++i)
3587 for (
int j = 0; j < i; ++j)
3589 double aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
3590 elmat(i,j) =
alpha*aji - aij + mij;
3591 elmat(j,i) =
alpha*aij - aji + mij;
3593 elmat(i,i) = (
alpha - 1.)*elmat(i,i) + jmat(i,i);
3598 for (
int i = 0; i < nvdofs; ++i)
3600 for (
int j = 0; j < i; ++j)
3602 double aij = elmat(i,j), aji = elmat(j,i);
3603 elmat(i,j) =
alpha*aji - aij;
3604 elmat(j,i) =
alpha*aij - aji;
3606 elmat(i,i) *= (
alpha - 1.);
3612 void TraceJumpIntegrator::AssembleFaceMatrix(
3617 int i, j, face_ndof, ndof1, ndof2;
3622 face_ndof = trial_face_fe.
GetDof();
3623 ndof1 = test_fe1.
GetDof();
3625 face_shape.SetSize(face_ndof);
3626 shape1.SetSize(ndof1);
3630 ndof2 = test_fe2.
GetDof();
3631 shape2.SetSize(ndof2);
3638 elmat.
SetSize(ndof1 + ndof2, face_ndof);
3653 if (trial_face_fe.
GetMapType() == FiniteElement::VALUE)
3673 trial_face_fe.
CalcShape(ip, face_shape);
3682 if (trial_face_fe.
GetMapType() == FiniteElement::VALUE)
3687 for (i = 0; i < ndof1; i++)
3688 for (j = 0; j < face_ndof; j++)
3690 elmat(i, j) += shape1(i) * face_shape(j);
3695 for (i = 0; i < ndof2; i++)
3696 for (j = 0; j < face_ndof; j++)
3698 elmat(ndof1+i, j) -= shape2(i) * face_shape(j);
3704 void NormalTraceJumpIntegrator::AssembleFaceMatrix(
3709 int i, j, face_ndof, ndof1, ndof2,
dim;
3712 MFEM_VERIFY(trial_face_fe.
GetMapType() == FiniteElement::VALUE,
"");
3714 face_ndof = trial_face_fe.
GetDof();
3715 ndof1 = test_fe1.
GetDof();
3718 face_shape.SetSize(face_ndof);
3719 normal.SetSize(dim);
3720 shape1.SetSize(ndof1,dim);
3721 shape1_n.SetSize(ndof1);
3725 ndof2 = test_fe2.
GetDof();
3726 shape2.SetSize(ndof2,dim);
3727 shape2_n.SetSize(ndof2);
3734 elmat.
SetSize(ndof1 + ndof2, face_ndof);
3757 trial_face_fe.
CalcShape(ip, face_shape);
3763 shape1.Mult(normal, shape1_n);
3771 shape2.Mult(normal, shape2_n);
3774 for (i = 0; i < ndof1; i++)
3775 for (j = 0; j < face_ndof; j++)
3777 elmat(i, j) -= shape1_n(i) * face_shape(j);
3782 for (i = 0; i < ndof2; i++)
3783 for (j = 0; j < face_ndof; j++)
3785 elmat(ndof1+i, j) += shape2_n(i) * face_shape(j);
3792 void NormalInterpolator::AssembleElementMatrix2(
3801 for (
int i = 0; i < ran_nodes.Size(); i++)
3807 for (
int j = 0; j < shape.Size(); j++)
3809 for (
int d = 0; d < spaceDim; d++)
3811 elmat(i, j+d*shape.Size()) = shape(j)*n(d);
3831 using VectorCoefficient::Eval;
3832 virtual void Eval(Vector &V, ElementTransformation &T,
3833 const IntegrationPoint &ip)
3836 fe.CalcPhysShape(T, V);
3849 internal::ShapeCoefficient dom_shape_coeff(*Q, dom_fe);
3855 ran_fe.
Project(dom_shape_coeff, Trans, elmat_as_vec);
3860 ScalarVectorProductInterpolator::AssembleElementMatrix2(
3879 fe.CalcPhysVShape(T, M);
3884 VShapeCoefficient dom_shape_coeff(*Q, dom_fe, Trans.
GetSpaceDim());
3895 VectorScalarProductInterpolator::AssembleElementMatrix2(
3910 vc(width), shape(height) { }
3917 fe.CalcPhysShape(T, shape);
3922 VecShapeCoefficient dom_shape_coeff(*VQ, dom_fe);
3933 ScalarCrossProductInterpolator::AssembleElementMatrix2(
3951 using VectorCoefficient::Eval;
3957 fe.CalcPhysVShape(T, vshape);
3958 for (
int k = 0; k < vdim; k++)
3960 V(k) = vc(0) * vshape(k,1) - vc(1) * vshape(k,0);
3965 VCrossVShapeCoefficient dom_shape_coeff(*VQ, dom_fe);
3971 ran_fe.
Project(dom_shape_coeff, Trans, elmat_as_vec);
3975 VectorCrossProductInterpolator::AssembleElementMatrix2(
3991 vshape(height, width), vc(width)
3993 MFEM_ASSERT(width == 3,
"");
4001 fe.CalcPhysVShape(T, vshape);
4002 for (
int k = 0; k < height; k++)
4004 M(k,0) = vc(1) * vshape(k,2) - vc(2) * vshape(k,1);
4005 M(k,1) = vc(2) * vshape(k,0) - vc(0) * vshape(k,2);
4006 M(k,2) = vc(0) * vshape(k,1) - vc(1) * vshape(k,0);
4011 VCrossVShapeCoefficient dom_shape_coeff(*VQ, dom_fe);
4042 vshape(vdim, vq.GetVDim()), vc(vq.GetVDim()) { }
4044 using VectorCoefficient::Eval;
4045 virtual void Eval(Vector &V, ElementTransformation &T,
4046 const IntegrationPoint &ip)
4050 fe.CalcPhysVShape(T, vshape);
4058 VectorInnerProductInterpolator::AssembleElementMatrix2(
4064 internal::VDotVShapeCoefficient dom_shape_coeff(*VQ, dom_fe);
4070 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)
int GetCurlDim() const
Returns the dimension of the curl for vector-valued finite elements.
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 CalcPhysCurlShape(ElementTransformation &Trans, DenseMatrix &curl_shape) const
Evaluate the curl of all shape functions of a vector finite element in physical space at the point de...
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)
FDualNumber< tbase > pow(const FDualNumber< tbase > &a, const FDualNumber< tbase > &b)
pow([dual number],[dual number])
int GetVDim() const
Returns the vector dimension for vector-valued finite elements.
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)