40 typedef memory::shared_ptr<gsINSPrecondBlock> Ptr;
41 typedef memory::unique_ptr<gsINSPrecondBlock> uPtr;
79 virtual std::string getName()
const
106 std::vector<gsSparseSolver<T>* > m_solvers;
114 typedef memory::shared_ptr<gsINSPrecondBlockMod> Ptr;
115 typedef memory::unique_ptr<gsINSPrecondBlockMod> uPtr;
125 int dim = m_opt.
getInt(
"dim");
127 m_solvers.resize(dim);
129 for (
int i = 0; i < dim; i++)
138 for (
int i = 0; i < (int)m_solvers.size(); i++)
165template <
class T,
int MatOrder>
179 using Base::m_pSolver;
184 typedef memory::shared_ptr<gsINSPrecondBlockF> Ptr;
185 typedef memory::unique_ptr<gsINSPrecondBlockF> uPtr;
193 Base(opt), m_blockF1(matNS.block(0, 0, opt.getInt(
"udofs"), opt.getInt(
"udofs")))
197 m_pSolver->compute(m_blockF1);
222 int rows()
const {
return m_size; }
225 int cols()
const {
return m_size; }
250template <
class T,
int MatOrder>
264 using Base::m_pSolver;
268 typedef memory::shared_ptr<gsINSPrecondBlockFwhole> Ptr;
269 typedef memory::unique_ptr<gsINSPrecondBlockFwhole> uPtr;
277 Base(opt), m_blockA(matNS.block(0, 0, opt.getInt(
"dim")*opt.getInt(
"udofs"), opt.getInt(
"dim")*opt.getInt(
"udofs")))
281 m_pSolver->compute(m_blockA);
305 int rows()
const {
return m_size; }
308 int cols()
const {
return m_size; }
333template <
class T,
int MatOrder>
341 std::vector<gsSparseMatrix<T, MatOrder> > m_diagBlocks;
346 using Base::m_solvers;
347 using Base::Base::m_opt;
351 typedef memory::shared_ptr<gsINSPrecondBlockFdiag> Ptr;
352 typedef memory::unique_ptr<gsINSPrecondBlockFdiag> uPtr;
362 int dim = opt.
getInt(
"dim");
363 m_size = dim * opt.
getInt(
"udofs");
365 m_diagBlocks.resize(dim);
367 for (
int i = 0; i < dim; i++)
369 int udofs = opt.
getInt(
"udofs");
370 m_diagBlocks[i] = matNS.block(i*udofs, i*udofs, udofs, udofs);
371 m_solvers[i]->compute(m_diagBlocks[i]);
396 int rows()
const {
return m_size; }
399 int cols()
const {
return m_size; }
424template <
class T,
int MatOrder>
434 std::vector<gsSparseMatrix<T, MatOrder> > m_diagBlocks;
439 using Base::m_solvers;
440 using Base::Base::m_opt;
444 typedef memory::shared_ptr<gsINSPrecondBlockFmod> Ptr;
445 typedef memory::unique_ptr<gsINSPrecondBlockFmod> uPtr;
453 Base(opt), m_matRef(matNS)
455 int dim = opt.
getInt(
"dim");
456 int udofs = opt.
getInt(
"udofs");
457 m_size = dim * udofs;
459 m_diagBlocks.resize(dim);
461 for (
int i = 0; i < dim; i++)
463 m_diagBlocks[i] = m_matRef.block(i*udofs, i*udofs, udofs, udofs);
464 m_solvers[i]->compute(m_diagBlocks[i]);
489 int rows()
const {
return m_size; }
492 int cols()
const {
return m_size; }
505template <
class T,
int MatOrder>
518 typedef memory::shared_ptr<gsINSPrecondBlockBt> Ptr;
519 typedef memory::unique_ptr<gsINSPrecondBlockBt> uPtr;
528 int dim = opt.
getInt(
"dim");
529 int udofs = opt.
getInt(
"udofs");
530 m_mat = matNS.block(0, dim * udofs, dim * udofs, matNS.cols() - dim * udofs);
554 int rows()
const {
return m_mat.rows(); }
557 int cols()
const {
return m_mat.cols(); }
564template <
class T,
int MatOrder>
577 using Base::m_pSolver;
581 typedef memory::shared_ptr<gsINSPrecondSchurLSC> Ptr;
582 typedef memory::unique_ptr<gsINSPrecondSchurLSC> uPtr;
595 int dim = opt.
getInt(
"dim");
596 int udofs = opt.
getInt(
"udofs");
597 int uSize = dim * udofs;
598 int pdofs = opt.
getInt(
"pdofs");
609 BMinv = matNS.block(uSize, 0, pdofs, uSize) * velMinv;
610 MinvBt = velMinv * matNS.block(0, uSize, uSize, pdofs);
612 m_mat1 = BMinv * matNS.block(0, uSize, uSize, pdofs);
613 m_mat2 = BMinv * matNS.block(0, 0, uSize, uSize) * MinvBt;
615 m_pSolver->compute(m_mat1);
639 int rows()
const {
return m_mat2.rows(); }
642 int cols()
const {
return m_mat2.cols(); }
649template <
class T,
int MatOrder>
663 using Base::m_pSolver;
667 typedef memory::shared_ptr<gsINSPrecondSchurPCD> Ptr;
668 typedef memory::unique_ptr<gsINSPrecondSchurPCD> uPtr;
680 m_matAp = mat.at(
"matAp");
681 m_matFp = mat.at(
"matFp");
682 m_matMp = mat.at(
"matMp");
687 m_pSolver->compute(m_matAp);
688 m_pMassSolver->compute(m_matMp);
691 ~gsINSPrecondSchurPCD()
695 delete m_pMassSolver;
696 m_pMassSolver = NULL;
721 int rows()
const {
return m_matAp.rows(); }
724 int cols()
const {
return m_matAp.cols(); }
731template <
class T,
int MatOrder>
732class gsINSPrecondSchurPCDmod :
public gsINSPrecondSchurPCD<T, MatOrder>
736 typedef gsINSPrecondSchurPCD<T, MatOrder> Base;
743 using Base::m_pMassSolver;
744 using Base::Base::m_pSolver;
748 typedef memory::shared_ptr<gsINSPrecondSchurPCDmod> Ptr;
749 typedef memory::unique_ptr<gsINSPrecondSchurPCDmod> uPtr;
785template <
class T,
int MatOrder>
799 typedef memory::shared_ptr<gsINSPrecondSchurAL> Ptr;
800 typedef memory::unique_ptr<gsINSPrecondSchurAL> uPtr;
836 GISMO_ASSERT(input.rows() == this->rows(),
"Wrong input size.");
837 x.resize(this->rows(), 1);
839 x = - m_const * m_mat * input;
845 int rows()
const {
return m_mat.rows(); }
848 int cols()
const {
return m_mat.cols(); }
855template <
class T,
int MatOrder>
868 using Base::m_pSolver;
872 typedef memory::shared_ptr<gsINSPrecondSchurSIMPLE> Ptr;
873 typedef memory::unique_ptr<gsINSPrecondSchurSIMPLE> uPtr;
885 int dim = opt.
getInt(
"dim");
886 int udofs = opt.
getInt(
"udofs");
887 int uSize = dim * udofs;
888 int pdofs = opt.
getInt(
"pdofs");
896 m_mat = - matNS.block(uSize, 0, pdofs, uSize) * Dinv * matNS.block(0, uSize, uSize, pdofs);
898 m_pSolver->compute(m_mat);
919 GISMO_ASSERT(input.rows() == this->rows(),
"Wrong input size.");
920 x.resize(this->rows(), 1);
922 x = m_pSolver->solve(input);
928 int rows()
const {
return m_mat.rows(); }
931 int cols()
const {
return m_mat.cols(); }
938template <
class T,
int MatOrder>
951 using Base::m_pSolver;
955 typedef memory::shared_ptr<gsINSPrecondSchurMSIMPLER> Ptr;
956 typedef memory::unique_ptr<gsINSPrecondSchurMSIMPLER> uPtr;
967 int dim = opt.
getInt(
"dim");
968 int udofs = opt.
getInt(
"udofs");
969 int uSize = dim * udofs;
970 int pdofs = opt.
getInt(
"pdofs");
978 m_mat = - matNS.block(uSize, 0, pdofs, uSize) * velMinv * matNS.block(0, uSize, uSize, pdofs);
980 m_pSolver->compute(m_mat);
1001 GISMO_ASSERT(input.rows() == this->rows(),
"Wrong input size.");
1002 x.resize(this->rows(), 1);
1004 x = m_pSolver->solve(input);
1010 int rows()
const {
return m_mat.rows(); }
1013 int cols()
const {
return m_mat.cols(); }
1020template <
class T,
int MatOrder>
1034 typedef memory::shared_ptr<gsINSPrecondSchurStokes> Ptr;
1035 typedef memory::unique_ptr<gsINSPrecondSchurStokes> uPtr;
1070 GISMO_ASSERT(input.rows() == this->rows(),
"Wrong input size.");
1071 x.resize(this->rows(), 1);
1073 x = - m_visc * m_mat * input;
1079 int rows()
const {
return m_mat.rows(); }
1082 int cols()
const {
return m_mat.cols(); }
1089#ifndef GISMO_BUILD_LIB
1090#include GISMO_HPP_HEADER(gsINSPrecondBlocks.hpp)
Class for block F of block preconditioner of the form.
Definition gsINSPrecondBlocks.h:167
static uPtr make(const gsSparseMatrix< T, MatOrder > &matNS, const gsOptionList &opt)
Returns a unique pointer to a newly created instance.
Definition gsINSPrecondBlocks.h:205
gsINSPrecondBlockF(const gsSparseMatrix< T, MatOrder > &matNS, const gsOptionList &opt)
Constructor.
Definition gsINSPrecondBlocks.h:192
int cols() const
Returns the number of columns of the block.
Definition gsINSPrecondBlocks.h:225
virtual std::string getName() const
Returns the block name as a string.
Definition gsINSPrecondBlocks.h:228
void apply(const gsMatrix< T > &input, gsMatrix< T > &x) const
Apply the block. Computes the vector \fx = F^{-1} y\f.
Definition gsINSPrecondBlocks.hpp:60
int rows() const
Returns the number of rows of the block.
Definition gsINSPrecondBlocks.h:222
Base class for block F of block preconditioner of the form.
Definition gsINSPrecondBlocks.h:335
static uPtr make(const gsSparseMatrix< T, MatOrder > &matNS, const gsOptionList &opt)
Returns a unique pointer to a newly created instance.
Definition gsINSPrecondBlocks.h:380
gsINSPrecondBlockFdiag(const gsSparseMatrix< T, MatOrder > &matNS, const gsOptionList &opt)
Constructor.
Definition gsINSPrecondBlocks.h:359
int cols() const
Returns the number of columns of the block.
Definition gsINSPrecondBlocks.h:399
virtual std::string getName() const
Returns the block name as a string.
Definition gsINSPrecondBlocks.h:402
void apply(const gsMatrix< T > &input, gsMatrix< T > &x) const
Apply the block. Computes the vector \fx = F^{-1} y\f.
Definition gsINSPrecondBlocks.hpp:82
int rows() const
Returns the number of rows of the block.
Definition gsINSPrecondBlocks.h:396
Base class for block F of (modified) block preconditioner of the form.
Definition gsINSPrecondBlocks.h:426
static uPtr make(const gsSparseMatrix< T, MatOrder > &matNS, const gsOptionList &opt)
Returns a unique pointer to a newly created instance.
Definition gsINSPrecondBlocks.h:473
gsINSPrecondBlockFmod(const gsSparseMatrix< T, MatOrder > &matNS, const gsOptionList &opt)
Constructor.
Definition gsINSPrecondBlocks.h:452
int cols() const
Returns the number of columns of the block.
Definition gsINSPrecondBlocks.h:492
virtual std::string getName() const
Returns the block name as a string.
Definition gsINSPrecondBlocks.h:495
void apply(const gsMatrix< T > &input, gsMatrix< T > &x) const
Apply the block. Computes the vector \fx = F^{-1} y\f.
Definition gsINSPrecondBlocks.hpp:97
int rows() const
Returns the number of rows of the block.
Definition gsINSPrecondBlocks.h:489
Class for block F of block preconditioner of the form.
Definition gsINSPrecondBlocks.h:252
static uPtr make(const gsSparseMatrix< T, MatOrder > &matNS, const gsOptionList &opt)
Returns a unique pointer to a newly created instance.
Definition gsINSPrecondBlocks.h:289
gsINSPrecondBlockFwhole(const gsSparseMatrix< T, MatOrder > &matNS, const gsOptionList &opt)
Constructor.
Definition gsINSPrecondBlocks.h:276
int cols() const
Returns the number of columns of the block.
Definition gsINSPrecondBlocks.h:308
virtual std::string getName() const
Returns the block name as a string.
Definition gsINSPrecondBlocks.h:311
void apply(const gsMatrix< T > &input, gsMatrix< T > &x) const
Apply the block. Computes the vector \fx = F^{-1} y\f.
Definition gsINSPrecondBlocks.hpp:72
int rows() const
Returns the number of rows of the block.
Definition gsINSPrecondBlocks.h:305
Base class for block F of (modified) block preconditioner of the form.
Definition gsINSPrecondBlocks.h:99
gsINSPrecondBlockMod(const gsOptionList &opt)
Constructor.
Definition gsINSPrecondBlocks.h:122
A base class for individual blocks of block preconditioners.
Definition gsINSPrecondBlocks.h:28
void setupLinSolver(gsSparseSolver< T > &solver)
Set up the linear solver for the block.
Definition gsINSPrecondBlocks.hpp:38
gsINSPrecondBlock()
Constructor.
Definition gsINSPrecondBlocks.h:46
gsSparseSolver< T > * createLinSolver()
Returns a pointer to new linear solver (direct or iterative).
Definition gsINSPrecondBlocks.hpp:20
gsINSPrecondBlock(const gsOptionList &opt)
Constructor.
Definition gsINSPrecondBlocks.h:53
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
Class which holds a list of parameters/options, and provides easy access to them.
Definition gsOptionList.h:33
bool getSwitch(const std::string &label) const
Reads value for option label from options.
Definition gsOptionList.cpp:51
const index_t & getInt(const std::string &label) const
Reads value for option label from options.
Definition gsOptionList.cpp:37
Real getReal(const std::string &label) const
Reads value for option label from options.
Definition gsOptionList.cpp:44
Sparse matrix class, based on gsEigen::SparseMatrix.
Definition gsSparseMatrix.h:139
Abstract class for solvers. The solver interface is base on 3 methods: -compute set the system matrix...
Definition gsSparseSolver.h:67
#define GISMO_NO_IMPLEMENTATION
Definition gsDebug.h:129
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Simple abstract class for (discrete) linear operators.
Simple adapter classes to use matrices or linear solvers as gsLinearOperators.
unique_ptr< T > make_unique(T *x)
Definition gsMemory.h:198
The G+Smo namespace, containing all definitions for the library.
void diagInvMatrix_into(const gsSparseMatrix< T, MatOrder > &mat, gsSparseMatrix< T, MatOrder > &diagInv, int repeat, bool lumping=false)
Fill a diagonal approximation of an inverse matrix.
Definition gsFlowUtils.h:137