MFEM v4.10.0
Finite element discretization library
Loading...
Searching...
No Matches
complexstaticcond.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_COMPLEX_BLOCK_STATIC_CONDENSATION
13#define MFEM_COMPLEX_BLOCK_STATIC_CONDENSATION
14
15#include "mfem.hpp"
16
17namespace mfem
18{
19
20
21/** @brief Class that performs static condensation of interior dofs for
22 multiple FE spaces for complex systems (see BlockStaticCondensation). It's used
23 by the class ComplexDPGWeakForm. */
25{
26 int height, width;
27 int nblocks; // original number of blocks
28 int rblocks; // reduces number of blocks
29 Mesh * mesh = nullptr;
30 bool parallel = false;
31 // original set of Finite Element Spaces
33 // indicates if the original space is already a trace space
34 Array<bool> IsTraceSpace;
35
36 // New set of "reduced" Finite Element Spaces
37 // (after static condensation)
40
41 Array<int> dof_offsets;
42 Array<int> tdof_offsets;
43
44 Array<int> rdof_offsets;
45 Array<int> rtdof_offsets;
46
47 // Schur complement matrix
48 // S = A_ii - A_ib (A_bb)^{-1} A_bi.
49 BlockMatrix * S_r = nullptr;
50 BlockMatrix * S_i = nullptr;
51 BlockMatrix * S_e_r = nullptr;
52 BlockMatrix * S_e_i = nullptr;
53 ComplexOperator * S = nullptr;
54
55 BlockVector * y_r = nullptr;
56 BlockVector * y_i = nullptr;
57 Vector * 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_r = nullptr;
70 BlockOperator * pS_e_r = nullptr;
71 BlockOperator * pS_i = nullptr;
72 BlockOperator * pS_e_i = nullptr;
73 // Block HypreParMatrix for Prolongation
74 BlockOperator * pP = nullptr;
75#endif
76
77 bool Parallel() const { return parallel; }
78
79
80 // tr_idx (trace dofs indices)
81 // int_idx (interior dof indices)
82 void GetReduceElementIndicesAndOffsets(int el, Array<int> & tr_idx,
83 Array<int> & int_idx,
84 Array<int> & offsets) const;
85
86 void GetReduceElementVDofs(int el, Array<int> & rdofs) const;
87 void GetElementVDofs(int el, Array<int> & vdofs) const;
88
89
90 // S = A_ii - A_ib (A_bb)^{-1} A_bi.
91 // y = y_i - A_ib (A_bb)^{-1} y_b
92 ComplexDenseMatrix * GetLocalShurComplement(int el, const Array<int> & tr_idx,
93 const Array<int> & int_idx,
94 const ComplexDenseMatrix & elmat,
95 const Vector & elvect_r,
96 const Vector & elvect_i,
97 Vector & rvect_r,
98 Vector & rvect_i);
99
100 void ComputeOffsets();
101
102 void BuildProlongation();
103#ifdef MFEM_USE_MPI
104 void BuildParallelProlongation();
105#endif
106
107 // ess_tdof list for each space
108 Array<Array<int> *> ess_tdofs;
109 void FillEssTdofLists(const Array<int> & ess_tdof_list);
110
111 void ConformingAssemble(int skip_zeros);
112
113 /** Restrict a marker Array on the true FE spaces dofs to a marker Array on
114 the reduced/trace true FE spaces dofs. */
115 void ConvertMarkerToReducedTrueDofs(Array<int> & tdof_marker,
116 Array<int> & rtdof_marker);
117
118 void SetSpaces(Array<FiniteElementSpace*> & fes_);
119
120 void Init();
121
122public:
123
125
127
128 /** Assemble the contribution to the Schur complement from the given
129 element matrix @a elmat. Save the other blocks internally: A_bb_inv, A_bi,
130 and A_bi. */
131 void AssembleReducedSystem(int el, ComplexDenseMatrix &elmat,
132 Vector & elvect_r, Vector & elvect_i);
133
134 /// Finalize the construction of the Schur complement matrix.
135 void Finalize(int skip_zeros = 0);
136
137 /// Determine and save internally essential reduced true dofs.
139
140 /// Eliminate the given reduced true dofs from the Schur complement matrix S.
141 void EliminateReducedTrueDofs(const Array<int> &ess_rtdof_list,
142 Matrix::DiagonalPolicy dpolicy);
143
144 bool HasEliminatedBC() const
145 {
146#ifndef MFEM_USE_MPI
147 return S_e_r;
148#else
149 return S_e_r || pS_e_r;
150#endif
151
152 }
153
154 /// Return the serial Schur complement matrix.
155 BlockMatrix &GetSchurMatrix_r() { return *S_r; }
156 BlockMatrix &GetSchurMatrix_i() { return *S_i; }
158 {
159 if (!S)
160 {
161#ifndef MFEM_USE_MPI
162 S = new ComplexOperator(S_r,S_i,false,false);
163#else
164 if (parallel)
165 {
166 S = new ComplexOperator(pS_r,pS_i,false,false);
167 }
168 else
169 {
170 S = new ComplexOperator(S_r,S_i,false,false);
171 }
172#endif
173 }
174 return *S;
175 }
176
177 /// Return the eliminated part of the serial Schur complement matrix.
178 BlockMatrix &GetSchurMatrixElim_r() { return *S_e_r; }
179 BlockMatrix &GetSchurMatrixElim_i() { return *S_e_i; }
180
181#ifdef MFEM_USE_MPI
182 /// Return the parallel Schur complement matrix.
185
186 /// Return the eliminated part of the parallel Schur complement matrix.
189
191#endif
192
193 /** Form the global reduced system matrix using the given @a diag_policy.
194 This method can be called after Assemble() is called. */
196
197 /** Restrict a solution vector on the full FE space dofs to a vector on the
198 reduced/trace true FE space dofs. */
199 void ReduceSolution(const Vector &sol, Vector &sc_sol) const;
200
201 /** @brief Set the reduced solution `X` and r.h.s `B` vectors from the full
202 linear system solution `x` and r.h.s. `b` vectors.
203 This method should be called after the internal reduced essential dofs
204 have been set using SetEssentialTrueDofs() and both the Schur complement
205 and its eliminated part have been finalized. */
206 void ReduceSystem(Vector &x, Vector &X, Vector &B,
207 int copy_interior = 0) const;
208
209 /** Restrict a list of true FE space dofs to a list of reduced/trace true FE
210 space dofs. */
212 Array<int> &ess_rtdof_list) const;
213
214 /** Given a solution of the reduced system 'sc_sol', compute the solution
215 of the full system 'sol'. */
216 void ComputeSolution(const Vector &sc_sol, Vector &sol) const;
217
219 {
220 trace_fes = tr_fes;
221 }
222
223};
224
225}
226
227#endif
A class to handle Block systems in a matrix-free implementation.
A class to handle Vectors in a block fashion.
Class that performs static condensation of interior dofs for multiple FE spaces for complex systems (...
void EliminateReducedTrueDofs(const Array< int > &ess_rtdof_list, Matrix::DiagonalPolicy dpolicy)
Eliminate the given reduced true dofs from the Schur complement matrix S.
ComplexBlockStaticCondensation(Array< FiniteElementSpace * > &fes_)
void ParallelAssemble(BlockMatrix *m_r, BlockMatrix *m_i)
void Finalize(int skip_zeros=0)
Finalize the construction of the Schur complement matrix.
BlockOperator & GetParallelSchurMatrixElim_r()
Return the eliminated part of the parallel Schur complement matrix.
BlockOperator & GetParallelSchurMatrix_r()
Return the parallel Schur complement matrix.
void AssembleReducedSystem(int el, ComplexDenseMatrix &elmat, Vector &elvect_r, Vector &elvect_i)
void FormSystemMatrix(Operator::DiagonalPolicy diag_policy)
void ConvertListToReducedTrueDofs(const Array< int > &ess_tdof_list, Array< int > &ess_rtdof_list) const
void SetEssentialTrueDofs(const Array< int > &ess_tdof_list)
Determine and save internally essential reduced true dofs.
void GetTraceFESpaces(Array< FiniteElementSpace * > &trace_fes) const
void ComputeSolution(const Vector &sc_sol, Vector &sol) const
BlockMatrix & GetSchurMatrix_r()
Return the serial 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 ReduceSolution(const Vector &sol, Vector &sc_sol) const
BlockMatrix & GetSchurMatrixElim_r()
Return the eliminated part of the serial Schur complement matrix.
Specialization of the ComplexOperator built from a pair of Dense Matrices. The purpose of this specia...
Mimic the action of a complex operator using two real operators.
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)