G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsScaledDirichletPrec.h
Go to the documentation of this file.
1
14#pragma once
15
16#include <gsSolver/gsMatrixOp.h>
18
19namespace gismo
20{
21
77template< typename T >
79{
81 typedef memory::shared_ptr<Op> OpPtr;
84 typedef memory::shared_ptr<JumpMatrix> JumpMatrixPtr;
86public:
87
90 void reserve( index_t n )
91 {
92 m_jumpMatrices.reserve(n);
93 m_localSchurOps.reserve(n);
94 m_localScaling.reserve(n);
95 }
96
108 {
109 m_jumpMatrices.push_back(give(jumpMatrix));
110 m_localSchurOps.push_back(give(localSchurOp));
111 m_localScaling.push_back(Matrix());
112 }
113
114 // Adds a new subdomain
115 // Documented in comment above
116 void addSubdomain( std::pair<JumpMatrix,OpPtr> data )
117 { addSubdomain(data.first.moveToPtr(), give(data.second)); }
118
121 const JumpMatrixPtr& jumpMatrix(index_t k) const { return m_jumpMatrices[k]; }
122
125 const OpPtr& localSchurOps(index_t k) const { return m_localSchurOps[k]; }
126
129 const Matrix& localScaling(index_t k) const { return m_localScaling[k]; }
130
138 static gsSortedVector<index_t> skeletonDofs( const JumpMatrix& jumpMatrix );
139
144 static JumpMatrix restrictJumpMatrix( const JumpMatrix& jumpMatrix, const std::vector<index_t>& dofs );
145
148 struct Blocks { SparseMatrix A00, A01, A10, A11; };
149
157 static Blocks matrixBlocks( const SparseMatrix& localMatrix, const std::vector<index_t>& dofs );
158
164
176 static OpPtr schurComplement( const SparseMatrix& localMatrix, const std::vector<index_t>& dofs )
177 {
178 Blocks blocks = matrixBlocks(localMatrix, dofs);
179 return schurComplement( blocks, makeSparseCholeskySolver(blocks.A11) );
180 }
181
195 static std::pair<JumpMatrix,OpPtr> restrictToSkeleton(
196 const JumpMatrix& jumpMatrix,
197 const SparseMatrix& localMatrix,
198 const std::vector<index_t>& dofs
199 )
200 { return std::pair<JumpMatrix,OpPtr>(restrictJumpMatrix(jumpMatrix,dofs),schurComplement(localMatrix,dofs)); }
201
206 {
207 GISMO_ASSERT( !m_jumpMatrices.empty(), "gsScaledDirichletPrec: Number of Lagrange multipliers "
208 "can only be determined if there are jump matrices.");
209 return m_jumpMatrices[0]->rows();
210 }
211
217
221 OpPtr preconditioner() const;
222
223public:
224 std::vector<JumpMatrixPtr> m_jumpMatrices;
225 std::vector<OpPtr> m_localSchurOps;
226 std::vector<Matrix> m_localScaling;
227};
228
229} // namespace gismo
230
231#ifndef GISMO_BUILD_LIB
232#include GISMO_HPP_HEADER(gsScaledDirichletPrec.hpp)
233#endif
Simple abstract class for discrete operators.
Definition gsLinearOperator.h:29
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
This class represents the scaled Dirichlet preconditioner for a IETI problem.
Definition gsScaledDirichletPrec.h:79
static OpPtr schurComplement(const SparseMatrix &localMatrix, const std::vector< index_t > &dofs)
Computes the Schur complement of the matrix with respect to the given dofs using a sparse Cholesky so...
Definition gsScaledDirichletPrec.h:176
gsMatrix< T > Matrix
Matrix type.
Definition gsScaledDirichletPrec.h:85
Matrix & localScaling(index_t k)
Access the local scaling matrix (as row vector)
Definition gsScaledDirichletPrec.h:128
OpPtr preconditioner() const
This returns the preconditioner as gsLinearOperator.
Definition gsScaledDirichletPrec.hpp:176
std::vector< OpPtr > m_localSchurOps
The local Schur complements .
Definition gsScaledDirichletPrec.h:225
JumpMatrixPtr & jumpMatrix(index_t k)
Access the jump matrix.
Definition gsScaledDirichletPrec.h:120
memory::shared_ptr< Op > OpPtr
Shared pointer to linear operator.
Definition gsScaledDirichletPrec.h:81
void addSubdomain(JumpMatrixPtr jumpMatrix, OpPtr localSchurOp)
Definition gsScaledDirichletPrec.h:107
OpPtr & localSchurOps(index_t k)
Access the local Schur complements operator.
Definition gsScaledDirichletPrec.h:124
std::vector< JumpMatrixPtr > m_jumpMatrices
The jump matrices .
Definition gsScaledDirichletPrec.h:224
void reserve(index_t n)
Reserves the memory required to store the given number of subdomain.
Definition gsScaledDirichletPrec.h:90
std::vector< Matrix > m_localScaling
The diagonal entries of as vectors.
Definition gsScaledDirichletPrec.h:226
static std::pair< JumpMatrix, OpPtr > restrictToSkeleton(const JumpMatrix &jumpMatrix, const SparseMatrix &localMatrix, const std::vector< index_t > &dofs)
Definition gsScaledDirichletPrec.h:195
gsLinearOperator< T > Op
Linear operator.
Definition gsScaledDirichletPrec.h:80
static JumpMatrix restrictJumpMatrix(const JumpMatrix &jumpMatrix, const std::vector< index_t > &dofs)
Restricts the jump matrix to the given dofs.
Definition gsScaledDirichletPrec.hpp:36
gsSparseMatrix< T > SparseMatrix
Sparse matrix type.
Definition gsScaledDirichletPrec.h:82
gsSparseMatrix< T, RowMajor > JumpMatrix
Sparse matrix type for jumps.
Definition gsScaledDirichletPrec.h:83
static OpPtr schurComplement(Blocks matrixBlocks, OpPtr solver)
Computes the Schur complement with respect to the block A11 of matrixBlocks.
Definition gsScaledDirichletPrec.hpp:135
void setupMultiplicityScaling()
This sets up the member vector localScaling based on multiplicity scaling.
Definition gsScaledDirichletPrec.hpp:149
static Blocks matrixBlocks(const SparseMatrix &localMatrix, const std::vector< index_t > &dofs)
Computes the matrix blocks with respect to the given dofs.
Definition gsScaledDirichletPrec.hpp:64
memory::shared_ptr< JumpMatrix > JumpMatrixPtr
Shared pointer to sparse matrix type for jumps.
Definition gsScaledDirichletPrec.h:84
static gsSortedVector< index_t > skeletonDofs(const JumpMatrix &jumpMatrix)
Extracts the skeleton dofs from the jump matrix.
Definition gsScaledDirichletPrec.hpp:25
index_t nLagrangeMultipliers() const
Returns the number of Lagrange multipliers.
Definition gsScaledDirichletPrec.h:205
Sparse matrix class, based on gsEigen::SparseMatrix.
Definition gsSparseMatrix.h:139
#define index_t
Definition gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Simple adapter classes to use matrices or linear solvers as gsLinearOperators.
An std::vector with sorting capabilities.
The G+Smo namespace, containing all definitions for the library.
S give(S &x)
Definition gsMemory.h:266
Definition gsScaledDirichletPrec.h:148