MFEM v4.10.0
Finite element discretization library
Loading...
Searching...
No Matches
hybridization_ext.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_HYBRIDIZATION_EXT
13#define MFEM_HYBRIDIZATION_EXT
14
15#include "../config/config.hpp"
16#include "../general/array.hpp"
18#include "../linalg/vector.hpp"
19
20#include <memory>
21
22namespace mfem
23{
24
25/// @brief Extension class supporting Hybridization on device (GPU).
26///
27/// Similar to BilinearFormExtension and LinearFormExtension, this extension
28/// class provides device execution capabilities for the Hybridization class.
29///
30/// As with the other extension classes, a limitation of this class is that it
31/// requires meshes consisting only of tensor-product elements, and finite
32/// element spaces without variable polynomial degrees.
34{
35 friend class Hybridization;
36public:
37 enum DofType : char
38 {
42 };
43protected:
44 class Hybridization &h; ///< The associated Hybridization object.=
45 int num_hat_dofs; ///< Number of Lagrange multipliers.
46 mutable Vector tmp1, tmp2; ///< Temporary vectors.
47
50
51 Array<int> el_to_face; ///< Element to face connectivity.
52 Array<int> el_face_offsets; ///< Per-element offsets into @a el_to_face.
53 Array<int> face_to_el; ///< Face-to-element connectivity.
54 Array<int> face_face_offsets; ///< Face-to-face offsets.
55
56 int n_el_face; ///< Total number of element-to-face connections.
57 int n_face_face; ///< Total number of face-to-face connections.
58
59 Vector Ct_mat; ///< Constraint matrix (transposed) stored element-wise.
60
61 /// @name For parallel non-conforming meshes
62 ///@{
63 std::unique_ptr<Operator> P_pc; ///< Partially conforming prolongation.
64 std::unique_ptr<Operator> P_nbr; ///< Face-neighbor prolongation.
65 ///@}
66
68
71
72 /// Return the (partially) conforming prolongation on the constraint space.
73 const Operator &GetProlongation() const;
74
75public:
76 /// Construct the constraint matrix.
77 void ConstructC();
78
79 template <int MID, int MBD>
80 void FactorElementMatrices(Vector &AhatInvCt_mat);
81
82 /// Form the Schur complement matrix $H$.
83 void ConstructH();
84
85 /// Compute the action of C^t x.
86 void MultCt(const Vector &x, Vector &y) const;
87
88 /// Compute the action of C x.
89 void MultC(const Vector &x, Vector &y) const;
90
91 /// @brief Assemble the element matrix A into the hybridized system matrix.
92 ///
93 /// @warning Using the interface will be very slow. AssembleElementMatrices()
94 /// should be used instead.
95 void AssembleMatrix(int el, const class DenseMatrix &elmat);
96
97 /// @brief Assemble the boundary element matrix A into the hybridized system
98 /// matrix.
99 ///
100 /// @warning Using the interface will be very slow. AssembleElementMatrices()
101 /// should be used instead.
102 void AssembleBdrMatrix(int bdr_el, const class DenseMatrix &elmat);
103
104 /// Invert and store the element matrices Ahat.
105 void AssembleElementMatrices(const class DenseTensor &el_mats);
106
107 /// Apply the action of R mapping from "hat DOFs" to T-vector
108 void MultR(const Vector &b, Vector &b_hat) const;
109
110 /// Apply the action of R^t mapping into the "hat DOF" space.
111 void MultRt(const Vector &b, Vector &b_hat) const;
112
113 /// Apply the elementwise A_hat^{-1}.
114 void MultAhatInv(Vector &x) const;
115
116 /// Constructor.
117 HybridizationExtension(class Hybridization &hybridization_);
118
119 /// Prepare for assembly; form the constraint matrix.
120 void Init(const Array<int> &ess_tdof_list);
121
122 /// @brief Given a right-hand side on the original space, compute the
123 /// corresponding right-hand side for the Lagrange multipliers.
124 void ReduceRHS(const Vector &b, Vector &b_r) const;
125
126 /// @brief Given Lagrange multipliers @a sol_r and the original right-hand
127 /// side @a b, recover the solution @a sol on the original finite element
128 /// space.
129 void ComputeSolution(const Vector &b, const Vector &sol_r, Vector &sol) const;
130
131 /// Destroys the stored element matrices.
132 void Reset() { Ahat = 0.0; }
133};
134
135}
136
137#endif
Data type dense matrix using column-major storage.
Definition densemat.hpp:24
Rank 3 tensor (array of matrices)
Extension class supporting Hybridization on device (GPU).
Vector Ct_mat
Constraint matrix (transposed) stored element-wise.
std::unique_ptr< Operator > P_nbr
Face-neighbor prolongation.
void ConstructC()
Construct the constraint matrix.
void Init(const Array< int > &ess_tdof_list)
Prepare for assembly; form the constraint matrix.
Array< int > face_to_el
Face-to-element connectivity.
std::unique_ptr< Operator > P_pc
Partially conforming prolongation.
int n_face_face
Total number of face-to-face connections.
void FactorElementMatrices(Vector &AhatInvCt_mat)
void ReduceRHS(const Vector &b, Vector &b_r) const
Given a right-hand side on the original space, compute the corresponding right-hand side for the Lagr...
Array< int > el_to_face
Element to face connectivity.
void ComputeSolution(const Vector &b, const Vector &sol_r, Vector &sol) const
Given Lagrange multipliers sol_r and the original right-hand side b, recover the solution sol on the ...
void Reset()
Destroys the stored element matrices.
HybridizationExtension(class Hybridization &hybridization_)
Constructor.
Array< int > face_face_offsets
Face-to-face offsets.
Vector tmp2
Temporary vectors.
void ConstructH()
Form the Schur complement matrix .
void MultR(const Vector &b, Vector &b_hat) const
Apply the action of R mapping from "hat DOFs" to T-vector.
Array< int > el_face_offsets
Per-element offsets into el_to_face.
const Operator & GetProlongation() const
Return the (partially) conforming prolongation on the constraint space.
void MultC(const Vector &x, Vector &y) const
Compute the action of C x.
void MultAhatInv(Vector &x) const
Apply the elementwise A_hat^{-1}.
int num_hat_dofs
Number of Lagrange multipliers.
void AssembleMatrix(int el, const class DenseMatrix &elmat)
Assemble the element matrix A into the hybridized system matrix.
int n_el_face
Total number of element-to-face connections.
void MultCt(const Vector &x, Vector &y) const
Compute the action of C^t x.
class Hybridization & h
The associated Hybridization object.=.
void MultRt(const Vector &b, Vector &b_hat) const
Apply the action of R^t mapping into the "hat DOF" space.
void AssembleBdrMatrix(int bdr_el, const class DenseMatrix &elmat)
Assemble the boundary element matrix A into the hybridized system matrix.
void AssembleElementMatrices(const class DenseTensor &el_mats)
Invert and store the element matrices Ahat.
Auxiliary class Hybridization, used to implement BilinearForm hybridization.
Abstract operator.
Definition operator.hpp:27
Vector data type.
Definition vector.hpp:82
const int * ess_tdof_list
real_t b
Definition lissajous.cpp:42
real_t sol(const Vector &x)