MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
blockstaticcond.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, 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 DPGWeakFrom.
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)
43
44 Array<int> dof_offsets;
45 Array<int> tdof_offsets;
46
47 Array<int> rdof_offsets;
48 Array<int> rtdof_offsets;
49
50 /** Schur complement matrix
51 S = A_ii - A_ib (A_bb)^{-1} A_bi.
52 Here (b) and (i) stand for "bubble" and "interface" respectively */
53 BlockMatrix * S = nullptr;
54 BlockMatrix * S_e = nullptr;
55
56 BlockVector * y = nullptr;
57
60
61 Array<int> rdof_edof; // Map from reduced dofs to exposed dofs
62 Array<int> ess_rtdof_list;
63
64 BlockMatrix * P = nullptr; // Block Prolongation
65 BlockMatrix * R = nullptr; // Block Restriction
66
67#ifdef MFEM_USE_MPI
68 BlockOperator * pS = nullptr;
69 BlockOperator * pS_e = nullptr;
70 BlockOperator * pP = nullptr;
71#endif
72
73 bool Parallel() const { return parallel; }
74
75
76 // tr_idx (trace dofs indices)
77 // int_idx (interior dof indices)
78 void GetReducedElementIndicesAndOffsets(int el, Array<int> & tr_idx,
79 Array<int> & int_idx,
80 Array<int> & offsets) const;
81
82 void GetReducedElementVDofs(int el, Array<int> & rdofs) const;
83 void GetElementVDofs(int el, Array<int> & vdofs) const;
84
85
86 /** S = A_ii - A_ib (A_bb)^{-1} A_bi and y = y_i - A_ib (A_bb)^{-1} y_b.
87 Here (b) and (i) stand for "bubble" and "interface" respectively */
88 void GetLocalSchurComplement(int el, const Array<int> & tr_idx,
89 const Array<int> & int_idx,
90 const DenseMatrix & elmat, const Vector & elvect,
91 DenseMatrix & rmat, Vector & rvect);
92
93 void ComputeOffsets();
94
95 void BuildProlongation();
96#ifdef MFEM_USE_MPI
97 void BuildParallelProlongation();
98#endif
99
100 // ess_tdof list for each space
101 Array<Array<int> *> ess_tdofs;
102 void FillEssTdofLists(const Array<int> & ess_tdof_list);
103
104 void ConformingAssemble(int skip_zeros);
105
106 /** Restrict a marker Array on the true FE spaces dofs to a marker Array on
107 the reduced/trace true FE spaces dofs. */
108 void ConvertMarkerToReducedTrueDofs(Array<int> & tdof_marker,
109 Array<int> & rtdof_marker);
110
111 void SetSpaces(Array<FiniteElementSpace*> & fes_);
112
113 void Init();
114
115public:
116
118
120
121 /** Assemble the contribution to the Schur complement from the given
122 element matrix 'elmat'; save the other blocks internally: A_bb_inv, A_bi,
123 and A_bi. */
124 void AssembleReducedSystem(int el, DenseMatrix &elmat,
125 Vector & elvect);
126
127 /// Finalize the construction of the Schur complement matrix.
128 void Finalize(int skip_zeros = 0);
129
130 /// Determine and save internally essential reduced true dofs.
131 void SetEssentialTrueDofs(const Array<int> &ess_tdof_list);
132
133 /// Eliminate the given reduced true dofs from the Schur complement matrix S.
134 void EliminateReducedTrueDofs(const Array<int> &ess_rtdof_list,
135 Matrix::DiagonalPolicy dpolicy);
136
137 bool HasEliminatedBC() const
138 {
139#ifndef MFEM_USE_MPI
140 return S_e;
141#else
142 return S_e || pS_e;
143#endif
144
145 }
146
147 /// Return the serial Schur complement matrix.
148 BlockMatrix &GetSchurMatrix() { return *S; }
149
150 /// Return the eliminated part of the serial Schur complement matrix.
151 BlockMatrix &GetSchurMatrixElim() { return *S_e; }
152
153#ifdef MFEM_USE_MPI
154 /// Return the parallel Schur complement matrix.
156
157 /// Return the eliminated part of the parallel Schur complement matrix.
159
161#endif
162
163 /** Form the global reduced system matrix using the given @a diag_policy.
164 This method can be called after Assemble() is called. */
166
167 /** Restrict a solution vector on the full FE space dofs to a vector on the
168 reduced/trace true FE space dofs. */
169 void ReduceSolution(const Vector &sol, Vector &sc_sol) const;
170
171 /** @brief Set the reduced solution `X` and r.h.s `B` vectors from the full
172 linear system solution `x` and r.h.s. `b` vectors.
173 This method should be called after the internal reduced essential dofs
174 have been set using SetEssentialTrueDofs() and both the Schur complement
175 and its eliminated part have been finalized. */
176 void ReduceSystem(Vector &x, Vector &X, Vector &B,
177 int copy_interior = 0) const;
178
179 /** Restrict a list of true FE space dofs to a list of reduced/trace true FE
180 space dofs. */
181 void ConvertListToReducedTrueDofs(const Array<int> &ess_tdof_list,
182 Array<int> &ess_rtdof_list) const;
183
184 /** Given a solution of the reduced system 'sc_sol' and the RHS 'b' for the
185 full linear system, compute the solution of the full system 'sol'. */
186 void ComputeSolution(const Vector &sc_sol, Vector &sol) const;
187
188};
189
190}
191
192#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
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:55
Mesh data type.
Definition mesh.hpp:56
DiagonalPolicy
Defines operator diagonal policy upon elimination of rows and/or columns.
Definition operator.hpp:48
Vector data type.
Definition vector.hpp:80