G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsScaledDirichletPrec.h
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <gsSolver/gsMatrixOp.h>
17 #include <gsUtils/gsSortedVector.h>
18 
19 namespace gismo
20 {
21 
77 template< typename T >
79 {
81  typedef memory::shared_ptr<Op> OpPtr;
84  typedef memory::shared_ptr<JumpMatrix> JumpMatrixPtr;
85  typedef gsMatrix<T> Matrix;
86 public:
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 
163  static OpPtr schurComplement( Blocks matrixBlocks, OpPtr solver );
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 
223 public:
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
Definition: gsScaledDirichletPrec.h:148
memory::shared_ptr< Op > OpPtr
Shared pointer to linear operator.
Definition: gsScaledDirichletPrec.h:81
static OpPtr schurComplement(Blocks matrixBlocks, OpPtr solver)
Computes the Schur complement with respect to the block A11 of matrixBlocks.
Definition: gsScaledDirichletPrec.hpp:135
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
void reserve(index_t n)
Reserves the memory required to store the given number of subdomain.
Definition: gsScaledDirichletPrec.h:90
Matrix & localScaling(index_t k)
Access the local scaling matrix (as row vector)
Definition: gsScaledDirichletPrec.h:128
static JumpMatrix restrictJumpMatrix(const JumpMatrix &jumpMatrix, const std::vector< index_t > &dofs)
Restricts the jump matrix to the given dofs.
Definition: gsScaledDirichletPrec.hpp:36
S give(S &x)
Definition: gsMemory.h:266
#define index_t
Definition: gsConfig.h:32
gsMatrix< T > Matrix
Matrix type.
Definition: gsScaledDirichletPrec.h:85
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
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
gsSparseMatrix< T > SparseMatrix
Sparse matrix type.
Definition: gsScaledDirichletPrec.h:82
static std::pair< JumpMatrix, OpPtr > restrictToSkeleton(const JumpMatrix &jumpMatrix, const SparseMatrix &localMatrix, const std::vector< index_t > &dofs)
Definition: gsScaledDirichletPrec.h:195
This class represents the scaled Dirichlet preconditioner for a IETI problem.
Definition: gsScaledDirichletPrec.h:78
void setupMultiplicityScaling()
This sets up the member vector localScaling based on multiplicity scaling.
Definition: gsScaledDirichletPrec.hpp:149
gsSparseMatrix< T, RowMajor > JumpMatrix
Sparse matrix type for jumps.
Definition: gsScaledDirichletPrec.h:83
void addSubdomain(JumpMatrixPtr jumpMatrix, OpPtr localSchurOp)
Definition: gsScaledDirichletPrec.h:107
gsLinearOperator< T > Op
Linear operator.
Definition: gsScaledDirichletPrec.h:80
index_t nLagrangeMultipliers() const
Returns the number of Lagrange multipliers.
Definition: gsScaledDirichletPrec.h:205
std::vector< Matrix > m_localScaling
The diagonal entries of as vectors.
Definition: gsScaledDirichletPrec.h:226
Simple abstract class for discrete operators.
Definition: gsLinearOperator.h:28
memory::shared_ptr< JumpMatrix > JumpMatrixPtr
Shared pointer to sparse matrix type for jumps.
Definition: gsScaledDirichletPrec.h:84
OpPtr & localSchurOps(index_t k)
Access the local Schur complements operator.
Definition: gsScaledDirichletPrec.h:124
An std::vector with sorting capabilities.
std::vector< JumpMatrixPtr > m_jumpMatrices
The jump matrices .
Definition: gsScaledDirichletPrec.h:224
static gsSortedVector< index_t > skeletonDofs(const JumpMatrix &jumpMatrix)
Extracts the skeleton dofs from the jump matrix.
Definition: gsScaledDirichletPrec.hpp:25
JumpMatrixPtr & jumpMatrix(index_t k)
Access the jump matrix.
Definition: gsScaledDirichletPrec.h:120
std::vector< OpPtr > m_localSchurOps
The local Schur complements .
Definition: gsScaledDirichletPrec.h:225
OpPtr preconditioner() const
This returns the preconditioner as gsLinearOperator.
Definition: gsScaledDirichletPrec.hpp:176
Simple adapter classes to use matrices or linear solvers as gsLinearOperators.