21 MFEM_ABORT(
"the assembly level has already been set!");
33 mfem_error(
"Unknown assembly level for this form.");
74 MFEM_ABORT(
"internal MFEM error");
91 for (
int i = 0; i <
fes->
GetNE(); i++)
97 for (
int k = 0; k <
dnfi.Size(); k++)
99 energy +=
dnfi[k]->GetElementEnergy(*fe, *T, el_x);
106 MFEM_ABORT(
"TODO: add energy contribution from interior face terms");
111 MFEM_ABORT(
"TODO: add energy contribution from boundary face terms");
119 MFEM_VERIFY(x.
Size() ==
Width(),
"invalid input Vector size");
154 for (
int i = 0; i <
fes->
GetNE(); i++)
160 for (
int k = 0; k <
dnfi.Size(); k++)
162 dnfi[k]->AssembleElementVector(*fe, *T, el_x, el_y);
188 for (
int k = 0; k <
fnfi.Size(); k++)
190 fnfi[k]->AssembleFaceVector(*fe1, *fe2, *tr, el_x, el_y);
206 for (
int k = 0; k <
bfnfi.Size(); k++)
214 MFEM_ASSERT(bdr_marker.
Size() == bdr_attr_marker.
Size(),
215 "invalid boundary marker for boundary face integrator #"
216 << k <<
", counting from zero");
217 for (
int i = 0; i < bdr_attr_marker.
Size(); i++)
219 bdr_attr_marker[i] |= bdr_marker[i];
223 for (
int i = 0; i <
fes -> GetNBE(); i++)
226 if (bdr_attr_marker[bdr_attr-1] == 0) {
continue; }
239 for (
int k = 0; k <
bfnfi.Size(); k++)
244 bfnfi[k]->AssembleFaceVector(*fe1, *fe2, *tr, el_x, el_y);
267 MFEM_ABORT(
"Not yet implemented!");
270 const int skip_zeros = 0;
290 for (
int i = 0; i <
fes->
GetNE(); i++)
296 for (
int k = 0; k <
dnfi.Size(); k++)
298 dnfi[k]->AssembleElementGrad(*fe, *T, el_x, elmat);
325 for (
int k = 0; k <
fnfi.Size(); k++)
327 fnfi[k]->AssembleFaceGrad(*fe1, *fe2, *tr, el_x, elmat);
343 for (
int k = 0; k <
bfnfi.Size(); k++)
351 MFEM_ASSERT(bdr_marker.
Size() == bdr_attr_marker.
Size(),
352 "invalid boundary marker for boundary face integrator #"
353 << k <<
", counting from zero");
354 for (
int i = 0; i < bdr_attr_marker.
Size(); i++)
356 bdr_attr_marker[i] |= bdr_marker[i];
360 for (
int i = 0; i <
fes -> GetNBE(); i++)
363 if (bdr_attr_marker[bdr_attr-1] == 0) {
continue; }
376 for (
int k = 0; k <
bfnfi.Size(); k++)
381 bfnfi[k]->AssembleFaceGrad(*fe1, *fe2, *tr, el_x, elmat);
413 if (
ext) { MFEM_ABORT(
"Not yet implemented!"); }
436 for (
int i = 0; i <
dnfi.Size(); i++) {
delete dnfi[i]; }
437 for (
int i = 0; i <
fnfi.Size(); i++) {
delete fnfi[i]; }
438 for (
int i = 0; i <
bfnfi.Size(); i++) {
delete bfnfi[i]; }
444 fes(0), BlockGrad(NULL)
454 for (
int i=0; i<
Grads.NumRows(); ++i)
456 for (
int j=0; j<
Grads.NumCols(); ++j)
462 for (
int i = 0; i <
ess_tdofs.Size(); ++i)
475 for (
int i=0; i<
fes.
Size(); ++i)
496 for (
int s = 0; s <
fes.
Size(); ++s)
499 P[s] =
fes[s]->GetProlongationMatrix();
521 fes(0), BlockGrad(NULL)
536 for (
int s = 0; s <
fes.
Size(); ++s)
540 fes[s]->GetEssentialTrueDofs(*bdr_attr_is_ess[s], *
ess_tdofs[s]);
544 rhs[s]->SetSubVector(*
ess_tdofs[s], 0.0);
558 for (
int i=0; i<
fes.
Size(); ++i)
560 el_x_const[i] = el_x[i] =
new Vector();
565 for (
int i = 0; i <
fes[0]->GetNE(); ++i)
567 T =
fes[0]->GetElementTransformation(i);
568 for (
int s=0; s<
fes.
Size(); ++s)
570 fe[s] =
fes[s]->GetFE(i);
571 fes[s]->GetElementVDofs(i, *vdofs[s]);
575 for (
int k = 0; k <
dnfi.Size(); ++k)
577 energy +=
dnfi[k]->GetElementEnergy(fe, *T, el_x_const);
582 for (
int i = 0; i <
fes.
Size(); ++i)
590 MFEM_ABORT(
"TODO: add energy contribution from interior face terms");
595 MFEM_ABORT(
"TODO: add energy contribution from boundary face terms");
620 for (
int s=0; s<
fes.
Size(); ++s)
622 el_x_const[s] = el_x[s] =
new Vector();
630 for (
int i = 0; i <
fes[0]->GetNE(); ++i)
632 T =
fes[0]->GetElementTransformation(i);
633 for (
int s = 0; s <
fes.
Size(); ++s)
635 fes[s]->GetElementVDofs(i, *(vdofs[s]));
636 fe[s] =
fes[s]->GetFE(i);
640 for (
int k = 0; k <
dnfi.Size(); ++k)
642 dnfi[k]->AssembleElementVector(fe, *T,
645 for (
int s=0; s<
fes.
Size(); ++s)
647 if (el_y[s]->Size() == 0) {
continue; }
656 Mesh *mesh =
fes[0]->GetMesh();
664 for (
int s=0; s<
fes.
Size(); ++s)
669 fes[s]->GetElementVDofs(tr->
Elem1No, *(vdofs[s]));
670 fes[s]->GetElementVDofs(tr->
Elem2No, *(vdofs2[s]));
672 vdofs[s]->
Append(*(vdofs2[s]));
677 for (
int k = 0; k <
fnfi.Size(); ++k)
680 fnfi[k]->AssembleFaceVector(fe, fe2, *tr, el_x_const, el_y);
682 for (
int s=0; s<
fes.
Size(); ++s)
684 if (el_y[s]->Size() == 0) {
continue; }
694 Mesh *mesh =
fes[0]->GetMesh();
700 for (
int k = 0; k <
bfnfi.Size(); ++k)
708 MFEM_ASSERT(bdr_marker.
Size() == bdr_attr_marker.
Size(),
709 "invalid boundary marker for boundary face integrator #"
710 << k <<
", counting from zero");
711 for (
int i = 0; i < bdr_attr_marker.
Size(); ++i)
713 bdr_attr_marker[i] |= bdr_marker[i];
717 for (
int i = 0; i < mesh->
GetNBE(); ++i)
720 if (bdr_attr_marker[bdr_attr-1] == 0) {
continue; }
725 for (
int s=0; s<
fes.
Size(); ++s)
730 fes[s]->GetElementVDofs(tr->
Elem1No, *(vdofs[s]));
734 for (
int k = 0; k <
bfnfi.Size(); ++k)
739 bfnfi[k]->AssembleFaceVector(fe, fe2, *tr, el_x_const, el_y);
741 for (
int s=0; s<
fes.
Size(); ++s)
743 if (el_y[s]->Size() == 0) {
continue; }
751 for (
int s=0; s<
fes.
Size(); ++s)
762 MFEM_VERIFY(bx.
Size() ==
Width(),
"invalid input BlockVector size");
767 for (
int s = 0; s <
fes.
Size(); s++)
792 for (
int s = 0; s <
fes.
Size(); s++)
796 cP[s]->MultTranspose(pby.
GetBlock(s), by.GetBlock(s));
798 by.GetBlock(s).SetSubVector(*
ess_tdofs[s], 0.0);
804 const int skip_zeros = 0;
814 for (
int i=0; i<
fes.
Size(); ++i)
816 el_x_const[i] = el_x[i] =
new Vector();
819 for (
int j=0; j<
fes.
Size(); ++j)
825 for (
int i=0; i<
fes.
Size(); ++i)
827 for (
int j=0; j<
fes.
Size(); ++j)
829 if (
Grads(i,j) != NULL)
843 for (
int i = 0; i <
fes[0]->GetNE(); ++i)
845 T =
fes[0]->GetElementTransformation(i);
846 for (
int s = 0; s <
fes.
Size(); ++s)
848 fe[s] =
fes[s]->GetFE(i);
849 fes[s]->GetElementVDofs(i, *vdofs[s]);
853 for (
int k = 0; k <
dnfi.Size(); ++k)
855 dnfi[k]->AssembleElementGrad(fe, *T, el_x_const, elmats);
857 for (
int j=0; j<
fes.
Size(); ++j)
859 for (
int l=0; l<
fes.
Size(); ++l)
861 if (elmats(j,l)->Height() == 0) {
continue; }
862 Grads(j,l)->AddSubMatrix(*vdofs[j], *vdofs[l],
863 *elmats(j,l), skip_zeros);
873 Mesh *mesh =
fes[0]->GetMesh();
879 for (
int s=0; s <
fes.
Size(); ++s)
884 fes[s]->GetElementVDofs(tr->
Elem1No, *vdofs[s]);
885 fes[s]->GetElementVDofs(tr->
Elem2No, *vdofs2[s]);
886 vdofs[s]->
Append(*(vdofs2[s]));
891 for (
int k = 0; k <
fnfi.Size(); ++k)
893 fnfi[k]->AssembleFaceGrad(fe, fe2, *tr, el_x_const, elmats);
894 for (
int j=0; j<
fes.
Size(); ++j)
896 for (
int l=0; l<
fes.
Size(); ++l)
898 if (elmats(j,l)->Height() == 0) {
continue; }
899 Grads(j,l)->AddSubMatrix(*vdofs[j], *vdofs[l],
900 *elmats(j,l), skip_zeros);
910 Mesh *mesh =
fes[0]->GetMesh();
916 for (
int k = 0; k <
bfnfi.Size(); ++k)
924 MFEM_ASSERT(bdr_marker.
Size() == bdr_attr_marker.
Size(),
925 "invalid boundary marker for boundary face integrator #"
926 << k <<
", counting from zero");
927 for (
int i = 0; i < bdr_attr_marker.
Size(); ++i)
929 bdr_attr_marker[i] |= bdr_marker[i];
933 for (
int i = 0; i < mesh->
GetNBE(); ++i)
936 if (bdr_attr_marker[bdr_attr-1] == 0) {
continue; }
941 for (
int s = 0; s <
fes.
Size(); ++s)
946 fes[s]->GetElementVDofs(i, *vdofs[s]);
950 for (
int k = 0; k <
bfnfi.Size(); ++k)
952 bfnfi[k]->AssembleFaceGrad(fe, fe2, *tr, el_x_const, elmats);
953 for (
int l=0; l<
fes.
Size(); ++l)
955 for (
int j=0; j<
fes.
Size(); ++j)
957 if (elmats(j,l)->Height() == 0) {
continue; }
958 Grads(j,l)->AddSubMatrix(*vdofs[j], *vdofs[l],
959 *elmats(j,l), skip_zeros);
967 if (!
Grads(0,0)->Finalized())
969 for (
int i=0; i<
fes.
Size(); ++i)
971 for (
int j=0; j<
fes.
Size(); ++j)
973 Grads(i,j)->Finalize(skip_zeros);
978 for (
int i=0; i<
fes.
Size(); ++i)
980 for (
int j=0; j<
fes.
Size(); ++j)
1001 for (
int s1 = 0; s1 <
fes.
Size(); ++s1)
1003 for (
int s2 = 0; s2 <
fes.
Size(); ++s2)
1007 mGrads(s1, s2) =
cGrads(s1, s2);
1012 for (
int s = 0; s <
fes.
Size(); ++s)
1014 for (
int i = 0; i <
ess_tdofs[s]->Size(); ++i)
1016 for (
int j = 0; j <
fes.
Size(); ++j)
1020 mGrads(s, s)->EliminateRowCol((*
ess_tdofs[s])[i],
1025 mGrads(s, j)->EliminateRow((*
ess_tdofs[s])[i]);
1026 mGrads(j, s)->EliminateCol((*
ess_tdofs[s])[i]);
1034 for (
int i = 0; i <
fes.
Size(); ++i)
1036 for (
int j = 0; j <
fes.
Size(); ++j)
1047 for (
int i=0; i<
fes.
Size(); ++i)
1049 for (
int j=0; j<
fes.
Size(); ++j)
1057 for (
int i = 0; i <
dnfi.Size(); ++i)
1062 for (
int i = 0; i <
fnfi.Size(); ++i)
1067 for (
int i = 0; i <
bfnfi.Size(); ++i)
Abstract class for all finite elements.
int Size() const
Return the logical size of the array.
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
AssemblyLevel
Enumeration defining the assembly level for bilinear and nonlinear form classes derived from Operator...
int GetBdrAttribute(int i) const
Return the attribute of boundary element i.
A class to handle Vectors in a block fashion.
HypreParMatrix * RAP(const HypreParMatrix *A, const HypreParMatrix *P)
Returns the matrix P^t * A * P.
virtual void Finalize(int skip_zeros=1)
Finalize the matrix initialization, switching the storage format from LIL to CSR. ...
void SetSize(int s)
Resize the vector to size s.
int GetNBE() const
Returns number of boundary elements.
void GetElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
void Copy(Array ©) const
Create a copy of the internal array to the provided copy.
void GetSubVector(const Array< int > &dofs, Vector &elemvect) const
Extract entries listed in dofs to the output Vector elemvect.
Data type dense matrix using column-major storage.
int Size() const
Returns the size of the vector.
void Update(double *data, const Array< int > &bOffsets)
Update method.
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1)
Get a list of essential true dofs, ess_tdof_list, corresponding to the boundary attributes marked in ...
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
Abstract parallel finite element space.
FaceElementTransformations * GetInteriorFaceTransformations(int FaceNo)
double * GetData() const
Return a pointer to the beginning of the Vector data.
static void MarkerToList(const Array< int > &marker, Array< int > &list)
Convert a Boolean marker array to a list containing all marked indices.
void BooleanMultTranspose(int alpha, const int *x, int beta, int *y)
virtual int GetTrueVSize() const
Return the number of local vector true dofs.
int GetNumFaces() const
Return the number of faces (3D), edges (2D) or vertices (1D).
int GetNE() const
Returns number of elements in the mesh.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
int Append(const T &el)
Append element 'el' to array, resize if necessary.
Mesh * GetMesh() const
Returns the mesh.
void mfem_error(const char *msg)
Function called when an error is encountered. Used by the macros MFEM_ABORT, MFEM_ASSERT, MFEM_VERIFY.
HypreParMatrix * Dof_TrueDof_Matrix() const
The true dof-to-dof interpolation matrix.
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
virtual const Operator * GetProlongationMatrix() const
The returned Operator is owned by the FiniteElementSpace.
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
Set the diagonal value to one.
FaceElementTransformations * GetBdrFaceTransformations(int BdrElemNo)
void AddElementVector(const Array< int > &dofs, const Vector &elemvect)
Add elements of the elemvect Vector to the entries listed in dofs. Negative dof values cause the -dof...
void AddSubMatrix(const Array< int > &rows, const Array< int > &cols, const DenseMatrix &subm, int skip_zeros=1)
Dynamic 2D array using row-major layout.
bool Finalized() const
Returns whether or not CSR format has been finalized.
ElementTransformation * GetElementTransformation(int i) const
Returns ElementTransformation for the i-th element.
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
void EliminateRowCol(int rc, const double sol, Vector &rhs, DiagonalPolicy dpolicy=DIAG_ONE)
Eliminate row rc and column rc and modify the rhs using sol.
void PartialSum()
Fill the entries of the array with the cumulative sum of the entries.
int height
Dimension of the output / number of rows in the matrix.
void ConvertToConformingVDofs(const Array< int > &dofs, Array< int > &cdofs)
For a partially conforming FE space, convert a marker array (nonzero entries are true) on the partial...
void MultTranspose(const Vector &x, Vector &y) const
Multiply a vector with the transposed matrix. y = At * x.
const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
static void ListToMarker(const Array< int > &list, int marker_size, Array< int > &marker, int mark_val=-1)
Convert an array of indices (list) to a Boolean marker array where all indices in the list are marked...
long GetSequence() const
Return update counter (see Mesh::sequence)
A class to handle Block systems in a matrix-free implementation.
int width
Dimension of the input / number of columns in the matrix.
void SetBlock(int iRow, int iCol, Operator *op, double c=1.0)
Add a block op in the block-entry (iblock, jblock).
Vector & GetBlock(int i)
Get the i-th vector in the block.
double f(const Vector &p)