G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsBlockOp.h
Go to the documentation of this file.
1 
13 #pragma once
14 
15 #include <gsCore/gsExport.h>
16 #include <gsCore/gsLinearAlgebra.h>
18 
19 namespace gismo
20 {
21 
42 template<class T>
43 class gsBlockOp GISMO_FINAL : public gsLinearOperator<T>
44 {
45 public:
46 
48  typedef memory::shared_ptr< gsBlockOp<T> > Ptr;
49 
51  typedef memory::unique_ptr< gsBlockOp<T> > uPtr;
52 
54  typedef memory::shared_ptr< gsLinearOperator<T> > BasePtr;
55 
57  gsBlockOp(index_t nRows, index_t nCols);
58 
60  static uPtr make(index_t nRows, index_t nCols)
61  { return memory::make_unique( new gsBlockOp(nRows,nCols) ); }
62 
69  void addOperator(index_t row, index_t col, const BasePtr& op);
70 
78  const BasePtr & getOperator(index_t row, index_t col) const {
79  return m_blockPrec(row,col);
80  }
81 
87  void apply(const gsMatrix<T> & input, gsMatrix<T> & result) const;
88 
90  index_t rowBlocks() const {return m_blockPrec.rows();}
92  index_t colBlocks() const {return m_blockPrec.cols();}
93 
94  index_t rows() const {return m_blockTargetPositions.sum();}
95  index_t cols() const {return m_blockInputPositions.sum() ;}
96 
97 private:
98 
99  gsEigen::Array<BasePtr, Dynamic, Dynamic> m_blockPrec;
100 
101  //Contains the size of the target vector for each block
102  gsVector<index_t> m_blockTargetPositions;
103  //Contains the size of the input vector for each block
104  gsVector<index_t> m_blockInputPositions;
105 
106 };
107 
108 } // namespace gismo
109 
110 #ifndef GISMO_BUILD_LIB
111 #include GISMO_HPP_HEADER(gsBlockOp.hpp)
112 #endif
unique_ptr< T > make_unique(T *x)
Definition: gsMemory.h:198
index_t cols() const
Returns the number of columns of the operator.
Definition: gsBlockOp.h:95
gsBlockOp(index_t nRows, index_t nCols)
Constructor. Takes the number of blocks (nRows, nCols). Provide the contents of the blocks with addOp...
Definition: gsBlockOp.hpp:18
index_t rows() const
Returns the number of rows of the operator.
Definition: gsBlockOp.h:94
void apply(const gsMatrix< T > &input, gsMatrix< T > &result) const
Apply the correct segment of the input vector on the preconditioners in the block structure and store...
Definition: gsBlockOp.hpp:46
#define index_t
Definition: gsConfig.h:32
Handles shared library creation and other class attributes.
index_t colBlocks() const
Number of col blocks.
Definition: gsBlockOp.h:92
memory::shared_ptr< gsBlockOp< T > > Ptr
Shared pointer for gsBlockOp.
Definition: gsBlockOp.h:48
Simple class create a block operator structure.
Definition: gsBlockOp.h:43
index_t rowBlocks() const
Number of row blocks.
Definition: gsBlockOp.h:90
memory::unique_ptr< gsBlockOp< T > > uPtr
Unique pointer for gsBlockOp.
Definition: gsBlockOp.h:51
Simple abstract class for discrete operators.
Definition: gsLinearOperator.h:28
This is the main header file that collects wrappers of Eigen for linear algebra.
static uPtr make(index_t nRows, index_t nCols)
Make function returning a smart pointer.
Definition: gsBlockOp.h:60
const BasePtr & getOperator(index_t row, index_t col) const
Returns the pointer to a linear operator of a specific block (if existent)
Definition: gsBlockOp.h:78
void addOperator(index_t row, index_t col, const BasePtr &op)
Add a preconditioner to the block structure.
Definition: gsBlockOp.hpp:30
memory::shared_ptr< gsLinearOperator< T > > BasePtr
Base class.
Definition: gsBlockOp.h:54
Simple abstract class for (discrete) linear operators.