15 #include "../general/device.hpp"
37 Table face_dof, dof_face;
56 int *I = dof_dof.
GetI();
57 int *J = dof_dof.
GetJ();
58 double *data =
new double[I[
height]];
119 MFEM_ABORT(
"the assembly level has already been set!");
129 mfem_error(
"Element assembly not supported yet... stay tuned!");
136 mfem_error(
"Matrix-free action not supported yet... stay tuned!");
150 MFEM_WARNING(
"Static condensation not supported for this assembly level");
156 bool symmetric =
false;
157 bool block_diagonal =
false;
176 MFEM_WARNING(
"Hybridization not supported for this assembly level");
203 "invalid matrix A dimensions: "
205 MFEM_ASSERT(A.
Finalized(),
"matrix A must be Finalized");
282 dbfi[0]->AssembleElementMatrix(fe, *eltrans, elmat);
283 for (
int k = 1; k <
dbfi.Size(); k++)
285 dbfi[k]->AssembleElementMatrix(fe, *eltrans,
elemmat);
358 #ifdef MFEM_USE_LEGACY_OPENMP
359 int free_element_matrices = 0;
363 free_element_matrices = 1;
369 for (
int i = 0; i <
fes -> GetNE(); i++)
374 elmat_p = &(*element_matrices)(i);
380 dbfi[0]->AssembleElementMatrix(fe, *eltrans, elmat);
381 for (
int k = 1; k <
dbfi.Size(); k++)
383 dbfi[k]->AssembleElementMatrix(fe, *eltrans,
elemmat);
409 for (
int k = 0; k <
bbfi.Size(); k++)
417 MFEM_ASSERT(bdr_marker.
Size() == bdr_attr_marker.
Size(),
418 "invalid boundary marker for boundary integrator #"
419 << k <<
", counting from zero");
420 for (
int i = 0; i < bdr_attr_marker.
Size(); i++)
422 bdr_attr_marker[i] |= bdr_marker[i];
426 for (
int i = 0; i <
fes -> GetNBE(); i++)
429 if (bdr_attr_marker[bdr_attr-1] == 0) {
continue; }
432 fes -> GetBdrElementVDofs (i,
vdofs);
433 eltrans =
fes -> GetBdrElementTransformation (i);
434 bbfi[0]->AssembleElementMatrix(be, *eltrans, elmat);
435 for (
int k = 1; k <
bbfi.Size(); k++)
440 bbfi[k]->AssembleElementMatrix(be, *eltrans,
elemmat);
464 for (
int i = 0; i < nfaces; i++)
466 tr = mesh -> GetInteriorFaceTransformations (i);
469 fes -> GetElementVDofs (tr -> Elem1No,
vdofs);
470 fes -> GetElementVDofs (tr -> Elem2No, vdofs2);
472 for (
int k = 0; k <
fbfi.Size(); k++)
474 fbfi[k] -> AssembleFaceMatrix (*
fes -> GetFE (tr -> Elem1No),
475 *
fes -> GetFE (tr -> Elem2No),
492 for (
int k = 0; k <
bfbfi.Size(); k++)
500 MFEM_ASSERT(bdr_marker.
Size() == bdr_attr_marker.
Size(),
501 "invalid boundary marker for boundary face integrator #"
502 << k <<
", counting from zero");
503 for (
int i = 0; i < bdr_attr_marker.
Size(); i++)
505 bdr_attr_marker[i] |= bdr_marker[i];
509 for (
int i = 0; i <
fes -> GetNBE(); i++)
512 if (bdr_attr_marker[bdr_attr-1] == 0) {
continue; }
514 tr = mesh -> GetBdrFaceTransformations (i);
517 fes -> GetElementVDofs (tr -> Elem1No,
vdofs);
518 fe1 =
fes -> GetFE (tr -> Elem1No);
523 for (
int k = 0; k <
bfbfi.Size(); k++)
528 bfbfi[k] -> AssembleFaceMatrix (*fe1, *fe2, *tr,
elemmat);
535 #ifdef MFEM_USE_LEGACY_OPENMP
536 if (free_element_matrices)
550 MFEM_ASSERT(
mat,
"the BilinearForm is not assembled");
580 Vector &B,
int copy_interior)
678 const int remove_zeros = 0;
766 #ifdef MFEM_USE_LEGACY_OPENMP
767 #pragma omp parallel for private(tmp,eltrans)
769 for (
int i = 0; i < num_elements; i++)
772 num_dofs_per_el, num_dofs_per_el);
775 if (num_dofs_per_el != fe.GetDof()*
fes->
GetVDim())
776 mfem_error(
"BilinearForm::ComputeElementMatrices:"
777 " all elements must have same number of dofs");
781 dbfi[0]->AssembleElementMatrix(fe, eltrans, elmat);
782 for (
int k = 1; k <
dbfi.Size(); k++)
785 dbfi[k]->AssembleElementMatrix(fe, eltrans, tmp);
848 for (
int i = 0; i < vdofs.
Size(); i++)
853 mat -> EliminateRowCol (vdof, sol(vdof), rhs, dpolicy);
857 mat -> EliminateRowCol (-1-vdof, sol(-1-vdof), rhs, dpolicy);
870 for (
int i = 0; i < vdofs.
Size(); i++)
875 mat -> EliminateRowCol (vdof, *
mat_e, dpolicy);
879 mat -> EliminateRowCol (-1-vdof, *
mat_e, dpolicy);
888 MFEM_ASSERT(ess_dofs.
Size() ==
height,
"incorrect dof Array size");
889 MFEM_ASSERT(sol.
Size() ==
height,
"incorrect sol Vector size");
890 MFEM_ASSERT(rhs.
Size() ==
height,
"incorrect rhs Vector size");
892 for (
int i = 0; i < ess_dofs.
Size(); i++)
895 mat -> EliminateRowCol (i, sol(i), rhs, dpolicy);
902 MFEM_ASSERT(ess_dofs.
Size() ==
height,
"incorrect dof Array size");
904 for (
int i = 0; i < ess_dofs.
Size(); i++)
907 mat -> EliminateRowCol (i, dpolicy);
914 MFEM_ASSERT(ess_dofs.
Size() ==
height,
"incorrect dof Array size");
916 for (
int i = 0; i < ess_dofs.
Size(); i++)
919 mat -> EliminateRowColDiag (i, value);
934 if (nfes && nfes !=
fes)
988 for (k=0; k <
dbfi.Size(); k++) {
delete dbfi[k]; }
989 for (k=0; k <
bbfi.Size(); k++) {
delete bbfi[k]; }
990 for (k=0; k <
fbfi.Size(); k++) {
delete fbfi[k]; }
991 for (k=0; k <
bfbfi.Size(); k++) {
delete bfbfi[k]; }
1000 :
Matrix(te_fes->GetVSize(), tr_fes->GetVSize())
1011 :
Matrix(te_fes->GetVSize(), tr_fes->GetVSize())
1026 return (*
mat)(i, j);
1031 return (*
mat)(i, j);
1040 const double a)
const
1046 const double a)
const
1065 "MixedBilinearForm::GetBlocks: both trial and test spaces "
1066 "must use Ordering::byNODES!");
1104 for (i = 0; i <
test_fes -> GetNE(); i++)
1106 trial_fes -> GetElementVDofs (i, tr_vdofs);
1107 test_fes -> GetElementVDofs (i, te_vdofs);
1108 eltrans =
test_fes -> GetElementTransformation (i);
1109 for (k = 0; k <
dom.Size(); k++)
1111 dom[k] -> AssembleElementMatrix2 (*
trial_fes -> GetFE(i),
1114 mat -> AddSubMatrix (te_vdofs, tr_vdofs, elemmat, skip_zeros);
1121 for (i = 0; i <
test_fes -> GetNBE(); i++)
1123 trial_fes -> GetBdrElementVDofs (i, tr_vdofs);
1124 test_fes -> GetBdrElementVDofs (i, te_vdofs);
1125 eltrans =
test_fes -> GetBdrElementTransformation (i);
1126 for (k = 0; k <
bdr.Size(); k++)
1128 bdr[k] -> AssembleElementMatrix2 (*
trial_fes -> GetBE(i),
1131 mat -> AddSubMatrix (te_vdofs, tr_vdofs, elemmat, skip_zeros);
1143 for (i = 0; i < nfaces; i++)
1153 te_vdofs.
Append(te_vdofs2);
1161 test_fe2 = test_fe1;
1163 for (
int k = 0; k <
skt.Size(); k++)
1165 skt[k]->AssembleFaceMatrix(*trial_face_fe, *test_fe1, *test_fe2,
1206 for (i = 0; i <
trial_fes -> GetNBE(); i++)
1207 if (bdr_attr_is_ess[
trial_fes -> GetBdrAttribute (i)-1])
1209 trial_fes -> GetBdrElementVDofs (i, tr_vdofs);
1210 for (j = 0; j < tr_vdofs.
Size(); j++)
1212 if ( (k = tr_vdofs[j]) < 0 )
1219 mat -> EliminateCols (cols_marker, &sol, &rhs);
1225 mat -> EliminateCols (marked_vdofs, &sol, &rhs);
1233 for (i = 0; i <
test_fes -> GetNBE(); i++)
1234 if (bdr_attr_is_ess[
test_fes -> GetBdrAttribute (i)-1])
1236 test_fes -> GetBdrElementVDofs (i, te_vdofs);
1237 for (j = 0; j < te_vdofs.
Size(); j++)
1239 if ( (k = te_vdofs[j]) < 0 )
1243 mat -> EliminateRow (k);
1262 for (i = 0; i <
dom.Size(); i++) {
delete dom[i]; }
1263 for (i = 0; i <
bdr.Size(); i++) {
delete bdr[i]; }
1264 for (i = 0; i <
skt.Size(); i++) {
delete skt[i]; }
1291 dom[0]->AssembleElementMatrix2(*dom_fe, *ran_fe, *T, totelmat);
1292 for (
int j = 1; j <
dom.Size(); j++)
1294 dom[j]->AssembleElementMatrix2(*dom_fe, *ran_fe, *T, elmat);
1304 for (
int i = 0; i < nfaces; i++)
1312 skt[0]->AssembleElementMatrix2(*dom_fe, *ran_fe, *T, totelmat);
1313 for (
int j = 1; j <
skt.Size(); j++)
1315 skt[j]->AssembleElementMatrix2(*dom_fe, *ran_fe, *T, elmat);
Abstract class for Finite Elements.
Ordering::Type GetOrdering() const
Return the ordering method.
int Size() const
Logical size of the array.
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
int GetBdrAttribute(int i) const
Return the attribute of boundary element i.
const SparseMatrix * GetConformingProlongation() const
The returned SparseMatrix is owned by the FiniteElementSpace.
void SetConstraintIntegrator(BilinearFormIntegrator *c_integ)
bool ReducesTrueVSize() const
HypreParMatrix * RAP(const HypreParMatrix *A, const HypreParMatrix *P)
Returns the matrix P^t * A * P.
void SyncMemory(const Vector &v)
Update the memory location of the vector to match v.
virtual void Finalize(int skip_zeros=1)
Finalize the matrix initialization, switching the storage format from LIL to CSR. ...
void SortRows()
Sort the column (TYPE II) indices in each row.
void SetSize(int s)
Resize the vector to size s.
void GetElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
void BooleanMult(const Array< int > &x, Array< int > &y) const
y = A * x, treating all entries as booleans (zero=false, nonzero=true).
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().
Pointer to an Operator of a specified type.
int * GetJ()
Return the array J.
virtual void GetEssentialVDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_vdofs, int component=-1) const
Data type dense matrix using column-major storage.
void AddMult(const Vector &x, Vector &y, const double a=1.0) const
y += A * x (default) or y += a * A * x
int Size() const
Returns the size of the vector.
void ReduceSystem(Vector &x, Vector &b, Vector &X, Vector &B, int copy_interior=0) const
Set the reduced solution X and r.h.s B vectors from the full linear system solution x and r...
int * GetI()
Return the array I.
void EliminateReducedTrueDofs(const Array< int > &ess_rtdof_list, Matrix::DiagonalPolicy dpolicy)
Eliminate the given reduced true dofs from the Schur complement matrix S.
Abstract data type for matrix inverse.
void LoseData()
Call this if data has been stolen.
const FiniteElement * GetFaceElement(int i) const
void ComputeSolution(const Vector &b, const Vector &sc_sol, Vector &sol) const
FaceElementTransformations * GetFaceElementTransformations(int FaceNo, int mask=31)
Memory< double > & GetMemory()
Return a reference to the Memory object used by the Vector.
void Reset()
Destroy the current hybridization matrix while preserving the computed constraint matrix and the set ...
void GetBlocks(Array2D< SparseMatrix * > &blocks) const
int GetNumFaces() const
Return the number of faces (3D), edges (2D) or vertices (1D).
const SparseMatrix * GetConformingRestriction() const
The returned SparseMatrix is owned by the FiniteElementSpace.
int GetNE() const
Returns number of elements in the mesh.
void SetSize(int m, int n)
void Finalize()
Finalize the construction of the hybridized matrix.
void AssembleBdrMatrix(int bdr_el, const DenseMatrix &A)
Assemble the boundary element matrix A into the hybridized system matrix.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
SparseMatrix & GetMatrix()
Return the serial hybridized matrix.
int Append(const T &el)
Append element 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.
bool areColumnsSorted() const
void GetFaceTransformation(int i, IsoparametricTransformation *FTr)
Returns the transformation defining the given face element in a user-defined variable.
void ComputeSolution(const Vector &b, const Vector &sol_r, Vector &sol) const
Abstract data type matrix.
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void Transpose(const Table &A, Table &At, int _ncols_A)
Transpose a Table.
int GetVDim() const
Returns vector dimension.
void AddSubMatrix(const Array< int > &rows, const Array< int > &cols, const DenseMatrix &subm, int skip_zeros=1)
Dynamic 2D array using row-major layout.
void SetSubVectorComplement(const Array< int > &dofs, const double val)
Set all vector entries NOT in the 'dofs' array to the given 'val'.
void SetSubMatrix(const Array< int > &rows, const Array< int > &cols, const DenseMatrix &subm, int skip_zeros=1)
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 AssembleMatrix(int el, const DenseMatrix &A)
Assemble the element matrix A into the hybridized system matrix.
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.
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication.
void Finalize()
Finalize the construction of the Schur complement matrix.
void AssembleBdrMatrix(int el, const DenseMatrix &elmat)
virtual void RecoverFEMSolution(const Vector &X, const Vector &b, Vector &x)
Reconstruct a solution vector x (e.g. a GridFunction) from the solution X of a constrained linear sys...
int height
Dimension of the output / number of rows in the matrix.
Table * GetFaceToElementTable() const
void AssembleMatrix(int el, const DenseMatrix &elmat)
bool HasEliminatedBC() const
Return true if essential boundary conditions have been eliminated from the Schur complement matrix...
void NewMemoryAndSize(const Memory< double > &mem, int s, bool own_mem)
Reset the Vector to use the given external Memory mem and size s.
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 associated with i'th element.
void GetFaceVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th face element (2D and 3D).
SparseMatrix & GetMatrix()
Return the serial Schur complement matrix.
void ReduceRHS(const Vector &b, Vector &b_r) const
const Table & GetElementToDofTable() const
void Init(const Array< int > &ess_tdof_list)
Prepare the Hybridization object for assembly.
const FiniteElement * GetBE(int i) const
Returns pointer to the FiniteElement for the i'th boundary element.
void GetBdrElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th boundary element.
void SetEssentialTrueDofs(const Array< int > &ess_tdof_list)
Determine and save internally essential reduced true dofs.
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
virtual const SparseMatrix * GetRestrictionMatrix() const
The returned SparseMatrix is owned by the FiniteElementSpace.
long GetSequence() const
Return update counter (see Mesh::sequence)
void Init(bool symmetric, bool block_diagonal)
virtual void Assemble(int skip_zeros=1)
Construct the internal matrix representation of the discrete linear operator.
Rank 3 tensor (array of matrices)
int width
Dimension of the input / number of columns in the matrix.
void Reset(OpType *A, bool own_A=true)
Reset the OperatorHandle to the given OpType pointer, A.
void PartMult(const Array< int > &rows, const Vector &x, Vector &y) const