MFEM v4.8.0
Finite element discretization library
Loading...
Searching...
No Matches
bilinearform.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2025, 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,
237 const Array<int> &ess_tdof_list);
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, const real_t a = 1.0) const override
311 { mat -> AddMult (x, y, a); }
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 { mat->AddMultTranspose(x, y, a); }
323
324 /** @brief Add the original uneliminated matrix transpose vector
325 multiple to a vector. The original matrix is $ M + M_e $
326 so we have: $ y += M^T x + {M_e}^T x $ */
327 void FullAddMultTranspose(const Vector & x, Vector & y) const
328 { mat->AddMultTranspose(x, y); mat_e->AddMultTranspose(x, y); }
329
330 /// Matrix transpose vector multiplication: $ y = M^T x $
331 void MultTranspose(const Vector & x, Vector & y) const override;
332
333 /// Compute $ y^T M x $
334 real_t InnerProduct(const Vector &x, const Vector &y) const
335 { return mat->InnerProduct (x, y); }
336
337 /** @brief Returns a pointer to (approximation) of the matrix inverse:
338 $ M^{-1} $ (currently returns NULL) */
339 MatrixInverse *Inverse() const override;
340
341 /** @brief Finalizes the matrix initialization if the ::AssemblyLevel is
342 AssemblyLevel::LEGACY.
343 The matrix that gets finalized is different if you are using static
344 condensation or hybridization.*/
345 void Finalize(int skip_zeros = 1) override;
346
347 /** @brief Returns a const reference to the sparse matrix: $ M $
348 *
349 This will fail if HasSpMat() is false. */
350 const SparseMatrix &SpMat() const
351 {
352 MFEM_VERIFY(mat, "mat is NULL and can't be dereferenced");
353 return *mat;
354 }
355
356 /** @brief Returns a reference to the sparse matrix: $ M $
357 *
358 This will fail if HasSpMat() is false. */
360 {
361 MFEM_VERIFY(mat, "mat is NULL and can't be dereferenced");
362 return *mat;
363 }
364
365 /** @brief Returns true if the sparse matrix is not null, false otherwise.
366 *
367 @sa SpMat(). */
368 bool HasSpMat()
369 {
370 return mat != nullptr;
371 }
372
373
374 /** @brief Nullifies the internal matrix $ M $ and returns a pointer
375 to it. Used for transferring ownership. */
376 SparseMatrix *LoseMat() { SparseMatrix *tmp = mat; mat = NULL; return tmp; }
377
378 /** @brief Returns a const reference to the sparse matrix of eliminated b.c.:
379 $ M_e $
380
381 This will fail if HasSpMatElim() is false. */
382 const SparseMatrix &SpMatElim() const
383 {
384 MFEM_VERIFY(mat_e, "mat_e is NULL and can't be dereferenced");
385 return *mat_e;
386 }
387
388 /** @brief Returns a reference to the sparse matrix of eliminated b.c.:
389 $ M_e $
390
391 This will fail if HasSpMatElim() is false. */
393 {
394 MFEM_VERIFY(mat_e, "mat_e is NULL and can't be dereferenced");
395 return *mat_e;
396 }
397
398 /** @brief Returns true if the sparse matrix of eliminated b.c.s is not
399 null, false otherwise.
400
401 @sa SpMatElim(). */
403 {
404 return mat_e != nullptr;
405 }
406
407 /// Adds new Domain Integrator. Assumes ownership of @a bfi.
409
410 /// Adds new Domain Integrator restricted to certain elements specified by
411 /// the @a elem_attr_marker.
413 Array<int> &elem_marker);
414
415 /// Adds new Boundary Integrator. Assumes ownership of @a bfi.
417
418 /** @brief Adds new Boundary Integrator, restricted to specific boundary
419 attributes.
420
421 Assumes ownership of @a bfi. The array @a bdr_marker is stored internally
422 as a pointer to the given Array<int> object. */
424 Array<int> &bdr_marker);
425
426 /// Adds new interior Face Integrator. Assumes ownership of @a bfi.
428
429 /// Adds new boundary Face Integrator. Assumes ownership of @a bfi.
431
432 /** @brief Adds new boundary Face Integrator, restricted to specific boundary
433 attributes.
434
435 Assumes ownership of @a bfi. The array @a bdr_marker is stored internally
436 as a pointer to the given Array<int> object. */
438 Array<int> &bdr_marker);
439
440 /// Sets all sparse values of $ M $ and $ M_e $ to 'a'.
441 void operator=(const real_t a)
442 {
443 if (mat != NULL) { *mat = a; }
444 if (mat_e != NULL) { *mat_e = a; }
445 }
446
447 /// Assembles the form i.e. sums over all domain/bdr integrators.
448 void Assemble(int skip_zeros = 1);
449
450 /** @brief Assemble the diagonal of the bilinear form into @a diag. Note that
451 @a diag is a tdof Vector.
452
453 When the AssemblyLevel is not LEGACY, and the mesh has hanging nodes,
454 this method returns |P^T| d_l, where d_l is the diagonal of the form
455 before applying conforming assembly, P^T is the transpose of the
456 conforming prolongation, and |.| denotes the entry-wise absolute value.
457 In general, this is just an approximation of the exact diagonal for this
458 case. */
459 void AssembleDiagonal(Vector &diag) const override;
460
461 /// Get the finite element space prolongation operator.
462 const Operator *GetProlongation() const override
463 { return fes->GetConformingProlongation(); }
464
465 /// Get the finite element space restriction operator
466 const Operator *GetRestriction() const override
467 { return fes->GetConformingRestriction(); }
468
469 /// Get the output finite element space prolongation matrix
470 const Operator *GetOutputProlongation() const override
471 { return GetProlongation(); }
472
473 /** @brief Returns the output fe space restriction matrix, transposed
474
475 Logically, this is the transpose of GetOutputRestriction, but in
476 practice it is convenient to have it in transposed form for
477 construction of RAP operators in matrix-free methods. */
480
481 /// Get the output finite element space restriction matrix
482 const Operator *GetOutputRestriction() const override
483 { return GetRestriction(); }
484
485 /// Compute serial RAP operator and store it in @a A as a SparseMatrix.
487 {
488 MFEM_ASSERT(mat, "SerialRAP requires the SparseMatrix to be assembled.");
490 A.Reset(mat, false);
491 }
492
493 /** @brief Form the linear system A X = B, corresponding to this bilinear
494 form and the linear form @a b(.). */
495 /** This method applies any necessary transformations to the linear system
496 such as: eliminating boundary conditions; applying conforming constraints
497 for non-conforming AMR; parallel assembly; static condensation;
498 hybridization.
499
500 The GridFunction-size vector @a x must contain the essential b.c. The
501 BilinearForm and the LinearForm-size vector @a b must be assembled.
502
503 The vector @a X is initialized with a suitable initial guess: when using
504 hybridization, the vector @a X is set to zero; otherwise, the essential
505 entries of @a X are set to the corresponding b.c. and all other entries
506 are set to zero (@a copy_interior == 0) or copied from @a x
507 (@a copy_interior != 0).
508
509 This method can be called multiple times (with the same @a ess_tdof_list
510 array) to initialize different right-hand sides and boundary condition
511 values.
512
513 After solving the linear system, the finite element solution @a x can be
514 recovered by calling RecoverFEMSolution() (with the same vectors @a X,
515 @a b, and @a x).
516
517 NOTE: If there are no transformations, @a X simply reuses the data of
518 @a x. */
519 virtual void FormLinearSystem(const Array<int> &ess_tdof_list, Vector &x,
520 Vector &b, OperatorHandle &A, Vector &X,
521 Vector &B, int copy_interior = 0);
522
523 /** @brief Form the linear system A X = B, corresponding to this bilinear
524 form and the linear form @a b(.). */
525 /** Version of the method FormLinearSystem() where the system matrix is
526 returned in the variable @a A, of type OpType, holding a *reference* to
527 the system matrix (created with the method OpType::MakeRef()). The
528 reference will be invalidated when SetOperatorType(), Update(), or the
529 destructor is called. */
530 template <typename OpType>
531 void FormLinearSystem(const Array<int> &ess_tdof_list, Vector &x, Vector &b,
532 OpType &A, Vector &X, Vector &B,
533 int copy_interior = 0)
534 {
536 FormLinearSystem(ess_tdof_list, x, b, Ah, X, B, copy_interior);
537 OpType *A_ptr = Ah.Is<OpType>();
538 MFEM_VERIFY(A_ptr, "invalid OpType used");
539 A.MakeRef(*A_ptr);
540 }
541
542 /// Form the linear system matrix @a A, see FormLinearSystem() for details.
543 virtual void FormSystemMatrix(const Array<int> &ess_tdof_list,
544 OperatorHandle &A);
545
546 /// Form the linear system matrix A, see FormLinearSystem() for details.
547 /** Version of the method FormSystemMatrix() where the system matrix is
548 returned in the variable @a A, of type OpType, holding a *reference* to
549 the system matrix (created with the method OpType::MakeRef()). The
550 reference will be invalidated when SetOperatorType(), Update(), or the
551 destructor is called. */
552 template <typename OpType>
553 void FormSystemMatrix(const Array<int> &ess_tdof_list, OpType &A)
554 {
556 FormSystemMatrix(ess_tdof_list, Ah);
557 OpType *A_ptr = Ah.Is<OpType>();
558 MFEM_VERIFY(A_ptr, "invalid OpType used");
559 A.MakeRef(*A_ptr);
560 }
561
562 /// Recover the solution of a linear system formed with FormLinearSystem().
563 /** Call this method after solving a linear system constructed using the
564 FormLinearSystem() method to recover the solution as a GridFunction-size
565 vector in @a x. Use the same arguments as in the FormLinearSystem() call.
566 */
567 void RecoverFEMSolution(const Vector &X, const Vector &b,
568 Vector &x) override;
569
570 /// @brief Compute and store internally all element matrices.
571 ///
572 /// If AssemblyLevel::ELEMENT is selected with SetAssemblyLeve(), this will
573 /// use efficient (device-accelerated) assembly of the element matrices.
575
576 /// Free the memory used by the element matrices.
578
579 /// @brief Return a DenseTensor containing the assembled element matrices.
580 ///
581 /// If AssemblyLevel::ELEMENT is selected with SetAssemblyLeve(), this will
582 /// use efficient (device-accelerated) assembly of the element matrices.
584
585 /// Compute the element matrix of the given element
586 /** The element matrix is computed by calling the domain integrators
587 or the one stored internally by a prior call of ComputeElementMatrices()
588 is returned when available.
589 */
590 void ComputeElementMatrix(int i, DenseMatrix &elmat) const;
591
592 /// Compute the boundary element matrix of the given boundary element
593 /** @note The boundary attribute markers of the integrators are ignored. */
594 void ComputeBdrElementMatrix(int i, DenseMatrix &elmat) const;
595
596 /// Compute the face matrix of the given face element
597 void ComputeFaceMatrix(int i, DenseMatrix &elmat) const;
598
599 /// Compute the boundary face matrix of the given boundary element
600 /** @note The boundary attribute markers of the integrators are ignored. */
601 void ComputeBdrFaceMatrix(int i, DenseMatrix &elmat) const;
602
603 /// Assemble the given element matrix
604 /** The element matrix @a elmat is assembled for the element @a i, i.e.
605 added to the system matrix. The flag @a skip_zeros skips the zero
606 elements of the matrix, unless they are breaking the symmetry of
607 the system matrix.
608 */
609 void AssembleElementMatrix(int i, const DenseMatrix &elmat,
610 int skip_zeros = 1);
611
612 /// Assemble the given element matrix
613 /** The element matrix @a elmat is assembled for the element @a i, i.e.
614 added to the system matrix. The vdofs of the element are returned
615 in @a vdofs. The flag @a skip_zeros skips the zero elements of the
616 matrix, unless they are breaking the symmetry of the system matrix.
617 */
618 void AssembleElementMatrix(int i, const DenseMatrix &elmat,
619 Array<int> &vdofs, int skip_zeros = 1);
620
621 /// Assemble the given boundary element matrix
622 /** The boundary element matrix @a elmat is assembled for the boundary
623 element @a i, i.e. added to the system matrix. The flag @a skip_zeros
624 skips the zero elements of the matrix, unless they are breaking the
625 symmetry of the system matrix.
626 */
627 void AssembleBdrElementMatrix(int i, const DenseMatrix &elmat,
628 int skip_zeros = 1);
629
630 /// Assemble the given boundary element matrix
631 /** The boundary element matrix @a elmat is assembled for the boundary
632 element @a i, i.e. added to the system matrix. The vdofs of the element
633 are returned in @a vdofs. The flag @a skip_zeros skips the zero elements
634 of the matrix, unless they are breaking the symmetry of the system
635 matrix. */
636 void AssembleBdrElementMatrix(int i, const DenseMatrix &elmat,
637 Array<int> &vdofs, int skip_zeros = 1);
638
639 /// Eliminate essential boundary DOFs from the system.
640 /** The array @a bdr_attr_is_ess marks boundary attributes that constitute
641 the essential part of the boundary. By default, the diagonal at the
642 essential DOFs is set to 1.0. This behavior is controlled by the argument
643 @a dpolicy. */
644 void EliminateEssentialBC(const Array<int> &bdr_attr_is_ess,
645 const Vector &sol, Vector &rhs,
646 DiagonalPolicy dpolicy = DIAG_ONE);
647
648 /// Eliminate essential boundary DOFs from the system matrix.
649 void EliminateEssentialBC(const Array<int> &bdr_attr_is_ess,
650 DiagonalPolicy dpolicy = DIAG_ONE);
651 /// Perform elimination and set the diagonal entry to the given value
652 void EliminateEssentialBCDiag(const Array<int> &bdr_attr_is_ess,
653 real_t value);
654
655 /// Eliminate the given @a vdofs. NOTE: here, @a vdofs is a list of DOFs.
656 /** In this case the eliminations are applied to the internal $ M $
657 and @a rhs without storing the elimination matrix $ M_e $. */
658 void EliminateVDofs(const Array<int> &vdofs, const Vector &sol, Vector &rhs,
659 DiagonalPolicy dpolicy = DIAG_ONE);
660
661 /** @brief Eliminate the given @a vdofs, storing the eliminated part
662 internally in $ M_e $.
663
664 This method works in conjunction with EliminateVDofsInRHS() and allows
665 elimination of boundary conditions in multiple right-hand sides. In this
666 method, @a vdofs is a list of DOFs. */
667 void EliminateVDofs(const Array<int> &vdofs,
668 DiagonalPolicy dpolicy = DIAG_ONE);
669
670 /** @brief Similar to
671 EliminateVDofs(const Array<int> &, const Vector &,
672 Vector &, DiagonalPolicy)
673 but here @a ess_dofs is a marker (boolean) array on all vector-dofs
674 (@a ess_dofs[i] < 0 is true). */
675 void EliminateEssentialBCFromDofs(const Array<int> &ess_dofs,
676 const Vector &sol,
677 Vector &rhs,
678 DiagonalPolicy dpolicy = DIAG_ONE);
679
680 /** @brief Similar to EliminateVDofs(const Array<int> &, DiagonalPolicy) but
681 here @a ess_dofs is a marker (boolean) array on all vector-dofs
682 (@a ess_dofs[i] < 0 is true). */
683 void EliminateEssentialBCFromDofs(const Array<int> &ess_dofs,
684 DiagonalPolicy dpolicy = DIAG_ONE);
685 /// Perform elimination and set the diagonal entry to the given value
686 void EliminateEssentialBCFromDofsDiag(const Array<int> &ess_dofs,
687 real_t value);
688
689 /** @brief Use the stored eliminated part of the matrix (see
690 EliminateVDofs(const Array<int> &, DiagonalPolicy)) to modify the r.h.s.
691 @a b; @a vdofs is a list of DOFs (non-directional, i.e. >= 0). */
692 void EliminateVDofsInRHS(const Array<int> &vdofs, const Vector &x,
693 Vector &b);
694
695 /** @brief Compute inner product for full uneliminated matrix:
696 $ y^T M x + y^T M_e x $ */
697 real_t FullInnerProduct(const Vector &x, const Vector &y) const
698 { return mat->InnerProduct(x, y) + mat_e->InnerProduct(x, y); }
699
700 /** @brief Update the @a FiniteElementSpace and delete all data associated
701 with the old one. */
702 virtual void Update(FiniteElementSpace *nfes = NULL);
703
704 /// (DEPRECATED) Return the FE space associated with the BilinearForm.
705 /** @deprecated Use FESpace() instead. */
706 MFEM_DEPRECATED FiniteElementSpace *GetFES() { return fes; }
707
708 /// Return the FE space associated with the BilinearForm.
710
711 /// Read-only access to the associated FiniteElementSpace.
712 const FiniteElementSpace *FESpace() const { return fes; }
713
714 /// Prints operator to stream os.
715 void Print(std::ostream & os = mfem::out, int width_ = 4) const override
716 {
717 MFEM_VERIFY(mat, "mat is NULL and can't be dereferenced");
718 mat->Print(os, width_);
719 }
720
721 /** @brief Sets Operator::DiagonalPolicy used upon construction of the
722 linear system.
723 Policies include:
724
725 - DIAG_ZERO (Set the diagonal values to zero)
726 - DIAG_ONE (Set the diagonal values to one)
727 - DIAG_KEEP (Keep the diagonal values)
728 */
730
731 /// Indicate that integrators are not owned by the BilinearForm
733
734 /** @brief Deletes internal matrices, bilinear integrators, and the
735 BilinearFormExtension */
736 virtual ~BilinearForm();
737};
738
739
740/**
741 Class for assembling of bilinear forms `a(u,v)` defined on different
742 trial and test spaces. The assembled matrix `M` is such that
743
744 a(u,v) = V^t M U
745
746 where `U` and `V` are the vectors representing the functions `u` and `v`,
747 respectively. The first argument, `u`, of `a(,)` is in the trial space
748 and the second argument, `v`, is in the test space. Thus,
749
750 # of rows of M = dimension of the test space and
751 # of cols of M = dimension of the trial space.
752
753 Both trial and test spaces should be defined on the same mesh.
754*/
756{
757protected:
758 SparseMatrix *mat; ///< Owned.
759 SparseMatrix *mat_e; ///< Owned.
760
762 *test_fes; ///< Not owned
763
764 /// The form assembly level (full, partial, etc.)
766
767 /** Extension for supporting Full Assembly (FA), Element Assembly (EA),
768 Partial Assembly (PA), or Matrix Free assembly (MF). */
769 std::unique_ptr<MixedBilinearFormExtension> ext;
770
771 /** @brief Indicates the BilinearFormIntegrator%s stored in
772 MixedBilinearForm#domain_integs, MixedBilinearForm#boundary_integs,
773 MixedBilinearForm#trace_face_integs and
774 MixedBilinearForm#boundary_trace_face_integs
775 are owned by another MixedBilinearForm. */
777
778 /// Domain integrators.
780 /// Entries are not owned.
782
783 /// Boundary integrators.
785 /// Entries are not owned.
787
788 /// Interior face integrators.
790
791 /// Boundary face integrators.
793 /// Entries are not owned.
795
796 /// Trace face (skeleton) integrators.
798
799 /// Boundary trace face (skeleton) integrators.
801 /// Entries are not owned.
803
806
807private:
808 /// Copy construction is not supported; body is undefined.
810
811 /// Copy assignment is not supported; body is undefined.
812 MixedBilinearForm &operator=(const MixedBilinearForm &);
813
814public:
815 /** @brief Construct a MixedBilinearForm on the given trial, @a tr_fes, and
816 test, @a te_fes, FiniteElementSpace%s. */
817 /** The pointers @a tr_fes and @a te_fes are not owned by the newly
818 constructed object. */
820 FiniteElementSpace *te_fes);
821
822 /** @brief Create a MixedBilinearForm on the given trial, @a tr_fes, and
823 test, @a te_fes, FiniteElementSpace%s, using the same integrators as the
824 MixedBilinearForm @a mbf.
825
826 The pointers @a tr_fes and @a te_fes are not owned by the newly
827 constructed object.
828
829 The integrators in @a mbf are copied as pointers and they are not owned
830 by the newly constructed MixedBilinearForm. */
832 FiniteElementSpace *te_fes,
833 MixedBilinearForm *mbf);
834
835 /// Returns a reference to: $ M_{ij} $
836 real_t &Elem(int i, int j) override;
837
838 /// Returns a reference to: $ M_{ij} $
839 const real_t &Elem(int i, int j) const override;
840
841 /// Matrix multiplication: $ y = M x $
842 void Mult(const Vector & x, Vector & y) const override;
843
844 /// Add the matrix vector multiple to a vector: $ y += a M x $
845 void AddMult(const Vector & x, Vector & y,
846 const real_t a = 1.0) const override;
847
848 /// Matrix transpose vector multiplication: $ y = M^T x $
849 void MultTranspose(const Vector & x, Vector & y) const override;
850
851 /// Add the matrix transpose vector multiplication: $ y += a M^T x $
852 void AddMultTranspose(const Vector & x, Vector & y,
853 const real_t a = 1.0) const override;
854
855 /** @brief Returns a pointer to (approximation) of the matrix inverse:
856 $ M^{-1} $ (currently unimplemented and returns NULL)*/
857 MatrixInverse *Inverse() const override;
858
859 /** @brief Finalizes the matrix initialization if the ::AssemblyLevel is
860 AssemblyLevel::LEGACY.*/
861 void Finalize(int skip_zeros = 1) override;
862
863 /** @brief Extract the associated matrix as SparseMatrix blocks. The number
864 of block rows and columns is given by the vector dimensions (vdim) of the
865 test and trial spaces, respectively. */
866 void GetBlocks(Array2D<SparseMatrix *> &blocks) const;
867
868 /// Returns a const reference to the sparse matrix: $ M $
869 /** This will segfault if the usual sparse mat is not defined
870 like when static condensation is being used or AllocMat() has
871 not yet been called. */
872 const SparseMatrix &SpMat() const
873 {
874 MFEM_VERIFY(mat, "mat is NULL and can't be dereferenced");
875 return *mat;
876 }
877
878 /// Returns a reference to the sparse matrix: $ M $
880 {
881 MFEM_VERIFY(mat, "mat is NULL and can't be dereferenced");
882 return *mat;
883 }
884
885 /** @brief Nullifies the internal matrix $ M $ and returns a pointer
886 to it. Used for transferring ownership. */
887 SparseMatrix *LoseMat() { SparseMatrix *tmp = mat; mat = NULL; return tmp; }
888
889 /// Returns a const reference to the sparse matrix of eliminated b.c.: $ M_e $
890 const SparseMatrix &SpMatElim() const
891 {
892 MFEM_VERIFY(mat_e, "mat_e is NULL and can't be dereferenced");
893 return *mat_e;
894 }
895
896 /// Returns a reference to the sparse matrix of eliminated b.c.: $ M_e $
898 {
899 MFEM_VERIFY(mat_e, "mat_e is NULL and can't be dereferenced");
900 return *mat_e;
901 }
902
903 /// Adds a domain integrator. Assumes ownership of @a bfi.
905
906 /// Adds a domain integrator. Assumes ownership of @a bfi.
908 Array<int> &elem_marker);
909
910 /// Adds a boundary integrator. Assumes ownership of @a bfi.
912
913 /// Adds a boundary integrator. Assumes ownership of @a bfi.
915 Array<int> &bdr_marker);
916
917 /// Adds an interior face integrator. Assumes ownership of @a bfi.
919
920 /// Adds a boundary face integrator. Assumes ownership of @a bfi.
922
923 /// Adds a boundary face integrator. Assumes ownership of @a bfi.
925 Array<int> &bdr_marker);
926
927 /** @brief Add a trace face integrator. Assumes ownership of @a bfi.
928
929 This type of integrator assembles terms over all faces of the mesh using
930 the face FE from the trial space and the two adjacent volume FEs from
931 the test space. */
933
934 /// Adds a boundary trace face integrator. Assumes ownership of @a bfi.
936
937 /// Adds a boundary trace face integrator. Assumes ownership of @a bfi.
939 Array<int> &bdr_marker);
940
941 /// Access all integrators added with AddDomainIntegrator().
943 /** @brief Access all domain markers added with AddDomainIntegrator().
944 If no marker was specified when the integrator was added, the
945 corresponding pointer (to Array<int>) will be NULL. */
947
948 /// Access all integrators added with AddBoundaryIntegrator().
950
951 /** @brief Access all boundary markers added with AddBoundaryIntegrator().
952
953 If no marker was specified when the integrator was added, the
954 corresponding pointer (to Array<int>) will be NULL. */
956
957 /// Access all integrators added with AddInteriorFaceIntegrator().
959
960 /// Access all integrators added with AddBdrFaceIntegrator().
962 /** @brief Access all boundary markers added with AddBdrFaceIntegrator().
963 If no marker was specified when the integrator was added, the
964 corresponding pointer (to Array<int>) will be NULL. */
966
967 /// Access all integrators added with AddTraceFaceIntegrator().
969
970 /// Access all integrators added with AddBdrTraceFaceIntegrator().
973
974 /** @brief Access all boundary markers added with AddBdrTraceFaceIntegrator()
975
976 If no marker was specified when the integrator was added, the
977 corresponding pointer (to Array<int>) will be NULL. */
980
981 /// Sets all sparse values of $ M $ to @a a.
982 void operator=(const real_t a) { *mat = a; }
983
984 /// Set the desired assembly level. The default is AssemblyLevel::LEGACY.
985 /** This method must be called before assembly. See ::AssemblyLevel*/
986 void SetAssemblyLevel(AssemblyLevel assembly_level);
987
988 void Assemble(int skip_zeros = 1);
989
990 /** @brief Assemble the diagonal of ADA^T into diag, where A is this mixed
991 bilinear form and D is a diagonal. */
992 void AssembleDiagonal_ADAt(const Vector &D, Vector &diag) const;
993
994 /// Get the input finite element space prolongation matrix
995 const Operator *GetProlongation() const override
996 { return trial_fes->GetProlongationMatrix(); }
997
998 /// Get the input finite element space restriction matrix
999 const Operator *GetRestriction() const override
1000 { return trial_fes->GetRestrictionMatrix(); }
1001
1002 /// Get the test finite element space prolongation matrix
1003 const Operator *GetOutputProlongation() const override
1004 { return test_fes->GetProlongationMatrix(); }
1005
1006 /// Get the test finite element space restriction matrix
1007 const Operator *GetOutputRestriction() const override
1008 { return test_fes->GetRestrictionMatrix(); }
1009
1010 /** @brief For partially conforming trial and/or test FE spaces, complete the
1011 assembly process by performing $ P2^t A P1 $ where $ A $ is the
1012 internal sparse matrix; $ P1 $ and $ P2 $ are the conforming
1013 prolongation matrices of the trial and test FE spaces, respectively.
1014 After this call the MixedBilinearForm becomes an operator on the
1015 conforming FE spaces. */
1016 void ConformingAssemble();
1017
1018 /// Compute the element matrix of the given element
1019 void ComputeElementMatrix(int i, DenseMatrix &elmat) const;
1020
1021 /// Compute the boundary element matrix of the given boundary element
1022 /** @note The boundary attribute markers of the integrators are ignored. */
1023 void ComputeBdrElementMatrix(int i, DenseMatrix &elmat) const;
1024
1025 /// Compute the trace face matrix of the given face element
1026 void ComputeTraceFaceMatrix(int i, DenseMatrix &elmat) const;
1027
1028 /// Compute the boundary trace face matrix of the given boundary element
1029 /** @note The boundary attribute markers of the integrators are ignored. */
1030 void ComputeBdrTraceFaceMatrix(int i, DenseMatrix &elmat) const;
1031
1032 /// Compute the face matrix of the given face element
1033 void ComputeFaceMatrix(int i, DenseMatrix &elmat) const;
1034
1035 /// Compute the boundary face matrix of the given boundary element
1036 /** @note The boundary attribute markers of the integrators are ignored. */
1037 void ComputeBdrFaceMatrix(int i, DenseMatrix &elmat) const;
1038
1039 /// Assemble the given element matrix
1040 /** The element matrix @a elmat is assembled for the element @a i, i.e.
1041 added to the system matrix. The flag @a skip_zeros skips the zero
1042 elements of the matrix, unless they are breaking the symmetry of
1043 the system matrix.
1044 */
1045 void AssembleElementMatrix(int i, const DenseMatrix &elmat,
1046 int skip_zeros = 1);
1047
1048 /// Assemble the given element matrix
1049 /** The element matrix @a elmat is assembled for the element @a i, i.e.
1050 added to the system matrix. The vdofs of the element are returned
1051 in @a trial_vdofs and @a test_vdofs. The flag @a skip_zeros skips
1052 the zero elements of the matrix, unless they are breaking the symmetry
1053 of the system matrix.
1054 */
1055 void AssembleElementMatrix(int i, const DenseMatrix &elmat,
1057 int skip_zeros = 1);
1058
1059 /// Assemble the given boundary element matrix
1060 /** The boundary element matrix @a elmat is assembled for the boundary
1061 element @a i, i.e. added to the system matrix. The flag @a skip_zeros
1062 skips the zero elements of the matrix, unless they are breaking the
1063 symmetry of the system matrix.
1064 */
1065 void AssembleBdrElementMatrix(int i, const DenseMatrix &elmat,
1066 int skip_zeros = 1);
1067
1068 /// Assemble the given boundary element matrix
1069 /** The boundary element matrix @a elmat is assembled for the boundary
1070 element @a i, i.e. added to the system matrix. The vdofs of the element
1071 are returned in @a trial_vdofs and @a test_vdofs. The flag @a skip_zeros
1072 skips the zero elements of the matrix, unless they are breaking the
1073 symmetry of the system matrix.*/
1074 void AssembleBdrElementMatrix(int i, const DenseMatrix &elmat,
1077 int skip_zeros = 1);
1078
1079 /// Eliminate essential boundary trial DOFs from the system.
1080 /** The array @a bdr_attr_is_ess marks boundary attributes that constitute
1081 the essential part of the boundary. */
1082 void EliminateTrialEssentialBC(const Array<int> &bdr_attr_is_ess,
1083 const Vector &sol, Vector &rhs);
1084
1085 /// Eliminate essential boundary trial DOFs from the system matrix.
1086 /** The array @a bdr_attr_is_ess marks boundary attributes that constitute
1087 the essential part of the boundary. */
1088 void EliminateTrialEssentialBC(const Array<int> &bdr_attr_is_ess);
1089
1090 /// (DEPRECATED) Eliminate essential boundary trial DOFs from the system.
1091 /** @see EliminateTrialEssentialBC() */
1092 MFEM_DEPRECATED void EliminateTrialDofs(const Array<int> &bdr_attr_is_ess,
1093 const Vector &sol, Vector &rhs)
1094 { EliminateTrialEssentialBC(bdr_attr_is_ess, sol, rhs); }
1095
1096 /// Eliminate the given trial @a vdofs. NOTE: here, @a vdofs is a list of DOFs.
1097 /** In this case the eliminations are applied to the internal $ M $
1098 and @a rhs without storing the elimination matrix $ M_e $. */
1099 void EliminateTrialVDofs(const Array<int> &vdofs, const Vector &sol,
1100 Vector &rhs);
1101
1102 /// Eliminate the given trial @a vdofs, storing the eliminated part internally in $ M_e $.
1103 /** This method works in conjunction with EliminateTrialVDofsInRHS() and allows
1104 elimination of boundary conditions in multiple right-hand sides. In this
1105 method, @a vdofs is a list of DOFs. */
1106 void EliminateTrialVDofs(const Array<int> &vdofs);
1107
1108 /** @brief Use the stored eliminated part of the matrix (see
1109 EliminateTrialVDofs(const Array<int> &)) to modify the r.h.s.
1110 @a b; @a vdofs is a list of DOFs (non-directional, i.e. >= 0). */
1111 void EliminateTrialVDofsInRHS(const Array<int> &vdofs, const Vector &x,
1112 Vector &b);
1113
1114 /** @brief Similar to
1115 EliminateTrialVDofs(const Array<int> &, const Vector &, Vector &)
1116 but here @a ess_dofs is a marker (boolean) array on all vector-dofs
1117 (@a ess_dofs[i] < 0 is true). */
1118 void EliminateEssentialBCFromTrialDofs(const Array<int> &marked_vdofs,
1119 const Vector &sol, Vector &rhs);
1120
1121 /// Eliminate essential boundary test DOFs from the system matrix.
1122 /** The array @a bdr_attr_is_ess marks boundary attributes that constitute
1123 the essential part of the boundary. */
1124 void EliminateTestEssentialBC(const Array<int> &bdr_attr_is_ess);
1125
1126 /// (DEPRECATED) Eliminate essential boundary test DOFs from the system.
1127 /** @see EliminateTestEssentialBC() */
1128 MFEM_DEPRECATED virtual void EliminateTestDofs(const Array<int>
1129 &bdr_attr_is_ess)
1130 { EliminateTestEssentialBC(bdr_attr_is_ess); }
1131
1132 /// Eliminate the given test @a vdofs. NOTE: here, @a vdofs is a list of DOFs.
1133 void EliminateTestVDofs(const Array<int> &vdofs);
1134
1135 /** @brief Return in @a A that is column-constrained.
1136
1137 This returns the same operator as FormRectangularLinearSystem(), but does
1138 without the transformations of the right-hand side. */
1139 virtual void FormRectangularSystemMatrix(const Array<int> &trial_tdof_list,
1140 const Array<int> &test_tdof_list,
1141 OperatorHandle &A);
1142
1143 /** @brief Form the column-constrained linear system matrix A.
1144
1145 Version of the method FormRectangularSystemMatrix() where the system
1146 matrix is returned in the variable @a A, of type OpType, holding a
1147 *reference* to the system matrix (created with the method
1148 OpType::MakeRef()). The reference will be invalidated when
1149 SetOperatorType(), Update(), or the destructor is called. */
1150 template <typename OpType>
1151 void FormRectangularSystemMatrix(const Array<int> &trial_tdof_list,
1152 const Array<int> &test_tdof_list, OpType &A)
1153 {
1154 OperatorHandle Ah;
1155 FormRectangularSystemMatrix(trial_tdof_list, test_tdof_list, Ah);
1156 OpType *A_ptr = Ah.Is<OpType>();
1157 MFEM_VERIFY(A_ptr, "invalid OpType used");
1158 A.MakeRef(*A_ptr);
1159 }
1160
1161 /** @brief Form the linear system A X = B, corresponding to this mixed
1162 bilinear form and the linear form @a b(.).
1163
1164 Return in @a A a *reference* to the system matrix that is
1165 column-constrained. The reference will be invalidated when
1166 SetOperatorType(), Update(), or the destructor is called. */
1167 virtual void FormRectangularLinearSystem(const Array<int> &trial_tdof_list,
1168 const Array<int> &test_tdof_list,
1169 Vector &x, Vector &b,
1170 OperatorHandle &A, Vector &X,
1171 Vector &B);
1172
1173 /** @brief Form the linear system A X = B, corresponding to this bilinear
1174 form and the linear form @a b(.).
1175
1176 Version of the method FormRectangularLinearSystem() where the system
1177 matrix is returned in the variable @a A, of type OpType, holding a
1178 *reference* to the system matrix (created with the method
1179 OpType::MakeRef()). The reference will be invalidated when
1180 SetOperatorType(), Update(), or the destructor is called. */
1181 template <typename OpType>
1182 void FormRectangularLinearSystem(const Array<int> &trial_tdof_list,
1183 const Array<int> &test_tdof_list,
1184 Vector &x, Vector &b,
1185 OpType &A, Vector &X, Vector &B)
1186 {
1187 OperatorHandle Ah;
1188 FormRectangularLinearSystem(trial_tdof_list, test_tdof_list, x, b,
1189 Ah, X, B);
1190 OpType *A_ptr = Ah.Is<OpType>();
1191 MFEM_VERIFY(A_ptr, "invalid OpType used");
1192 A.MakeRef(*A_ptr);
1193 }
1194
1195 /// Must be called after making changes to #trial_fes or #test_fes.
1196 void Update();
1197
1198 /// Return the trial FE space associated with the BilinearForm.
1200
1201 /// Read-only access to the associated trial FiniteElementSpace.
1202 const FiniteElementSpace *TrialFESpace() const { return trial_fes; }
1203
1204 /// Return the test FE space associated with the BilinearForm.
1206
1207 /// Read-only access to the associated test FiniteElementSpace.
1208 const FiniteElementSpace *TestFESpace() const { return test_fes; }
1209
1210 /// Prints operator to stream os.
1211 void Print(std::ostream & os = mfem::out, int width_ = 4) const override
1212 {
1213 MFEM_VERIFY(mat, "mat is NULL and can't be dereferenced");
1214 mat->Print(os, width_);
1215 }
1216
1217 /** @brief Deletes internal matrices, bilinear integrators, and the
1218 BilinearFormExtension */
1219 virtual ~MixedBilinearForm();
1220};
1221
1222
1223/**
1224 Class for constructing the matrix representation of a linear operator,
1225 `v = L u`, from one FiniteElementSpace (domain) to another FiniteElementSpace
1226 (range). The constructed matrix `A` is such that
1227
1228 V = A U
1229
1230 where `U` and `V` are the vectors of degrees of freedom representing the
1231 functions `u` and `v`, respectively. The dimensions of `A` are
1232
1233 number of rows of A = dimension of the range space and
1234 number of cols of A = dimension of the domain space.
1235
1236 This class is very similar to MixedBilinearForm. One difference is that
1237 the linear operator `L` is defined using a special kind of
1238 BilinearFormIntegrator (we reuse its functionality instead of defining a
1239 new class). The other difference with the MixedBilinearForm class is that
1240 the "assembly" process overwrites the global matrix entries using the
1241 local element matrices instead of adding them.
1242
1243 Note that if we define the bilinear form `b(u,v) := (Lu,v)` using an inner
1244 product in the range space, then its matrix representation, `B`, is
1245
1246 B = M A, (since V^t B U = b(u,v) = (Lu,v) = V^t M A U)
1247
1248 where `M` denotes the mass matrix for the inner product in the range space:
1249 `V1^t M V2 = (v1,v2)`. Similarly, if `c(u,w) := (Lu,Lw)` then
1250
1251 C = A^t M A.
1252*/
1254{
1255private:
1256 /// Copy construction is not supported; body is undefined.
1258
1259 /// Copy assignment is not supported; body is undefined.
1261
1262public:
1263 /** @brief Construct a DiscreteLinearOperator on the given
1264 FiniteElementSpace%s @a domain_fes and @a range_fes. */
1265 /** The pointers @a domain_fes and @a range_fes are not owned by the newly
1266 constructed object. */
1268 FiniteElementSpace *range_fes)
1269 : MixedBilinearForm(domain_fes, range_fes) { }
1270
1271 /// Adds a domain interpolator. Assumes ownership of @a di.
1275 Array<int> &elem_marker)
1276 { AddDomainIntegrator(di, elem_marker); }
1277
1278 /// Adds a trace face interpolator. Assumes ownership of @a di.
1281
1282 /// Access all interpolators added with AddDomainInterpolator().
1285
1286 /// Set the desired assembly level. The default is AssemblyLevel::FULL.
1287 /** This method must be called before assembly. */
1288 void SetAssemblyLevel(AssemblyLevel assembly_level);
1289
1290 /** @brief Construct the internal matrix representation of the discrete
1291 linear operator. */
1292 virtual void Assemble(int skip_zeros = 1);
1293
1294 /** @brief Get the output finite element space restriction matrix in
1295 transposed form. */
1298};
1299
1300}
1301
1302#endif
Dynamic 2D array using row-major layout.
Definition array.hpp:392
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:244
const SparseMatrix * GetConformingRestriction() const
The returned SparseMatrix is owned by the FiniteElementSpace.
Definition fespace.cpp:1463
virtual const SparseMatrix * GetRestrictionMatrix() const
The returned SparseMatrix is owned by the FiniteElementSpace.
Definition fespace.hpp:750
virtual const Operator * GetProlongationMatrix() const
Definition fespace.hpp:727
const Operator * GetRestrictionTransposeOperator() const
Return an operator that performs the transpose of GetRestrictionOperator.
Definition fespace.cpp:1478
const SparseMatrix * GetConformingProlongation() const
Definition fespace.cpp:1456
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:25
int height
Dimension of the output / number of rows in the matrix.
Definition operator.hpp:27
DiagonalPolicy
Defines operator diagonal policy upon elimination of rows and/or columns.
Definition operator.hpp:48
@ DIAG_ONE
Set the diagonal value to one.
Definition operator.hpp:50
@ DIAG_KEEP
Keep the diagonal value.
Definition operator.hpp:51
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
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:43
std::function< real_t(const Vector &)> f(real_t mass_coeff)
Definition lor_mms.hpp:30