MFEM v4.10.0
Finite element discretization library
Loading...
Searching...
No Matches
blockstaticcond.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_BLOCK_STATIC_CONDENSATION
13#define MFEM_BLOCK_STATIC_CONDENSATION
14
15#include "mfem.hpp"
16
17namespace mfem
18{
19
20/** @brief Class that performs static condensation of interior dofs for
21 multiple FE spaces. This class is used in class DPGWeakForm.
22 It is suitable for systems resulting from the discretization of multiple
23 FE spaces. It eliminates the dofs associated with the interior of the elements
24 and returns the reduced system which contains only the interfacial dofs.
25 The ordering of the dofs in the matrix is implied by the ordering given by the
26 FE spaces, but there is no assumption on the ordering of the FE spaces.
27 This class handles both serial and parallel FE spaces. */
29{
30 int height, width;
31 int nblocks; // original number of blocks
32 int rblocks; // reduces number of blocks
33 Mesh * mesh = nullptr;
34 bool parallel = false;
35 // original set of Finite Element Spaces
37 // indicates if the original space is a trace space
38 Array<bool> IsTraceSpace;
39
40 // New set of "reduced" Finite Element Spaces
41 // (after static condensation)
44
45 Array<int> dof_offsets;
46 Array<int> tdof_offsets;
47
48 Array<int> rdof_offsets;
49 Array<int> rtdof_offsets;
50
51 /** Schur complement matrix
52 S = A_ii - A_ib (A_bb)^{-1} A_bi.
53 Here (b) and (i) stand for "bubble" and "interface" respectively */
54 BlockMatrix * S = nullptr;
55 BlockMatrix * S_e = nullptr;
56
57 BlockVector * y = nullptr;
58
61
62 Array<int> rdof_edof; // Map from reduced dofs to exposed dofs
63 Array<int> ess_rtdof_list;
64
65 BlockMatrix * P = nullptr; // Block Prolongation
66 BlockMatrix * R = nullptr; // Block Restriction
67
68#ifdef MFEM_USE_MPI
69 BlockOperator * pS = nullptr;
70 BlockOperator * pS_e = nullptr;
71 BlockOperator * pP = nullptr;
72#endif
73
74 bool Parallel() const { return parallel; }
75
76
77 // tr_idx (trace dofs indices)
78 // int_idx (interior dof indices)
79 void GetReducedElementIndicesAndOffsets(int el, Array<int> & tr_idx,
80 Array<int> & int_idx,
81 Array<int> & offsets) const;
82
83 void GetReducedElementVDofs(int el, Array<int> & rdofs) const;
84 void GetElementVDofs(int el, Array<int> & vdofs) const;
85
86
87 /** S = A_ii - A_ib (A_bb)^{-1} A_bi and y = y_i - A_ib (A_bb)^{-1} y_b.
88 Here (b) and (i) stand for "bubble" and "interface" respectively */
89 void GetLocalSchurComplement(int el, const Array<int> & tr_idx,
90 const Array<int> & int_idx,
91 const DenseMatrix & elmat, const Vector & elvect,
92 DenseMatrix & rmat, Vector & rvect);
93
94 void ComputeOffsets();
95
96 void BuildProlongation();
97#ifdef MFEM_USE_MPI
98 void BuildParallelProlongation();
99#endif
100
101 // ess_tdof list for each space
102 Array<Array<int> *> ess_tdofs;
103 void FillEssTdofLists(const Array<int> & ess_tdof_list);
104
105 void ConformingAssemble(int skip_zeros);
106
107 /** Restrict a marker Array on the true FE spaces dofs to a marker Array on
108 the reduced/trace true FE spaces dofs. */
109 void ConvertMarkerToReducedTrueDofs(Array<int> & tdof_marker,
110 Array<int> & rtdof_marker);
111
112 void SetSpaces(Array<FiniteElementSpace*> & fes_);
113
114 void Init();
115
116public:
117
119
121
122 /** Assemble the contribution to the Schur complement from the given
123 element matrix 'elmat'; save the other blocks internally: A_bb_inv, A_bi,
124 and A_bi. */
125 void AssembleReducedSystem(int el, DenseMatrix &elmat,
126 Vector & elvect);
127
128 /// Finalize the construction of the Schur complement matrix.
129 void Finalize(int skip_zeros = 0);
130
131 /// Determine and save internally essential reduced true dofs.
133
134 /// Eliminate the given reduced true dofs from the Schur complement matrix S.
135 void EliminateReducedTrueDofs(const Array<int> &ess_rtdof_list,
136 Matrix::DiagonalPolicy dpolicy);
137
138 bool HasEliminatedBC() const
139 {
140#ifndef MFEM_USE_MPI
141 return S_e;
142#else
143 return S_e || pS_e;
144#endif
145
146 }
147
148 /// Return the serial Schur complement matrix.
149 BlockMatrix &GetSchurMatrix() { return *S; }
150
151 /// Return the eliminated part of the serial Schur complement matrix.
152 BlockMatrix &GetSchurMatrixElim() { return *S_e; }
153
154#ifdef MFEM_USE_MPI
155 /// Return the parallel Schur complement matrix.
157
158 /// Return the eliminated part of the parallel Schur complement matrix.
160
162#endif
163
164 /** Form the global reduced system matrix using the given @a diag_policy.
165 This method can be called after Assemble() is called. */
167
168 /** Restrict a solution vector on the full FE space dofs to a vector on the
169 reduced/trace true FE space dofs. */
170 void ReduceSolution(const Vector &sol, Vector &sc_sol) const;
171
172 /** @brief Set the reduced solution `X` and r.h.s `B` vectors from the full
173 linear system solution `x` and r.h.s. `b` vectors.
174 This method should be called after the internal reduced essential dofs
175 have been set using SetEssentialTrueDofs() and both the Schur complement
176 and its eliminated part have been finalized. */
177 void ReduceSystem(Vector &x, Vector &X, Vector &B,
178 int copy_interior = 0) const;
179
180 /** Restrict a list of true FE space dofs to a list of reduced/trace true FE
181 space dofs. */
183 Array<int> &ess_rtdof_list) const;
184
185 /** Given a solution of the reduced system 'sc_sol', compute the solution
186 of the full system 'sol'. */
187 void ComputeSolution(const Vector &sc_sol, Vector &sol) const;
188
190 {
191 trace_fes = tr_fes;
192 }
193
194};
195
196}
197
198#endif
A class to handle Block systems in a matrix-free implementation.
Class that performs static condensation of interior dofs for multiple FE spaces. This class is used i...
BlockMatrix & GetSchurMatrix()
Return the serial Schur complement matrix.
void ConvertListToReducedTrueDofs(const Array< int > &ess_tdof_list, Array< int > &ess_rtdof_list) const
void FormSystemMatrix(Operator::DiagonalPolicy diag_policy)
void EliminateReducedTrueDofs(const Array< int > &ess_rtdof_list, Matrix::DiagonalPolicy dpolicy)
Eliminate the given reduced true dofs from the Schur complement matrix S.
void SetEssentialTrueDofs(const Array< int > &ess_tdof_list)
Determine and save internally essential reduced true dofs.
BlockMatrix & GetSchurMatrixElim()
Return the eliminated part of the serial Schur complement matrix.
BlockStaticCondensation(Array< FiniteElementSpace * > &fes_)
void ParallelAssemble(BlockMatrix *m)
BlockOperator & GetParallelSchurMatrix()
Return the parallel Schur complement matrix.
void ReduceSystem(Vector &x, Vector &X, Vector &B, int copy_interior=0) const
Set the reduced solution X and r.h.s B vectors from the full linear system solution x and r....
void ComputeSolution(const Vector &sc_sol, Vector &sol) const
void ReduceSolution(const Vector &sol, Vector &sc_sol) const
void GetTraceFESpaces(Array< FiniteElementSpace * > &trace_fes) const
BlockOperator & GetParallelSchurMatrixElim()
Return the eliminated part of the parallel Schur complement matrix.
void Finalize(int skip_zeros=0)
Finalize the construction of the Schur complement matrix.
void AssembleReducedSystem(int el, DenseMatrix &elmat, Vector &elvect)
A class to handle Vectors in a block fashion.
Data type dense matrix using column-major storage.
Definition densemat.hpp:24
A class to initialize the size of a Tensor.
Definition dtensor.hpp:57
Mesh data type.
Definition mesh.hpp:67
DiagonalPolicy
Defines operator diagonal policy upon elimination of rows and/or columns.
Definition operator.hpp:50
Vector data type.
Definition vector.hpp:82
const int * ess_tdof_list
real_t sol(const Vector &x)