MFEM v4.10.0
Finite element discretization library
Loading...
Searching...
No Matches
bilinearform.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2026, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12#ifndef MFEM_BILINEARFORM
13#define MFEM_BILINEARFORM
14
15#include "../config/config.hpp"
16#include "../linalg/linalg.hpp"
17#include "fespace.hpp"
18#include "gridfunc.hpp"
19#include "linearform.hpp"
20#include "bilininteg.hpp"
21#include "bilinearform_ext.hpp"
22#include "staticcond.hpp"
23#include "hybridization.hpp"
24
25namespace mfem
26{
27
28/** @brief Enumeration defining the assembly level for bilinear and nonlinear
29 form classes derived from Operator. For more details, see
30 https://mfem.org/howto/assembly_levels */
31enum class AssemblyLevel
32{
33 /// In the case of a BilinearForm LEGACY corresponds to a fully assembled
34 /// form, i.e. a global sparse matrix in MFEM, Hypre or PETSC format.
35 /// In the case of a NonlinearForm LEGACY corresponds to an operator that
36 /// is fully evaluated on the fly.
37 /// This assembly level is ALWAYS performed on the host.
38 LEGACY = 0,
39 /// @deprecated Use LEGACY instead.
40 LEGACYFULL = 0,
41 /// Fully assembled form, i.e. a global sparse matrix in MFEM format. This
42 /// assembly is compatible with device execution.
43 FULL,
44 /// Form assembled at element level, which computes and stores dense element
45 /// matrices.
46 ELEMENT,
47 /// Partially-assembled form, which computes and stores data only at
48 /// quadrature points.
49 PARTIAL,
50 /// "Matrix-free" form that computes all of its action on-the-fly without any
51 /// substantial storage.
52 NONE,
53};
54
55
56/** @brief A "square matrix" operator for the associated FE space and
57 BLFIntegrators The sum of all the BLFIntegrators can be used form the matrix
58 M. This class also supports other assembly levels specified via the
59 SetAssemblyLevel() function. */
60class BilinearForm : public Matrix
61{
63
64protected:
65 /// Sparse matrix $ M $ to be associated with the form. Owned.
67
68 /** @brief Sparse Matrix $ M_e $ used to store the eliminations
69 from the b.c. Owned.
70 $ M + M_e = M_{original} $ */
72
73 /// FE space on which the form lives. Not owned.
75
76 /** @brief The ::AssemblyLevel of the form (AssemblyLevel::LEGACY,
77 AssemblyLevel::FULL, AssemblyLevel::ELEMENT, AssemblyLevel::PARTIAL) */
79
80 /// Element batch size used in the form action (1, 8, num_elems, etc.)
81 int batch;
82
83 /** @brief Extension for supporting Full Assembly (FA),
84 Element Assembly (EA),Partial Assembly (PA),
85 or Matrix Free assembly (MF). */
86 std::unique_ptr<BilinearFormExtension> ext;
87
88 /** Indicates if the sparse matrix is sorted after assembly when using
89 Full Assembly (FA). */
90 bool sort_sparse_matrix = false;
91
92 /** @brief Indicates the Mesh::sequence corresponding to the current state of
93 the BilinearForm. */
95
96 /** @brief Indicates the BilinearFormIntegrator%s stored in #domain_integs,
97 #boundary_integs, #interior_face_integs, and #boundary_face_integs are
98 owned by another BilinearForm. */
100
101 /// Set of Domain Integrators to be applied.
103
104 /// Element attribute marker (should be of length mesh->attributes.Max() or
105 /// 0 if mesh->attributes is empty)
106 /// Includes all by default.
107 /// 0 - ignore attribute
108 /// 1 - include attribute
109 Array<Array<int>*> domain_integs_marker; ///< Entries are not owned.
110
111 /// Set of Boundary Integrators to be applied.
113 Array<Array<int>*> boundary_integs_marker; ///< Entries are not owned.
114
115 /// Set of interior face Integrators to be applied.
117
118 /// Set of boundary face Integrators to be applied.
120 Array<Array<int>*> boundary_face_integs_marker; ///< Entries are not owned.
121
124
125 std::unique_ptr<DenseTensor> element_matrices;
126
127 std::unique_ptr<StaticCondensation> static_cond;
128 std::unique_ptr<Hybridization> hybridization;
129
130 /** @brief This data member allows one to specify what should be done to the
131 diagonal matrix entries and corresponding RHS values upon elimination of
132 the constrained DoFs. */
134
136
137 /// Allocate appropriate SparseMatrix and assign it to #mat
138 void AllocMat();
139
140 /** @brief For partially conforming trial and/or test FE spaces, complete the
141 assembly process by performing $ P^t A P $ where $ A $ is the
142 internal sparse matrix and $ P $ is the conforming prolongation
143 matrix of the trial/test FE space. After this call the
144 BilinearForm becomes an operator on the conforming FE space. */
145 void ConformingAssemble();
146
147 /// may be used in the construction of derived classes
149 {
150 fes = NULL; sequence = -1;
151 mat = mat_e = NULL; extern_bfs = 0;
155 batch = 1;
156 }
157
158private:
159 /// Copy construction is not supported; body is undefined.
160 BilinearForm(const BilinearForm &);
161
162 /// Copy assignment is not supported; body is undefined.
163 BilinearForm &operator=(const BilinearForm &);
164
165public:
166 /// Creates bilinear form associated with FE space @a *f.
167 /** The pointer @a f is not owned by the newly constructed object. */
169
170 /** @brief Create a BilinearForm on the FiniteElementSpace @a f, using the
171 same integrators as the BilinearForm @a bf.
172
173 The pointer @a f is not owned by the newly constructed object.
174
175 The integrators in @a bf are copied as pointers and they are not owned by
176 the newly constructed BilinearForm.
177
178 The optional parameter @a ps is used to initialize the internal flag
179 #precompute_sparsity, see UsePrecomputedSparsity() for details. */
181
182 /// Get the size of the BilinearForm as a square matrix.
183 int Size() const { return height; }
184
185 /// Set the desired assembly level.
186 /** Valid choices are:
187
188 - AssemblyLevel::LEGACY (default)
189 - AssemblyLevel::FULL
190 - AssemblyLevel::PARTIAL
191 - AssemblyLevel::ELEMENT
192 - AssemblyLevel::NONE
193
194 If used, this method must be called before assembly. */
195 void SetAssemblyLevel(AssemblyLevel assembly_level);
196
197 /** @brief Force the sparse matrix column indices to be sorted when using
198 AssemblyLevel::FULL.
199
200 When assembling on device the assembly algorithm uses atomic operations
201 to insert values in the sparse matrix, which can result in different
202 column index orderings across runs. Calling this method with @a enable_it
203 set to @a true forces a sorting algorithm to be called at the end of the
204 assembly procedure to ensure sorted column indices (and therefore
205 deterministic results).
206 */
207 void EnableSparseMatrixSorting(bool enable_it)
208 {
209 sort_sparse_matrix = enable_it;
210 }
211
212 /// Returns the assembly level
214
216
217 /** @brief Enable the use of static condensation. For details see the
218 description for class StaticCondensation in fem/staticcond.hpp This
219 method should be called before assembly. If the number of unknowns after
220 static condensation is not reduced, it is not enabled. */
222
223 /** @brief Check if static condensation was actually enabled by a previous
224 call to EnableStaticCondensation(). */
225 bool StaticCondensationIsEnabled() const { return static_cond != nullptr; }
226
227 /// Return the trace FE space associated with static condensation.
229 { return static_cond ? static_cond->GetTraceFESpace() : NULL; }
230
231 /// Enable hybridization.
232 /** For details see the description for class
233 Hybridization in fem/hybridization.hpp. This method should be called
234 before assembly. */
235 void EnableHybridization(FiniteElementSpace *constr_space,
236 BilinearFormIntegrator *constr_integ,
238
239 /** @brief For scalar FE spaces, precompute the sparsity pattern of the
240 matrix (assuming dense element matrices) based on the types of
241 integrators present in the bilinear form. */
243
244 /** @brief Use the given CSR sparsity pattern to allocate the internal
245 SparseMatrix.
246
247 - The @a I and @a J arrays must define a square graph with size equal to
248 GetVSize() of the associated FiniteElementSpace.
249 - This method should be called after enabling static condensation or
250 hybridization, if used.
251 - In the case of static condensation, @a I and @a J are not used.
252 - The ownership of the arrays @a I and @a J remains with the caller. */
253 void UseSparsity(int *I, int *J, bool isSorted);
254
255 /// Use the sparsity of @a A to allocate the internal SparseMatrix.
256 void UseSparsity(SparseMatrix &A);
257
258 /** @brief Pre-allocate the internal SparseMatrix before assembly.
259 If the internal flag #precompute_sparsity
260 is set, the matrix is allocated in CSR format (i.e.
261 finalized) and the entries are initialized with zeros. */
262 void AllocateMatrix() { if (mat == NULL) { AllocMat(); } }
263
264 /// Access all the integrators added with AddDomainIntegrator().
266
267 /** @brief Access all boundary markers added with AddDomainIntegrator().
268 If no marker was specified when the integrator was added, the
269 corresponding pointer (to Array<int>) will be NULL. */
271
272 /// Access all the integrators added with AddBoundaryIntegrator().
274 /** @brief Access all boundary markers added with AddBoundaryIntegrator().
275 If no marker was specified when the integrator was added, the
276 corresponding pointer (to Array<int>) will be NULL. */
278
279 /// Access all integrators added with AddInteriorFaceIntegrator().
281
282 /// Access all integrators added with AddBdrFaceIntegrator().
284
285 /** @brief Access all boundary markers added with AddBdrFaceIntegrator().
286 If no marker was specified when the integrator was added, the
287 corresponding pointer (to Array<int>) will be NULL. */
290
291 /// Returns a reference to: $ M_{ij} $
292 const real_t &operator()(int i, int j) { return (*mat)(i,j); }
293
294 /// Returns a reference to: $ M_{ij} $
295 real_t &Elem(int i, int j) override;
296
297 /// Returns constant reference to: $ M_{ij} $
298 const real_t &Elem(int i, int j) const override;
299
300 /// Matrix vector multiplication: $ y = M x $
301 void Mult(const Vector &x, Vector &y) const override;
302
303 /** @brief Matrix vector multiplication with the original uneliminated
304 matrix. The original matrix is $ M + M_e $ so we have:
305 $ y = M x + M_e x $ */
306 void FullMult(const Vector &x, Vector &y) const
307 { mat->Mult(x, y); mat_e->AddMult(x, y); }
308
309 /// Add the matrix vector multiple to a vector: $ y += a M x $
310 void AddMult(const Vector &x, Vector &y,
311 const real_t a = 1.0) const override;
312
313 /** @brief Add the original uneliminated matrix vector multiple to a vector.
314 The original matrix is $ M + Me $ so we have:
315 $ y += M x + M_e x $ */
316 void FullAddMult(const Vector &x, Vector &y) const
317 { mat->AddMult(x, y); mat_e->AddMult(x, y); }
318
319 /// Add the matrix transpose vector multiplication: $ y += a M^T x $
320 void AddMultTranspose(const Vector & x, Vector & y,
321 const real_t a = 1.0) const override;
322
323 /** @brief Add the original uneliminated matrix transpose vector
324 multiple to a vector. The original matrix is $ M + M_e $
325 so we have: $ y += M^T x + {M_e}^T x $ */
326 void FullAddMultTranspose(const Vector & x, Vector & y) const
327 { mat->AddMultTranspose(x, y); mat_e->AddMultTranspose(x, y); }
328
329 /// Matrix transpose vector multiplication: $ y = M^T x $
330 void MultTranspose(const Vector & x, Vector & y) const override;
331
332 /// Compute $ y^T M x $
333 real_t InnerProduct(const Vector &x, const Vector &y) const
334 { return mat->InnerProduct (x, y); }
335
336 /** @brief Returns a pointer to (approximation) of the matrix inverse:
337 $ M^{-1} $ (currently returns NULL) */
338 MatrixInverse *Inverse() const override;
339
340 /** @brief Finalizes the matrix initialization if the ::AssemblyLevel is
341 AssemblyLevel::LEGACY.
342 The matrix that gets finalized is different if you are using static
343 condensation or hybridization.*/
344 void Finalize(int skip_zeros = 1) override;
345
346 /** @brief Returns a const reference to the sparse matrix: $ M $
347 *
348 This will fail if HasSpMat() is false. */
349 const SparseMatrix &SpMat() const
350 {
351 MFEM_VERIFY(mat, "mat is NULL and can't be dereferenced");
352 return *mat;
353 }
354
355 /** @brief Returns a reference to the sparse matrix: $ M $
356 *
357 This will fail if HasSpMat() is false. */
359 {
360 MFEM_VERIFY(mat, "mat is NULL and can't be dereferenced");
361 return *mat;
362 }
363
364 /** @brief Returns true if the sparse matrix is not null, false otherwise.
365 *
366 @sa SpMat(). */
367 bool HasSpMat()
368 {
369 return mat != nullptr;
370 }
371
372
373 /** @brief Nullifies the internal matrix $ M $ and returns a pointer
374 to it. Used for transferring ownership. */
375 SparseMatrix *LoseMat() { SparseMatrix *tmp = mat; mat = NULL; return tmp; }
376
377 /** @brief Returns a const reference to the sparse matrix of eliminated b.c.:
378 $ M_e $
379
380 This will fail if HasSpMatElim() is false. */
381 const SparseMatrix &SpMatElim() const
382 {
383 MFEM_VERIFY(mat_e, "mat_e is NULL and can't be dereferenced");
384 return *mat_e;
385 }
386
387 /** @brief Returns a reference to the sparse matrix of eliminated b.c.:
388 $ M_e $
389
390 This will fail if HasSpMatElim() is false. */
392 {
393 MFEM_VERIFY(mat_e, "mat_e is NULL and can't be dereferenced");
394 return *mat_e;
395 }
396
397 /** @brief Returns true if the sparse matrix of eliminated b.c.s is not
398 null, false otherwise.
399
400 @sa SpMatElim(). */
402 {
403 return mat_e != nullptr;
404 }
405
406 /// Adds new Domain Integrator. Assumes ownership of @a bfi.
408
409 /// Adds new Domain Integrator restricted to certain elements specified by
410 /// the @a elem_attr_marker.
412 Array<int> &elem_marker);
413
414 /// Adds new Boundary Integrator. Assumes ownership of @a bfi.
416
417 /** @brief Adds new Boundary Integrator, restricted to specific boundary
418 attributes.
419
420 Assumes ownership of @a bfi. The array @a bdr_marker is stored internally
421 as a pointer to the given Array<int> object. */
423 Array<int> &bdr_marker);
424
425 /// Adds new interior Face Integrator. Assumes ownership of @a bfi.
427
428 /// Adds new boundary Face Integrator. Assumes ownership of @a bfi.
430
431 /** @brief Adds new boundary Face Integrator, restricted to specific boundary
432 attributes.
433
434 Assumes ownership of @a bfi. The array @a bdr_marker is stored internally
435 as a pointer to the given Array<int> object. */
437 Array<int> &bdr_marker);
438
439 /// Sets all sparse values of $ M $ and $ M_e $ to 'a'.
440 void operator=(const real_t a)
441 {
442 if (mat != NULL) { *mat = a; }
443 if (mat_e != NULL) { *mat_e = a; }
444 }
445
446 /// Assembles the form i.e. sums over all domain/bdr integrators.
447 void Assemble(int skip_zeros = 1);
448
449 /** @brief Assemble the diagonal of the bilinear form into @a diag. Note that
450 @a diag is a tdof Vector.
451
452 When the AssemblyLevel is not LEGACY, and the mesh has hanging nodes,
453 this method returns |P^T| d_l, where d_l is the diagonal of the form
454 before applying conforming assembly, P^T is the transpose of the
455 conforming prolongation, and |.| denotes the entry-wise absolute value.
456 In general, this is just an approximation of the exact diagonal for this
457 case. */
458 void AssembleDiagonal(Vector &diag) const override;
459
460 /// Get the finite element space prolongation operator.
461 const Operator *GetProlongation() const override
462 { return fes->GetConformingProlongation(); }
463
464 /// Get the finite element space restriction operator
465 const Operator *GetRestriction() const override
466 { return fes->GetConformingRestriction(); }
467
468 /// Get the output finite element space prolongation matrix
469 const Operator *GetOutputProlongation() const override
470 { return GetProlongation(); }
471
472 /** @brief Returns the output fe space restriction matrix, transposed
473
474 Logically, this is the transpose of GetOutputRestriction, but in
475 practice it is convenient to have it in transposed form for
476 construction of RAP operators in matrix-free methods. */
479
480 /// Get the output finite element space restriction matrix
481 const Operator *GetOutputRestriction() const override
482 { return GetRestriction(); }
483
484 /// Compute serial RAP operator and store it in @a A as a SparseMatrix.
486 {
487 MFEM_ASSERT(mat, "SerialRAP requires the SparseMatrix to be assembled.");
489 A.Reset(mat, false);
490 }
491
492 /** @brief Form the linear system A X = B, corresponding to this bilinear
493 form and the linear form @a b(.). */
494 /** This method applies any necessary transformations to the linear system
495 such as: eliminating boundary conditions; applying conforming constraints
496 for non-conforming AMR; parallel assembly; static condensation;
497 hybridization.
498
499 The GridFunction-size vector @a x must contain the essential b.c. The
500 BilinearForm and the LinearForm-size vector @a b must be assembled.
501
502 The vector @a X is initialized with a suitable initial guess: when using
503 hybridization, the vector @a X is set to zero; otherwise, the essential
504 entries of @a X are set to the corresponding b.c. and all other entries
505 are set to zero (@a copy_interior == 0) or copied from @a x
506 (@a copy_interior != 0).
507
508 This method can be called multiple times (with the same @a ess_tdof_list
509 array) to initialize different right-hand sides and boundary condition
510 values.
511
512 After solving the linear system, the finite element solution @a x can be
513 recovered by calling RecoverFEMSolution() (with the same vectors @a X,
514 @a b, and @a x).
515
516 NOTE: If there are no transformations, @a X simply reuses the data of
517 @a x. */
518 virtual void FormLinearSystem(const Array<int> &ess_tdof_list, Vector &x,
519 Vector &b, OperatorHandle &A, Vector &X,
520 Vector &B, int copy_interior = 0);
521
522 /** @brief Form the linear system A X = B, corresponding to this bilinear
523 form and the linear form @a b(.). */
524 /** Version of the method FormLinearSystem() where the system matrix is
525 returned in the variable @a A, of type OpType, holding a *reference* to
526 the system matrix (created with the method OpType::MakeRef()). The
527 reference will be invalidated when SetOperatorType(), Update(), or the
528 destructor is called. */
529 template <typename OpType>
531 OpType &A, Vector &X, Vector &B,
532 int copy_interior = 0)
533 {
535 FormLinearSystem(ess_tdof_list, x, b, Ah, X, B, copy_interior);
536 OpType *A_ptr = Ah.Is<OpType>();
537 MFEM_VERIFY(A_ptr, "invalid OpType used");
538 A.MakeRef(*A_ptr);
539 }
540
541 /// Form the linear system matrix @a A, see FormLinearSystem() for details.
542 virtual void FormSystemMatrix(const Array<int> &ess_tdof_list,
543 OperatorHandle &A);
544
545 /// Form the linear system matrix A, see FormLinearSystem() for details.
546 /** Version of the method FormSystemMatrix() where the system matrix is
547 returned in the variable @a A, of type OpType, holding a *reference* to
548 the system matrix (created with the method OpType::MakeRef()). The
549 reference will be invalidated when SetOperatorType(), Update(), or the
550 destructor is called. */
551 template <typename OpType>
553 {
556 OpType *A_ptr = Ah.Is<OpType>();
557 MFEM_VERIFY(A_ptr, "invalid OpType used");
558 A.MakeRef(*A_ptr);
559 }
560
561 /// Recover the solution of a linear system formed with FormLinearSystem().
562 /** Call this method after solving a linear system constructed using the
563 FormLinearSystem() method to recover the solution as a GridFunction-size
564 vector in @a x. Use the same arguments as in the FormLinearSystem() call.
565 */
566 void RecoverFEMSolution(const Vector &X, const Vector &b,
567 Vector &x) override;
568
569 /// @brief Compute and store internally all element matrices.
570 ///
571 /// If AssemblyLevel::ELEMENT is selected with SetAssemblyLevel(), this will
572 /// use efficient (device-accelerated) assembly of the element matrices.
574
575 /// Free the memory used by the element matrices.
577
578 /// @brief Return a DenseTensor containing the assembled element matrices.
579 ///
580 /// If AssemblyLevel::ELEMENT is selected with SetAssemblyLevel(), this will
581 /// use efficient (device-accelerated) assembly of the element matrices.
583
584 /// Compute the element matrix of the given element
585 /** The element matrix is computed by calling the domain integrators
586 or the one stored internally by a prior call of ComputeElementMatrices()
587 is returned when available.
588 */
589 void ComputeElementMatrix(int i, DenseMatrix &elmat) const;
590
591 /// Compute the boundary element matrix of the given boundary element
592 /** @note The boundary attribute markers of the integrators are ignored. */
593 void ComputeBdrElementMatrix(int i, DenseMatrix &elmat) const;
594
595 /// Compute the face matrix of the given face element
596 void ComputeFaceMatrix(int i, DenseMatrix &elmat) const;
597
598 /// Compute the boundary face matrix of the given boundary element
599 /** @note The boundary attribute markers of the integrators are ignored. */
600 void ComputeBdrFaceMatrix(int i, DenseMatrix &elmat) const;
601
602 /// Assemble the given element matrix
603 /** The element matrix @a elmat is assembled for the element @a i, i.e.
604 added to the system matrix. The flag @a skip_zeros skips the zero
605 elements of the matrix, unless they are breaking the symmetry of
606 the system matrix.
607 */
608 void AssembleElementMatrix(int i, const DenseMatrix &elmat,
609 int skip_zeros = 1);
610
611 /// Assemble the given element matrix
612 /** The element matrix @a elmat is assembled for the element @a i, i.e.
613 added to the system matrix. The vdofs of the element are returned
614 in @a vdofs. The flag @a skip_zeros skips the zero elements of the
615 matrix, unless they are breaking the symmetry of the system matrix.
616 */
617 void AssembleElementMatrix(int i, const DenseMatrix &elmat,
618 Array<int> &vdofs, int skip_zeros = 1);
619
620 /// Assemble the given boundary element matrix
621 /** The boundary element matrix @a elmat is assembled for the boundary
622 element @a i, i.e. added to the system matrix. The flag @a skip_zeros
623 skips the zero elements of the matrix, unless they are breaking the
624 symmetry of the system matrix.
625 */
626 void AssembleBdrElementMatrix(int i, const DenseMatrix &elmat,
627 int skip_zeros = 1);
628
629 /// Assemble the given boundary element matrix
630 /** The boundary element matrix @a elmat is assembled for the boundary
631 element @a i, i.e. added to the system matrix. The vdofs of the element
632 are returned in @a vdofs. The flag @a skip_zeros skips the zero elements
633 of the matrix, unless they are breaking the symmetry of the system
634 matrix. */
635 void AssembleBdrElementMatrix(int i, const DenseMatrix &elmat,
636 Array<int> &vdofs, int skip_zeros = 1);
637
638 /// Eliminate essential boundary DOFs from the system.
639 /** The array @a bdr_attr_is_ess marks boundary attributes that constitute
640 the essential part of the boundary. By default, the diagonal at the
641 essential DOFs is set to 1.0. This behavior is controlled by the argument
642 @a dpolicy. */
643 void EliminateEssentialBC(const Array<int> &bdr_attr_is_ess,
644 const Vector &sol, Vector &rhs,
645 DiagonalPolicy dpolicy = DIAG_ONE);
646
647 /// Eliminate essential boundary DOFs from the system matrix.
648 void EliminateEssentialBC(const Array<int> &bdr_attr_is_ess,
649 DiagonalPolicy dpolicy = DIAG_ONE);
650 /// Perform elimination and set the diagonal entry to the given value
651 void EliminateEssentialBCDiag(const Array<int> &bdr_attr_is_ess,
652 real_t value);
653
654 /// Eliminate the given @a vdofs. NOTE: here, @a vdofs is a list of DOFs.
655 /** In this case the eliminations are applied to the internal $ M $
656 and @a rhs without storing the elimination matrix $ M_e $. */
657 void EliminateVDofs(const Array<int> &vdofs, const Vector &sol, Vector &rhs,
658 DiagonalPolicy dpolicy = DIAG_ONE);
659
660 /** @brief Eliminate the given @a vdofs, storing the eliminated part
661 internally in $ M_e $.
662
663 This method works in conjunction with EliminateVDofsInRHS() and allows
664 elimination of boundary conditions in multiple right-hand sides. In this
665 method, @a vdofs is a list of DOFs. */
666 void EliminateVDofs(const Array<int> &vdofs,
667 DiagonalPolicy dpolicy = DIAG_ONE);
668
669 /** @brief Similar to
670 EliminateVDofs(const Array<int> &, const Vector &,
671 Vector &, DiagonalPolicy)
672 but here @a ess_dofs is a marker (boolean) array on all vector-dofs
673 (@a ess_dofs[i] < 0 is true). */
674 void EliminateEssentialBCFromDofs(const Array<int> &ess_dofs,
675 const Vector &sol,
676 Vector &rhs,
677 DiagonalPolicy dpolicy = DIAG_ONE);
678
679 /** @brief Similar to EliminateVDofs(const Array<int> &, DiagonalPolicy) but
680 here @a ess_dofs is a marker (boolean) array on all vector-dofs
681 (@a ess_dofs[i] < 0 is true). */
682 void EliminateEssentialBCFromDofs(const Array<int> &ess_dofs,
683 DiagonalPolicy dpolicy = DIAG_ONE);
684 /// Perform elimination and set the diagonal entry to the given value
685 void EliminateEssentialBCFromDofsDiag(const Array<int> &ess_dofs,
686 real_t value);
687
688 /** @brief Use the stored eliminated part of the matrix (see
689 EliminateVDofs(const Array<int> &, DiagonalPolicy)) to modify the r.h.s.
690 @a b; @a vdofs is a list of DOFs (non-directional, i.e. >= 0). */
691 void EliminateVDofsInRHS(const Array<int> &vdofs, const Vector &x,
692 Vector &b);
693
694 /** @brief Compute inner product for full uneliminated matrix:
695 $ y^T M x + y^T M_e x $ */
696 real_t FullInnerProduct(const Vector &x, const Vector &y) const
697 { return mat->InnerProduct(x, y) + mat_e->InnerProduct(x, y); }
698
699 /** @brief Update the @a FiniteElementSpace and delete all data associated
700 with the old one. */
701 virtual void Update(FiniteElementSpace *nfes = NULL);
702
703 /// (DEPRECATED) Return the FE space associated with the BilinearForm.
704 /** @deprecated Use FESpace() instead. */
705 MFEM_DEPRECATED FiniteElementSpace *GetFES() { return fes; }
706
707 /// Return the FE space associated with the BilinearForm.
709
710 /// Read-only access to the associated FiniteElementSpace.
711 const FiniteElementSpace *FESpace() const { return fes; }
712
713 /// Prints operator to stream os.
714 void Print(std::ostream & os = mfem::out, int width_ = 4) const override
715 {
716 MFEM_VERIFY(mat, "mat is NULL and can't be dereferenced");
717 mat->Print(os, width_);
718 }
719
720 /** @brief Sets Operator::DiagonalPolicy used upon construction of the
721 linear system.
722 Policies include:
723
724 - DIAG_ZERO (Set the diagonal values to zero)
725 - DIAG_ONE (Set the diagonal values to one)
726 - DIAG_KEEP (Keep the diagonal values)
727 */
729
730 /// Indicate that integrators are not owned by the BilinearForm
732
733 /** @brief Deletes internal matrices, bilinear integrators, and the
734 BilinearFormExtension */
735 virtual ~BilinearForm();
736};
737
738
739/**
740 Class for assembling of bilinear forms `a(u,v)` defined on different
741 trial and test spaces. The assembled matrix `M` is such that
742
743 a(u,v) = V^t M U
744
745 where `U` and `V` are the vectors representing the functions `u` and `v`,
746 respectively. The first argument, `u`, of `a(,)` is in the trial space
747 and the second argument, `v`, is in the test space. Thus,
748
749 # of rows of M = dimension of the test space and
750 # of cols of M = dimension of the trial space.
751
752 Both trial and test spaces should be defined on the same mesh.
753*/
755{
756protected:
757 SparseMatrix *mat; ///< Owned.
758 SparseMatrix *mat_e; ///< Owned.
759
761 *test_fes; ///< Not owned
762
763 /// The form assembly level (full, partial, etc.)
765
766 /** Extension for supporting Full Assembly (FA), Element Assembly (EA),
767 Partial Assembly (PA), or Matrix Free assembly (MF). */
768 std::unique_ptr<MixedBilinearFormExtension> ext;
769
770 /** @brief Indicates the BilinearFormIntegrator%s stored in
771 MixedBilinearForm#domain_integs, MixedBilinearForm#boundary_integs,
772 MixedBilinearForm#trace_face_integs and
773 MixedBilinearForm#boundary_trace_face_integs
774 are owned by another MixedBilinearForm. */
776
777 /// Domain integrators.
779 /// Entries are not owned.
781
782 /// Boundary integrators.
784 /// Entries are not owned.
786
787 /// Interior face integrators.
789
790 /// Boundary face integrators.
792 /// Entries are not owned.
794
795 /// Trace face (skeleton) integrators.
797
798 /// Boundary trace face (skeleton) integrators.
800 /// Entries are not owned.
802
805
806private:
807 /// Copy construction is not supported; body is undefined.
809
810 /// Copy assignment is not supported; body is undefined.
811 MixedBilinearForm &operator=(const MixedBilinearForm &);
812
813public:
814 /** @brief Construct a MixedBilinearForm on the given trial, @a tr_fes, and
815 test, @a te_fes, FiniteElementSpace%s. */
816 /** The pointers @a tr_fes and @a te_fes are not owned by the newly
817 constructed object. */
819 FiniteElementSpace *te_fes);
820
821 /** @brief Create a MixedBilinearForm on the given trial, @a tr_fes, and
822 test, @a te_fes, FiniteElementSpace%s, using the same integrators as the
823 MixedBilinearForm @a mbf.
824
825 The pointers @a tr_fes and @a te_fes are not owned by the newly
826 constructed object.
827
828 The integrators in @a mbf are copied as pointers and they are not owned
829 by the newly constructed MixedBilinearForm. */
831 FiniteElementSpace *te_fes,
832 MixedBilinearForm *mbf);
833
834 /// Returns a reference to: $ M_{ij} $
835 real_t &Elem(int i, int j) override;
836
837 /// Returns a reference to: $ M_{ij} $
838 const real_t &Elem(int i, int j) const override;
839
840 /// Matrix multiplication: $ y = M x $
841 void Mult(const Vector & x, Vector & y) const override;
842
843 /// Add the matrix vector multiple to a vector: $ y += a M x $
844 void AddMult(const Vector & x, Vector & y,
845 const real_t a = 1.0) const override;
846
847 /// Matrix transpose vector multiplication: $ y = M^T x $
848 void MultTranspose(const Vector & x, Vector & y) const override;
849
850 /// Add the matrix transpose vector multiplication: $ y += a M^T x $
851 void AddMultTranspose(const Vector & x, Vector & y,
852 const real_t a = 1.0) const override;
853
854 /** @brief Returns a pointer to (approximation) of the matrix inverse:
855 $ M^{-1} $ (currently unimplemented and returns NULL)*/
856 MatrixInverse *Inverse() const override;
857
858 /** @brief Finalizes the matrix initialization if the ::AssemblyLevel is
859 AssemblyLevel::LEGACY.*/
860 void Finalize(int skip_zeros = 1) override;
861
862 /** @brief Extract the associated matrix as SparseMatrix blocks. The number
863 of block rows and columns is given by the vector dimensions (vdim) of the
864 test and trial spaces, respectively. */
865 void GetBlocks(Array2D<SparseMatrix *> &blocks) const;
866
867 /// Returns a const reference to the sparse matrix: $ M $
868 /** This will segfault if the usual sparse mat is not defined
869 like when static condensation is being used or AllocMat() has
870 not yet been called. */
871 const SparseMatrix &SpMat() const
872 {
873 MFEM_VERIFY(mat, "mat is NULL and can't be dereferenced");
874 return *mat;
875 }
876
877 /// Returns a reference to the sparse matrix: $ M $
879 {
880 MFEM_VERIFY(mat, "mat is NULL and can't be dereferenced");
881 return *mat;
882 }
883
884 /** @brief Nullifies the internal matrix $ M $ and returns a pointer
885 to it. Used for transferring ownership. */
886 SparseMatrix *LoseMat() { SparseMatrix *tmp = mat; mat = NULL; return tmp; }
887
888 /// Returns a const reference to the sparse matrix of eliminated b.c.: $ M_e $
889 const SparseMatrix &SpMatElim() const
890 {
891 MFEM_VERIFY(mat_e, "mat_e is NULL and can't be dereferenced");
892 return *mat_e;
893 }
894
895 /// Returns a reference to the sparse matrix of eliminated b.c.: $ M_e $
897 {
898 MFEM_VERIFY(mat_e, "mat_e is NULL and can't be dereferenced");
899 return *mat_e;
900 }
901
902 /// Adds a domain integrator. Assumes ownership of @a bfi.
904
905 /// Adds a domain integrator. Assumes ownership of @a bfi.
907 Array<int> &elem_marker);
908
909 /// Adds a boundary integrator. Assumes ownership of @a bfi.
911
912 /// Adds a boundary integrator. Assumes ownership of @a bfi.
914 Array<int> &bdr_marker);
915
916 /// Adds an interior face integrator. Assumes ownership of @a bfi.
918
919 /// Adds a boundary face integrator. Assumes ownership of @a bfi.
921
922 /// Adds a boundary face integrator. Assumes ownership of @a bfi.
924 Array<int> &bdr_marker);
925
926 /** @brief Add a trace face integrator. Assumes ownership of @a bfi.
927
928 This type of integrator assembles terms over all faces of the mesh using
929 the face FE from the trial space and the two adjacent volume FEs from
930 the test space. */
932
933 /// Adds a boundary trace face integrator. Assumes ownership of @a bfi.
935
936 /// Adds a boundary trace face integrator. Assumes ownership of @a bfi.
938 Array<int> &bdr_marker);
939
940 /// Access all integrators added with AddDomainIntegrator().
942 /** @brief Access all domain markers added with AddDomainIntegrator().
943 If no marker was specified when the integrator was added, the
944 corresponding pointer (to Array<int>) will be NULL. */
946
947 /// Access all integrators added with AddBoundaryIntegrator().
949
950 /** @brief Access all boundary markers added with AddBoundaryIntegrator().
951
952 If no marker was specified when the integrator was added, the
953 corresponding pointer (to Array<int>) will be NULL. */
955
956 /// Access all integrators added with AddInteriorFaceIntegrator().
958
959 /// Access all integrators added with AddBdrFaceIntegrator().
961 /** @brief Access all boundary markers added with AddBdrFaceIntegrator().
962 If no marker was specified when the integrator was added, the
963 corresponding pointer (to Array<int>) will be NULL. */
965
966 /// Access all integrators added with AddTraceFaceIntegrator().
968
969 /// Access all integrators added with AddBdrTraceFaceIntegrator().
972
973 /** @brief Access all boundary markers added with AddBdrTraceFaceIntegrator()
974
975 If no marker was specified when the integrator was added, the
976 corresponding pointer (to Array<int>) will be NULL. */
979
980 /// Sets all sparse values of $ M $ to @a a.
981 void operator=(const real_t a) { *mat = a; }
982
983 /// Set the desired assembly level. The default is AssemblyLevel::LEGACY.
984 /** This method must be called before assembly. See ::AssemblyLevel*/
985 void SetAssemblyLevel(AssemblyLevel assembly_level);
986
987 void Assemble(int skip_zeros = 1);
988
989 /** @brief Assemble the diagonal of ADA^T into diag, where A is this mixed
990 bilinear form and D is a diagonal. */
991 void AssembleDiagonal_ADAt(const Vector &D, Vector &diag) const;
992
993 /// Get the input finite element space prolongation matrix
994 const Operator *GetProlongation() const override
995 { return trial_fes->GetProlongationMatrix(); }
996
997 /// Get the input finite element space restriction matrix
998 const Operator *GetRestriction() const override
999 { return trial_fes->GetRestrictionMatrix(); }
1000
1001 /// Get the test finite element space prolongation matrix
1002 const Operator *GetOutputProlongation() const override
1003 { return test_fes->GetProlongationMatrix(); }
1004
1005 /// Get the test finite element space restriction matrix
1006 const Operator *GetOutputRestriction() const override
1007 { return test_fes->GetRestrictionMatrix(); }
1008
1009 /** @brief For partially conforming trial and/or test FE spaces, complete the
1010 assembly process by performing $ P2^t A P1 $ where $ A $ is the
1011 internal sparse matrix; $ P1 $ and $ P2 $ are the conforming
1012 prolongation matrices of the trial and test FE spaces, respectively.
1013 After this call the MixedBilinearForm becomes an operator on the
1014 conforming FE spaces. */
1015 void ConformingAssemble();
1016
1017 /// Compute the element matrix of the given element
1018 void ComputeElementMatrix(int i, DenseMatrix &elmat) const;
1019
1020 /// Compute the boundary element matrix of the given boundary element
1021 /** @note The boundary attribute markers of the integrators are ignored. */
1022 void ComputeBdrElementMatrix(int i, DenseMatrix &elmat) const;
1023
1024 /// Compute the trace face matrix of the given face element
1025 void ComputeTraceFaceMatrix(int i, DenseMatrix &elmat) const;
1026
1027 /// Compute the boundary trace face matrix of the given boundary element
1028 /** @note The boundary attribute markers of the integrators are ignored. */
1029 void ComputeBdrTraceFaceMatrix(int i, DenseMatrix &elmat) const;
1030
1031 /// Compute the face matrix of the given face element
1032 void ComputeFaceMatrix(int i, DenseMatrix &elmat) const;
1033
1034 /// Compute the boundary face matrix of the given boundary element
1035 /** @note The boundary attribute markers of the integrators are ignored. */
1036 void ComputeBdrFaceMatrix(int i, DenseMatrix &elmat) const;
1037
1038 /// Assemble the given element matrix
1039 /** The element matrix @a elmat is assembled for the element @a i, i.e.
1040 added to the system matrix. The flag @a skip_zeros skips the zero
1041 elements of the matrix, unless they are breaking the symmetry of
1042 the system matrix.
1043 */
1044 void AssembleElementMatrix(int i, const DenseMatrix &elmat,
1045 int skip_zeros = 1);
1046
1047 /// Assemble the given element matrix
1048 /** The element matrix @a elmat is assembled for the element @a i, i.e.
1049 added to the system matrix. The vdofs of the element are returned
1050 in @a trial_vdofs and @a test_vdofs. The flag @a skip_zeros skips
1051 the zero elements of the matrix, unless they are breaking the symmetry
1052 of the system matrix.
1053 */
1054 void AssembleElementMatrix(int i, const DenseMatrix &elmat,
1056 int skip_zeros = 1);
1057
1058 /// Assemble the given boundary element matrix
1059 /** The boundary element matrix @a elmat is assembled for the boundary
1060 element @a i, i.e. added to the system matrix. The flag @a skip_zeros
1061 skips the zero elements of the matrix, unless they are breaking the
1062 symmetry of the system matrix.
1063 */
1064 void AssembleBdrElementMatrix(int i, const DenseMatrix &elmat,
1065 int skip_zeros = 1);
1066
1067 /// Assemble the given boundary element matrix
1068 /** The boundary element matrix @a elmat is assembled for the boundary
1069 element @a i, i.e. added to the system matrix. The vdofs of the element
1070 are returned in @a trial_vdofs and @a test_vdofs. The flag @a skip_zeros
1071 skips the zero elements of the matrix, unless they are breaking the
1072 symmetry of the system matrix.*/
1073 void AssembleBdrElementMatrix(int i, const DenseMatrix &elmat,
1076 int skip_zeros = 1);
1077
1078 /// Eliminate essential boundary trial DOFs from the system.
1079 /** The array @a bdr_attr_is_ess marks boundary attributes that constitute
1080 the essential part of the boundary. */
1081 void EliminateTrialEssentialBC(const Array<int> &bdr_attr_is_ess,
1082 const Vector &sol, Vector &rhs);
1083
1084 /// Eliminate essential boundary trial DOFs from the system matrix.
1085 /** The array @a bdr_attr_is_ess marks boundary attributes that constitute
1086 the essential part of the boundary. */
1087 void EliminateTrialEssentialBC(const Array<int> &bdr_attr_is_ess);
1088
1089 /// (DEPRECATED) Eliminate essential boundary trial DOFs from the system.
1090 /** @see EliminateTrialEssentialBC() */
1091 MFEM_DEPRECATED void EliminateTrialDofs(const Array<int> &bdr_attr_is_ess,
1092 const Vector &sol, Vector &rhs)
1093 { EliminateTrialEssentialBC(bdr_attr_is_ess, sol, rhs); }
1094
1095 /// Eliminate the given trial @a vdofs. NOTE: here, @a vdofs is a list of DOFs.
1096 /** In this case the eliminations are applied to the internal $ M $
1097 and @a rhs without storing the elimination matrix $ M_e $. */
1098 void EliminateTrialVDofs(const Array<int> &vdofs, const Vector &sol,
1099 Vector &rhs);
1100
1101 /// Eliminate the given trial @a vdofs, storing the eliminated part internally in $ M_e $.
1102 /** This method works in conjunction with EliminateTrialVDofsInRHS() and allows
1103 elimination of boundary conditions in multiple right-hand sides. In this
1104 method, @a vdofs is a list of DOFs. */
1105 void EliminateTrialVDofs(const Array<int> &vdofs);
1106
1107 /** @brief Use the stored eliminated part of the matrix (see
1108 EliminateTrialVDofs(const Array<int> &)) to modify the r.h.s.
1109 @a b; @a vdofs is a list of DOFs (non-directional, i.e. >= 0). */
1110 void EliminateTrialVDofsInRHS(const Array<int> &vdofs, const Vector &x,
1111 Vector &b);
1112
1113 /** @brief Similar to
1114 EliminateTrialVDofs(const Array<int> &, const Vector &, Vector &)
1115 but here @a ess_dofs is a marker (boolean) array on all vector-dofs
1116 (@a ess_dofs[i] < 0 is true). */
1117 void EliminateEssentialBCFromTrialDofs(const Array<int> &marked_vdofs,
1118 const Vector &sol, Vector &rhs);
1119
1120 /// Eliminate essential boundary test DOFs from the system matrix.
1121 /** The array @a bdr_attr_is_ess marks boundary attributes that constitute
1122 the essential part of the boundary. */
1123 void EliminateTestEssentialBC(const Array<int> &bdr_attr_is_ess);
1124
1125 /// (DEPRECATED) Eliminate essential boundary test DOFs from the system.
1126 /** @see EliminateTestEssentialBC() */
1127 MFEM_DEPRECATED virtual void EliminateTestDofs(const Array<int>
1128 &bdr_attr_is_ess)
1129 { EliminateTestEssentialBC(bdr_attr_is_ess); }
1130
1131 /// Eliminate the given test @a vdofs. NOTE: here, @a vdofs is a list of DOFs.
1132 void EliminateTestVDofs(const Array<int> &vdofs);
1133
1134 /** @brief Return in @a A that is column-constrained.
1135
1136 This returns the same operator as FormRectangularLinearSystem(), but does
1137 without the transformations of the right-hand side. */
1138 virtual void FormRectangularSystemMatrix(const Array<int> &trial_tdof_list,
1139 const Array<int> &test_tdof_list,
1140 OperatorHandle &A);
1141
1142 /** @brief Form the column-constrained linear system matrix A.
1143
1144 Version of the method FormRectangularSystemMatrix() where the system
1145 matrix is returned in the variable @a A, of type OpType, holding a
1146 *reference* to the system matrix (created with the method
1147 OpType::MakeRef()). The reference will be invalidated when
1148 SetOperatorType(), Update(), or the destructor is called. */
1149 template <typename OpType>
1150 void FormRectangularSystemMatrix(const Array<int> &trial_tdof_list,
1151 const Array<int> &test_tdof_list, OpType &A)
1152 {
1153 OperatorHandle Ah;
1154 FormRectangularSystemMatrix(trial_tdof_list, test_tdof_list, Ah);
1155 OpType *A_ptr = Ah.Is<OpType>();
1156 MFEM_VERIFY(A_ptr, "invalid OpType used");
1157 A.MakeRef(*A_ptr);
1158 }
1159
1160 /** @brief Form the linear system A X = B, corresponding to this mixed
1161 bilinear form and the linear form @a b(.).
1162
1163 Return in @a A a *reference* to the system matrix that is
1164 column-constrained. The reference will be invalidated when
1165 SetOperatorType(), Update(), or the destructor is called. */
1166 virtual void FormRectangularLinearSystem(const Array<int> &trial_tdof_list,
1167 const Array<int> &test_tdof_list,
1168 Vector &x, Vector &b,
1169 OperatorHandle &A, Vector &X,
1170 Vector &B);
1171
1172 /** @brief Form the linear system A X = B, corresponding to this bilinear
1173 form and the linear form @a b(.).
1174
1175 Version of the method FormRectangularLinearSystem() where the system
1176 matrix is returned in the variable @a A, of type OpType, holding a
1177 *reference* to the system matrix (created with the method
1178 OpType::MakeRef()). The reference will be invalidated when
1179 SetOperatorType(), Update(), or the destructor is called. */
1180 template <typename OpType>
1181 void FormRectangularLinearSystem(const Array<int> &trial_tdof_list,
1182 const Array<int> &test_tdof_list,
1183 Vector &x, Vector &b,
1184 OpType &A, Vector &X, Vector &B)
1185 {
1186 OperatorHandle Ah;
1187 FormRectangularLinearSystem(trial_tdof_list, test_tdof_list, x, b,
1188 Ah, X, B);
1189 OpType *A_ptr = Ah.Is<OpType>();
1190 MFEM_VERIFY(A_ptr, "invalid OpType used");
1191 A.MakeRef(*A_ptr);
1192 }
1193
1194 /// Must be called after making changes to #trial_fes or #test_fes.
1195 void Update();
1196
1197 /// Return the trial FE space associated with the BilinearForm.
1199
1200 /// Read-only access to the associated trial FiniteElementSpace.
1201 const FiniteElementSpace *TrialFESpace() const { return trial_fes; }
1202
1203 /// Return the test FE space associated with the BilinearForm.
1205
1206 /// Read-only access to the associated test FiniteElementSpace.
1207 const FiniteElementSpace *TestFESpace() const { return test_fes; }
1208
1209 /// Prints operator to stream os.
1210 void Print(std::ostream & os = mfem::out, int width_ = 4) const override
1211 {
1212 MFEM_VERIFY(mat, "mat is NULL and can't be dereferenced");
1213 mat->Print(os, width_);
1214 }
1215
1216 /** @brief Deletes internal matrices, bilinear integrators, and the
1217 BilinearFormExtension */
1218 virtual ~MixedBilinearForm();
1219};
1220
1221
1222/**
1223 Class for constructing the matrix representation of a linear operator,
1224 `v = L u`, from one FiniteElementSpace (domain) to another FiniteElementSpace
1225 (range). The constructed matrix `A` is such that
1226
1227 V = A U
1228
1229 where `U` and `V` are the vectors of degrees of freedom representing the
1230 functions `u` and `v`, respectively. The dimensions of `A` are
1231
1232 number of rows of A = dimension of the range space and
1233 number of cols of A = dimension of the domain space.
1234
1235 This class is very similar to MixedBilinearForm. One difference is that
1236 the linear operator `L` is defined using a special kind of
1237 BilinearFormIntegrator (we reuse its functionality instead of defining a
1238 new class). The other difference with the MixedBilinearForm class is that
1239 the "assembly" process overwrites the global matrix entries using the
1240 local element matrices instead of adding them.
1241
1242 Note that if we define the bilinear form `b(u,v) := (Lu,v)` using an inner
1243 product in the range space, then its matrix representation, `B`, is
1244
1245 B = M A, (since V^t B U = b(u,v) = (Lu,v) = V^t M A U)
1246
1247 where `M` denotes the mass matrix for the inner product in the range space:
1248 `V1^t M V2 = (v1,v2)`. Similarly, if `c(u,w) := (Lu,Lw)` then
1249
1250 C = A^t M A.
1251*/
1253{
1254private:
1255 /// Copy construction is not supported; body is undefined.
1257
1258 /// Copy assignment is not supported; body is undefined.
1260
1261public:
1262 /** @brief Construct a DiscreteLinearOperator on the given
1263 FiniteElementSpace%s @a domain_fes and @a range_fes. */
1264 /** The pointers @a domain_fes and @a range_fes are not owned by the newly
1265 constructed object. */
1267 FiniteElementSpace *range_fes)
1268 : MixedBilinearForm(domain_fes, range_fes) { }
1269
1270 /// Adds a domain interpolator. Assumes ownership of @a di.
1274 Array<int> &elem_marker)
1275 { AddDomainIntegrator(di, elem_marker); }
1276
1277 /// Adds a trace face interpolator. Assumes ownership of @a di.
1280
1281 /// Access all interpolators added with AddDomainInterpolator().
1284
1285 /// Set the desired assembly level. The default is AssemblyLevel::FULL.
1286 /** This method must be called before assembly. */
1287 void SetAssemblyLevel(AssemblyLevel assembly_level);
1288
1289 /** @brief Construct the internal matrix representation of the discrete
1290 linear operator. */
1291 virtual void Assemble(int skip_zeros = 1);
1292
1293 /** @brief Get the output finite element space restriction matrix in
1294 transposed form. */
1297};
1298
1299}
1300
1301#endif
Dynamic 2D array using row-major layout.
Definition array.hpp:459
Abstract base class BilinearFormIntegrator.
A "square matrix" operator for the associated FE space and BLFIntegrators The sum of all the BLFInteg...
void AssembleDiagonal(Vector &diag) const override
Assemble the diagonal of the bilinear form into diag. Note that diag is a tdof Vector.
void SetAssemblyLevel(AssemblyLevel assembly_level)
Set the desired assembly level.
void AllocateMatrix()
Pre-allocate the internal SparseMatrix before assembly. If the internal flag precompute_sparsity is s...
void SetDiagonalPolicy(DiagonalPolicy policy)
Sets Operator::DiagonalPolicy used upon construction of the linear system. Policies include:
Array< BilinearFormIntegrator * > domain_integs
Set of Domain Integrators to be applied.
Array< Array< int > * > domain_integs_marker
Entries are not owned.
void EnableStaticCondensation()
Enable the use of static condensation. For details see the description for class StaticCondensation i...
void UsePrecomputedSparsity(int ps=1)
For scalar FE spaces, precompute the sparsity pattern of the matrix (assuming dense element matrices)...
void AssembleBdrElementMatrix(int i, const DenseMatrix &elmat, int skip_zeros=1)
Assemble the given boundary element matrix.
Array< Array< int > * > boundary_face_integs_marker
Entries are not owned.
bool HasSpMatElim()
Returns true if the sparse matrix of eliminated b.c.s is not null, false otherwise.
void UseSparsity(int *I, int *J, bool isSorted)
Use the given CSR sparsity pattern to allocate the internal SparseMatrix.
void EliminateVDofsInRHS(const Array< int > &vdofs, const Vector &x, Vector &b)
Use the stored eliminated part of the matrix (see EliminateVDofs(const Array<int> &,...
void FullAddMult(const Vector &x, Vector &y) const
Add the original uneliminated matrix vector multiple to a vector. The original matrix is so we have:...
void FullMult(const Vector &x, Vector &y) const
Matrix vector multiplication with the original uneliminated matrix. The original matrix is so we hav...
void AddDomainIntegrator(BilinearFormIntegrator *bfi)
Adds new Domain Integrator. Assumes ownership of bfi.
void ComputeElementMatrices()
Compute and store internally all element matrices.
Array< BilinearFormIntegrator * > boundary_face_integs
Set of boundary face Integrators to be applied.
Array< BilinearFormIntegrator * > * GetFBFI()
Access all integrators added with AddInteriorFaceIntegrator().
virtual void Update(FiniteElementSpace *nfes=NULL)
Update the FiniteElementSpace and delete all data associated with the old one.
void AddMultTranspose(const Vector &x, Vector &y, const real_t a=1.0) const override
Add the matrix transpose vector multiplication: .
void ComputeFaceMatrix(int i, DenseMatrix &elmat) const
Compute the face matrix of the given face element.
void EliminateVDofs(const Array< int > &vdofs, const Vector &sol, Vector &rhs, DiagonalPolicy dpolicy=DIAG_ONE)
Eliminate the given vdofs. NOTE: here, vdofs is a list of DOFs.
Array< BilinearFormIntegrator * > * GetDBFI()
Access all the integrators added with AddDomainIntegrator().
void FreeElementMatrices()
Free the memory used by the element matrices.
const Operator * GetOutputProlongation() const override
Get the output finite element space prolongation matrix.
void Finalize(int skip_zeros=1) override
Finalizes the matrix initialization if the AssemblyLevel is AssemblyLevel::LEGACY....
virtual ~BilinearForm()
Deletes internal matrices, bilinear integrators, and the BilinearFormExtension.
BilinearForm()
may be used in the construction of derived classes
void EliminateEssentialBCFromDofsDiag(const Array< int > &ess_dofs, real_t value)
Perform elimination and set the diagonal entry to the given value.
DiagonalPolicy diag_policy
This data member allows one to specify what should be done to the diagonal matrix entries and corresp...
void ComputeBdrFaceMatrix(int i, DenseMatrix &elmat) const
Compute the boundary face matrix of the given boundary element.
void EnableSparseMatrixSorting(bool enable_it)
Force the sparse matrix column indices to be sorted when using AssemblyLevel::FULL.
FiniteElementSpace * FESpace()
Return the FE space associated with the BilinearForm.
void AddBoundaryIntegrator(BilinearFormIntegrator *bfi)
Adds new Boundary Integrator. Assumes ownership of bfi.
const FiniteElementSpace * FESpace() const
Read-only access to the associated FiniteElementSpace.
void FullAddMultTranspose(const Vector &x, Vector &y) const
Add the original uneliminated matrix transpose vector multiple to a vector. The original matrix is s...
void Print(std::ostream &os=mfem::out, int width_=4) const override
Prints operator to stream os.
void AllocMat()
Allocate appropriate SparseMatrix and assign it to mat.
void AddMult(const Vector &x, Vector &y, const real_t a=1.0) const override
Add the matrix vector multiple to a vector: .
void Assemble(int skip_zeros=1)
Assembles the form i.e. sums over all domain/bdr integrators.
AssemblyLevel GetAssemblyLevel() const
Returns the assembly level.
real_t FullInnerProduct(const Vector &x, const Vector &y) const
Compute inner product for full uneliminated matrix: .
real_t InnerProduct(const Vector &x, const Vector &y) const
Compute .
const real_t & operator()(int i, int j)
Returns a reference to: .
void operator=(const real_t a)
Sets all sparse values of and to 'a'.
SparseMatrix & SpMatElim()
Returns a reference to the sparse matrix of eliminated b.c.: .
SparseMatrix * LoseMat()
Nullifies the internal matrix and returns a pointer to it. Used for transferring ownership.
bool HasSpMat()
Returns true if the sparse matrix is not null, false otherwise.
void EnableHybridization(FiniteElementSpace *constr_space, BilinearFormIntegrator *constr_integ, const Array< int > &ess_tdof_list)
Enable hybridization.
real_t & Elem(int i, int j) override
Returns a reference to: .
int extern_bfs
Indicates the BilinearFormIntegrators stored in domain_integs, boundary_integs, interior_face_integs,...
void AddBdrFaceIntegrator(BilinearFormIntegrator *bfi)
Adds new boundary Face Integrator. Assumes ownership of bfi.
const SparseMatrix & SpMatElim() const
Returns a const reference to the sparse matrix of eliminated b.c.: .
void AssembleElementMatrix(int i, const DenseMatrix &elmat, int skip_zeros=1)
Assemble the given element matrix.
void FormSystemMatrix(const Array< int > &ess_tdof_list, OpType &A)
Form the linear system matrix A, see FormLinearSystem() for details.
SparseMatrix & SpMat()
Returns a reference to the sparse matrix: .
Array< BilinearFormIntegrator * > * GetBBFI()
Access all the integrators added with AddBoundaryIntegrator().
Array< Array< int > * > boundary_integs_marker
Entries are not owned.
long sequence
Indicates the Mesh::sequence corresponding to the current state of the BilinearForm.
Array< BilinearFormIntegrator * > interior_face_integs
Set of interior face Integrators to be applied.
Array< Array< int > * > * GetBBFI_Marker()
Access all boundary markers added with AddBoundaryIntegrator(). If no marker was specified when the i...
void EliminateEssentialBCFromDofs(const Array< int > &ess_dofs, const Vector &sol, Vector &rhs, DiagonalPolicy dpolicy=DIAG_ONE)
Similar to EliminateVDofs(const Array<int> &, const Vector &, Vector &,...
SparseMatrix * mat
Sparse matrix to be associated with the form. Owned.
AssemblyLevel assembly
The AssemblyLevel of the form (AssemblyLevel::LEGACY, AssemblyLevel::FULL, AssemblyLevel::ELEMENT,...
void MultTranspose(const Vector &x, Vector &y) const override
Matrix transpose vector multiplication: .
std::unique_ptr< StaticCondensation > static_cond
const DenseTensor & GetElementMatrices()
Return a DenseTensor containing the assembled element matrices.
const Operator * GetRestriction() const override
Get the finite element space restriction operator.
void RecoverFEMSolution(const Vector &X, const Vector &b, Vector &x) override
Recover the solution of a linear system formed with FormLinearSystem().
const Operator * GetProlongation() const override
Get the finite element space prolongation operator.
void SerialRAP(OperatorHandle &A)
Compute serial RAP operator and store it in A as a SparseMatrix.
FiniteElementSpace * SCFESpace() const
Return the trace FE space associated with static condensation.
Array< BilinearFormIntegrator * > * GetBFBFI()
Access all integrators added with AddBdrFaceIntegrator().
std::unique_ptr< DenseTensor > element_matrices
FiniteElementSpace * fes
FE space on which the form lives. Not owned.
int batch
Element batch size used in the form action (1, 8, num_elems, etc.)
virtual void FormLinearSystem(const Array< int > &ess_tdof_list, Vector &x, Vector &b, OperatorHandle &A, Vector &X, Vector &B, int copy_interior=0)
Form the linear system A X = B, corresponding to this bilinear form and the linear form b(....
bool StaticCondensationIsEnabled() const
Check if static condensation was actually enabled by a previous call to EnableStaticCondensation().
void UseExternalIntegrators()
Indicate that integrators are not owned by the BilinearForm.
void ComputeElementMatrix(int i, DenseMatrix &elmat) const
Compute the element matrix of the given element.
int Size() const
Get the size of the BilinearForm as a square matrix.
const Operator * GetOutputRestriction() const override
Get the output finite element space restriction matrix.
void Mult(const Vector &x, Vector &y) const override
Matrix vector multiplication: .
MFEM_DEPRECATED FiniteElementSpace * GetFES()
(DEPRECATED) Return the FE space associated with the BilinearForm.
std::unique_ptr< BilinearFormExtension > ext
Extension for supporting Full Assembly (FA), Element Assembly (EA),Partial Assembly (PA),...
MatrixInverse * Inverse() const override
Returns a pointer to (approximation) of the matrix inverse: (currently returns NULL)
Hybridization * GetHybridization() const
Array< Array< int > * > * GetBFBFI_Marker()
Access all boundary markers added with AddBdrFaceIntegrator(). If no marker was specified when the in...
void EliminateEssentialBC(const Array< int > &bdr_attr_is_ess, const Vector &sol, Vector &rhs, DiagonalPolicy dpolicy=DIAG_ONE)
Eliminate essential boundary DOFs from the system.
void ConformingAssemble()
For partially conforming trial and/or test FE spaces, complete the assembly process by performing wh...
Array< BilinearFormIntegrator * > boundary_integs
Set of Boundary Integrators to be applied.
std::unique_ptr< Hybridization > hybridization
void FormLinearSystem(const Array< int > &ess_tdof_list, Vector &x, Vector &b, OpType &A, Vector &X, Vector &B, int copy_interior=0)
Form the linear system A X = B, corresponding to this bilinear form and the linear form b(....
void EliminateEssentialBCDiag(const Array< int > &bdr_attr_is_ess, real_t value)
Perform elimination and set the diagonal entry to the given value.
virtual void FormSystemMatrix(const Array< int > &ess_tdof_list, OperatorHandle &A)
Form the linear system matrix A, see FormLinearSystem() for details.
const Operator * GetOutputRestrictionTranspose() const override
Returns the output fe space restriction matrix, transposed.
Array< Array< int > * > * GetDBFI_Marker()
Access all boundary markers added with AddDomainIntegrator(). If no marker was specified when the int...
const SparseMatrix & SpMat() const
Returns a const reference to the sparse matrix: .
void ComputeBdrElementMatrix(int i, DenseMatrix &elmat) const
Compute the boundary element matrix of the given boundary element.
SparseMatrix * mat_e
Sparse Matrix used to store the eliminations from the b.c. Owned. .
void AddInteriorFaceIntegrator(BilinearFormIntegrator *bfi)
Adds new interior Face Integrator. Assumes ownership of bfi.
Data type dense matrix using column-major storage.
Definition densemat.hpp:24
Rank 3 tensor (array of matrices)
void AddDomainInterpolator(DiscreteInterpolator *di, Array< int > &elem_marker)
void AddDomainInterpolator(DiscreteInterpolator *di)
Adds a domain interpolator. Assumes ownership of di.
void AddTraceFaceInterpolator(DiscreteInterpolator *di)
Adds a trace face interpolator. Assumes ownership of di.
virtual void Assemble(int skip_zeros=1)
Construct the internal matrix representation of the discrete linear operator.
Array< Array< int > * > * GetDI_Marker()
DiscreteLinearOperator(FiniteElementSpace *domain_fes, FiniteElementSpace *range_fes)
Construct a DiscreteLinearOperator on the given FiniteElementSpaces domain_fes and range_fes.
Array< BilinearFormIntegrator * > * GetDI()
Access all interpolators added with AddDomainInterpolator().
const Operator * GetOutputRestrictionTranspose() const override
Get the output finite element space restriction matrix in transposed form.
void SetAssemblyLevel(AssemblyLevel assembly_level)
Set the desired assembly level. The default is AssemblyLevel::FULL.
Data and methods for fully-assembled bilinear forms.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:210
const SparseMatrix * GetConformingRestriction() const
The returned SparseMatrix is owned by the FiniteElementSpace.
Definition fespace.cpp:1429
virtual const SparseMatrix * GetRestrictionMatrix() const
The returned SparseMatrix is owned by the FiniteElementSpace.
Definition fespace.hpp:714
virtual const Operator * GetProlongationMatrix() const
Definition fespace.hpp:691
const Operator * GetRestrictionTransposeOperator() const
Return an operator that performs the transpose of GetRestrictionOperator.
Definition fespace.cpp:1444
const SparseMatrix * GetConformingProlongation() const
Definition fespace.cpp:1422
Auxiliary class Hybridization, used to implement BilinearForm hybridization.
Abstract data type for matrix inverse.
Definition matrix.hpp:63
Abstract data type matrix.
Definition matrix.hpp:28
const FiniteElementSpace * TrialFESpace() const
Read-only access to the associated trial FiniteElementSpace.
void AddBdrFaceIntegrator(BilinearFormIntegrator *bfi)
Adds a boundary face integrator. Assumes ownership of bfi.
void ConformingAssemble()
For partially conforming trial and/or test FE spaces, complete the assembly process by performing wh...
void AssembleBdrElementMatrix(int i, const DenseMatrix &elmat, int skip_zeros=1)
Assemble the given boundary element matrix.
const FiniteElementSpace * TestFESpace() const
Read-only access to the associated test FiniteElementSpace.
SparseMatrix & SpMat()
Returns a reference to the sparse matrix: .
void AddMult(const Vector &x, Vector &y, const real_t a=1.0) const override
Add the matrix vector multiple to a vector: .
void AddMultTranspose(const Vector &x, Vector &y, const real_t a=1.0) const override
Add the matrix transpose vector multiplication: .
Array< BilinearFormIntegrator * > * GetBFBFI()
Access all integrators added with AddBdrFaceIntegrator().
Array< BilinearFormIntegrator * > boundary_face_integs
Boundary face integrators.
void EliminateTrialVDofsInRHS(const Array< int > &vdofs, const Vector &x, Vector &b)
Use the stored eliminated part of the matrix (see EliminateTrialVDofs(const Array<int> &)) to modify ...
void Assemble(int skip_zeros=1)
real_t & Elem(int i, int j) override
Returns a reference to: .
void Finalize(int skip_zeros=1) override
Finalizes the matrix initialization if the AssemblyLevel is AssemblyLevel::LEGACY.
void AddBoundaryIntegrator(BilinearFormIntegrator *bfi)
Adds a boundary integrator. Assumes ownership of bfi.
Array< Array< int > * > * GetBFBFI_Marker()
Access all boundary markers added with AddBdrFaceIntegrator(). If no marker was specified when the in...
SparseMatrix & SpMatElim()
Returns a reference to the sparse matrix of eliminated b.c.: .
void AddInteriorFaceIntegrator(BilinearFormIntegrator *bfi)
Adds an interior face integrator. Assumes ownership of bfi.
virtual void FormRectangularSystemMatrix(const Array< int > &trial_tdof_list, const Array< int > &test_tdof_list, OperatorHandle &A)
Return in A that is column-constrained.
void ComputeFaceMatrix(int i, DenseMatrix &elmat) const
Compute the face matrix of the given face element.
void Print(std::ostream &os=mfem::out, int width_=4) const override
Prints operator to stream os.
void ComputeBdrTraceFaceMatrix(int i, DenseMatrix &elmat) const
Compute the boundary trace face matrix of the given boundary element.
Array< BilinearFormIntegrator * > * GetTFBFI()
Access all integrators added with AddTraceFaceIntegrator().
void MultTranspose(const Vector &x, Vector &y) const override
Matrix transpose vector multiplication: .
void ComputeElementMatrix(int i, DenseMatrix &elmat) const
Compute the element matrix of the given element.
Array< Array< int > * > boundary_face_integs_marker
Entries are not owned.
void SetAssemblyLevel(AssemblyLevel assembly_level)
Set the desired assembly level. The default is AssemblyLevel::LEGACY.
int extern_bfs
Indicates the BilinearFormIntegrators stored in MixedBilinearForm::domain_integs, MixedBilinearForm::...
MatrixInverse * Inverse() const override
Returns a pointer to (approximation) of the matrix inverse: (currently unimplemented and returns NUL...
void EliminateTrialVDofs(const Array< int > &vdofs, const Vector &sol, Vector &rhs)
Eliminate the given trial vdofs. NOTE: here, vdofs is a list of DOFs.
void AssembleDiagonal_ADAt(const Vector &D, Vector &diag) const
Assemble the diagonal of ADA^T into diag, where A is this mixed bilinear form and D is a diagonal.
const Operator * GetOutputProlongation() const override
Get the test finite element space prolongation matrix.
Array< BilinearFormIntegrator * > interior_face_integs
Interior face integrators.
const Operator * GetOutputRestriction() const override
Get the test finite element space restriction matrix.
void ComputeTraceFaceMatrix(int i, DenseMatrix &elmat) const
Compute the trace face matrix of the given face element.
void EliminateTrialEssentialBC(const Array< int > &bdr_attr_is_ess, const Vector &sol, Vector &rhs)
Eliminate essential boundary trial DOFs from the system.
Array< BilinearFormIntegrator * > * GetBBFI()
Access all integrators added with AddBoundaryIntegrator().
void AddBdrTraceFaceIntegrator(BilinearFormIntegrator *bfi)
Adds a boundary trace face integrator. Assumes ownership of bfi.
virtual MFEM_DEPRECATED void EliminateTestDofs(const Array< int > &bdr_attr_is_ess)
(DEPRECATED) Eliminate essential boundary test DOFs from the system.
Array< Array< int > * > boundary_integs_marker
Entries are not owned.
Array< BilinearFormIntegrator * > trace_face_integs
Trace face (skeleton) integrators.
FiniteElementSpace * TestFESpace()
Return the test FE space associated with the BilinearForm.
Array< BilinearFormIntegrator * > boundary_trace_face_integs
Boundary trace face (skeleton) integrators.
const Operator * GetRestriction() const override
Get the input finite element space restriction matrix.
Array< BilinearFormIntegrator * > domain_integs
Domain integrators.
SparseMatrix * LoseMat()
Nullifies the internal matrix and returns a pointer to it. Used for transferring ownership.
SparseMatrix * mat
Owned.
void Update()
Must be called after making changes to trial_fes or test_fes.
Array< Array< int > * > * GetBTFBFI_Marker()
Access all boundary markers added with AddBdrTraceFaceIntegrator()
Array< Array< int > * > domain_integs_marker
Entries are not owned.
const Operator * GetProlongation() const override
Get the input finite element space prolongation matrix.
void ComputeBdrFaceMatrix(int i, DenseMatrix &elmat) const
Compute the boundary face matrix of the given boundary element.
Array< BilinearFormIntegrator * > boundary_integs
Boundary integrators.
void EliminateEssentialBCFromTrialDofs(const Array< int > &marked_vdofs, const Vector &sol, Vector &rhs)
Similar to EliminateTrialVDofs(const Array<int> &, const Vector &, Vector &) but here ess_dofs is a m...
void AssembleElementMatrix(int i, const DenseMatrix &elmat, int skip_zeros=1)
Assemble the given element matrix.
Array< Array< int > * > boundary_trace_face_integs_marker
Entries are not owned.
virtual void FormRectangularLinearSystem(const Array< int > &trial_tdof_list, const Array< int > &test_tdof_list, Vector &x, Vector &b, OperatorHandle &A, Vector &X, Vector &B)
Form the linear system A X = B, corresponding to this mixed bilinear form and the linear form b(....
const SparseMatrix & SpMat() const
Returns a const reference to the sparse matrix: .
MFEM_DEPRECATED void EliminateTrialDofs(const Array< int > &bdr_attr_is_ess, const Vector &sol, Vector &rhs)
(DEPRECATED) Eliminate essential boundary trial DOFs from the system.
void FormRectangularSystemMatrix(const Array< int > &trial_tdof_list, const Array< int > &test_tdof_list, OpType &A)
Form the column-constrained linear system matrix A.
SparseMatrix * mat_e
Owned.
FiniteElementSpace * trial_fes
Not owned.
void GetBlocks(Array2D< SparseMatrix * > &blocks) const
Extract the associated matrix as SparseMatrix blocks. The number of block rows and columns is given b...
std::unique_ptr< MixedBilinearFormExtension > ext
FiniteElementSpace * TrialFESpace()
Return the trial FE space associated with the BilinearForm.
void EliminateTestEssentialBC(const Array< int > &bdr_attr_is_ess)
Eliminate essential boundary test DOFs from the system matrix.
Array< BilinearFormIntegrator * > * GetDBFI()
Access all integrators added with AddDomainIntegrator().
Array< Array< int > * > * GetBBFI_Marker()
Access all boundary markers added with AddBoundaryIntegrator().
void AddTraceFaceIntegrator(BilinearFormIntegrator *bfi)
Add a trace face integrator. Assumes ownership of bfi.
void EliminateTestVDofs(const Array< int > &vdofs)
Eliminate the given test vdofs. NOTE: here, vdofs is a list of DOFs.
void operator=(const real_t a)
Sets all sparse values of to a.
const SparseMatrix & SpMatElim() const
Returns a const reference to the sparse matrix of eliminated b.c.: .
void Mult(const Vector &x, Vector &y) const override
Matrix multiplication: .
Array< Array< int > * > * GetDBFI_Marker()
Access all domain markers added with AddDomainIntegrator(). If no marker was specified when the integ...
Array< BilinearFormIntegrator * > * GetBTFBFI()
Access all integrators added with AddBdrTraceFaceIntegrator().
virtual ~MixedBilinearForm()
Deletes internal matrices, bilinear integrators, and the BilinearFormExtension.
FiniteElementSpace * test_fes
Not owned.
Array< BilinearFormIntegrator * > * GetFBFI()
Access all integrators added with AddInteriorFaceIntegrator().
void AddDomainIntegrator(BilinearFormIntegrator *bfi)
Adds a domain integrator. Assumes ownership of bfi.
AssemblyLevel assembly
The form assembly level (full, partial, etc.)
void ComputeBdrElementMatrix(int i, DenseMatrix &elmat) const
Compute the boundary element matrix of the given boundary element.
void FormRectangularLinearSystem(const Array< int > &trial_tdof_list, const Array< int > &test_tdof_list, Vector &x, Vector &b, OpType &A, Vector &X, Vector &B)
Form the linear system A X = B, corresponding to this bilinear form and the linear form b(....
Pointer to an Operator of a specified type.
Definition handle.hpp:34
void Reset(OpType *A, bool own_A=true)
Reset the OperatorHandle to the given OpType pointer, A.
Definition handle.hpp:145
OpType * Is() const
Return the Operator pointer dynamically cast to a specified OpType.
Definition handle.hpp:108
Abstract operator.
Definition operator.hpp:27
int height
Dimension of the output / number of rows in the matrix.
Definition operator.hpp:29
DiagonalPolicy
Defines operator diagonal policy upon elimination of rows and/or columns.
Definition operator.hpp:50
@ DIAG_ONE
Set the diagonal value to one.
Definition operator.hpp:52
@ DIAG_KEEP
Keep the diagonal value.
Definition operator.hpp:53
Data type sparse matrix.
Definition sparsemat.hpp:51
void Print(std::ostream &out=mfem::out, int width_=4) const override
Prints matrix to stream out.
real_t InnerProduct(const Vector &x, const Vector &y) const
Compute y^t A x.
void AddMultTranspose(const Vector &x, Vector &y, const real_t a=1.0) const override
y += At * x (default) or y += a * At * x
void AddMult(const Vector &x, Vector &y, const real_t a=1.0) const override
y += A * x (default) or y += a * A * x
void Mult(const Vector &x, Vector &y) const override
Matrix vector multiplication.
Vector data type.
Definition vector.hpp:82
const int * ess_tdof_list
real_t b
Definition lissajous.cpp:42
real_t a
Definition lissajous.cpp:41
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
Definition globals.hpp:66
AssemblyLevel
Enumeration defining the assembly level for bilinear and nonlinear form classes derived from Operator...
float real_t
Definition config.hpp:46
std::function< real_t(const Vector &)> f(real_t mass_coeff)
Definition lor_mms.hpp:30
real_t sol(const Vector &x)