18template <
class T,
int MatOrder>
19typename gsINSPreconditioner<T, MatOrder>::uPtr gsINSPreconditioner<T, MatOrder>::make(std::string precType,
const std::map<std::string,
gsSparseMatrix<T, MatOrder> >& mat,
const gsOptionList& opt)
21 if (precType ==
"LSC_FdiagEqual")
23 else if (precType ==
"LSC_Fdiag")
25 else if (precType ==
"LSC_Fwhole")
27 else if (precType ==
"LSC_Fmod")
29 else if (precType ==
"PCD_FdiagEqual")
31 else if (precType ==
"PCD_Fdiag")
33 else if (precType ==
"PCD_Fwhole")
35 else if (precType ==
"PCD_Fmod")
37 else if (precType ==
"PCDmod_FdiagEqual")
39 else if (precType ==
"PCDmod_Fdiag")
41 else if (precType ==
"PCDmod_Fwhole")
43 else if (precType ==
"PCDmod_Fmod")
45 else if (precType ==
"AL_Fwhole")
47 else if (precType ==
"AL_Fmod")
49 else if (precType ==
"SIMPLE_FdiagEqual")
51 else if (precType ==
"SIMPLE_Fdiag")
53 else if (precType ==
"SIMPLE_Fwhole")
55 else if (precType ==
"SIMPLE_Fmod")
57 else if (precType ==
"SIMPLER_FdiagEqual")
59 else if (precType ==
"SIMPLER_Fdiag")
61 else if (precType ==
"SIMPLER_Fwhole")
63 else if (precType ==
"SIMPLER_Fmod")
65 else if (precType ==
"MSIMPLER_FdiagEqual")
67 else if (precType ==
"MSIMPLER_Fdiag")
69 else if (precType ==
"MSIMPLER_Fwhole")
71 else if (precType ==
"MSIMPLER_Fmod")
73 else if (precType ==
"StokesDiag_FdiagEqual")
75 else if (precType ==
"StokesTriang_FdiagEqual")
85 gsInfo <<
"Invalid preconditioner type, using LSC_FdiagEqual.\n";
91template <
class T,
int MatOrder>
92gsOptionList gsINSPreconditioner<T, MatOrder>::defaultOptions()
96 opt.
addInt(
"dim",
"Problem dimension", 0);
97 opt.
addReal(
"visc",
"Viscosity", 0.0);
98 opt.
addInt(
"udofs",
"Number of velocity dofs", 0);
99 opt.
addInt(
"pdofs",
"Number of pressure dofs", 0);
101 opt.
addInt(
"pcd_bcType",
"Type of BCs for Fp, Ap in PCD preconditioner", 3);
102 opt.
addReal(
"gamma",
"Parameter gamma for AL", 1.0);
103 opt.
addReal(
"alphaP",
"Pressure relaxation parameter for SIMPLE-type", 1.0);
104 opt.
addSwitch(
"lumpingM",
"Use lumped diagonal mass matrices in preconditioners",
true);
105 opt.
addSwitch(
"lumpingA",
"Use lumped diagonal blockA in SIMPLE-type preconditioners",
false);
106 opt.
addSwitch(
"pcd_assembAp",
"Assemble pressure Poisson matrix for definition of Ap in PCD",
true);
107 opt.
addSwitch(
"pcd_assembFp",
"Assemble pressure Poisson matrix for definition of Fp in PCD",
true);
109 opt.
addSwitch(
"iter",
"Subsystems iteratively",
false);
110 opt.
addInt(
"maxIt",
"Max number of iterations for inner solves", 10);
111 opt.
addReal(
"tol",
"Stopping tolerance for inner solves", 1e-2);
112 opt.
addInt(
"fill",
"Fill factor for ILUT precond (inner solves)", 2);
113 opt.
addReal(
"dropTol",
"Drop tolerance for ILUT precond (inner solves)", 1e-8);
119template <
class T,
int MatOrder>
122 int uSize = m_Finv->rows();
123 int pSize = m_Sinv->rows();
125 x.resize(uSize + pSize, 1);
128 m_Sinv->apply(input.bottomRows(pSize), tmpX);
129 x.bottomRows(pSize) = tmpX;
132 m_Bt->apply(x.bottomRows(pSize), tmp);
133 tmp = input.topRows(uSize) - tmp;
135 m_Finv->apply(tmp, tmpX);
136 x.topRows(uSize) = tmpX;
140template <
class T,
int MatOrder,
class BlockFType>
143 gsInfo <<
"Filling the extra part of Agamma matrix... ";
145 int dim = opt.
getInt(
"dim");
146 int udofs = opt.
getInt(
"udofs");
147 int pdofs = opt.
getInt(
"pdofs");
148 int uSize = dim * udofs;
149 int numDofs = uSize + pdofs;
150 real_t gamma = opt.
getReal(
"gamma");
156 presMinv.setIdentity();
157 for (
int i = 0; i < pdofs; i++)
158 presMinv.coeffRef(i, i) = 1 / presM.coeff(i, i);
163 nonZerosVector.setZero(numDofs);
166 matGammaPart.resize(numDofs, numDofs);
167 matGammaPart.reserve(nonZerosVector);
169 for (
int outer = 0; outer < Mgamma.outerSize(); ++outer)
171 matGammaPart.insert(it.row(), it.col()) = it.value();
173 matGammaPart.makeCompressed();
175 rhsGammaPart.setZero(numDofs, 1);
176 rhsGammaPart.topRows(uSize) = gamma * matNS.block(0, uSize, uSize, pdofs) * presMinv * rhs.bottomRows(pdofs);
181template <
class T,
int MatOrder,
class BlockFType>
184 gsInfo <<
"Filling the Agamma matrix... ";
189 fillALgammaPart_into(matGammaPart, rhsGammaPart, mat, rhs, opt);
191 matGamma = mat.at(
"matNS") + matGammaPart;
192 rhsGamma = rhs + rhsGammaPart;
198template <
class T,
int MatOrder,
class BlockFType>
201 int uSize = m_Finv->rows();
202 int pSize = m_Sinv->rows();
204 x.resize(uSize + pSize, 1);
207 m_Finv->apply(input.topRows(uSize), uStar);
210 tmp1.noalias() = m_B * uStar;
213 m_Sinv->apply(input.bottomRows(pSize) - tmp1, dp);
216 m_Bt->apply(dp, tmp2);
218 x.topRows(uSize).noalias() = uStar - m_Dinv * tmp2;
219 x.bottomRows(pSize) = m_alphaP * dp;
223template <
class T,
int MatOrder,
class BlockFType>
226 int uSize = m_Finv->rows();
227 int pSize = m_Sinv->rows();
229 x.resize(uSize + pSize, 1);
233 tmp1.noalias() = input.bottomRows(pSize) - m_BDinv * input.topRows(uSize);
235 m_Sinv->apply(tmp1, pStar);
239 m_Bt->apply(pStar, BtpStar);
240 m_Finv->apply(input.topRows(uSize) - BtpStar, uStar);
244 m_Sinv->apply(input.bottomRows(pSize) - m_B * uStar, dp);
247 m_Bt->apply(dp, tmp2);
249 x.topRows(uSize).noalias() = uStar - m_Dinv * tmp2;
250 x.bottomRows(pSize) = pStar + m_alphaP * dp;
254template <
class T,
int MatOrder,
class BlockFType>
257 int uSize = m_Finv->rows();
258 int pSize = m_Sinv->rows();
260 x.resize(uSize + pSize, 1);
264 tmp1.noalias() = input.bottomRows(pSize) - m_BMinv * input.topRows(uSize);
266 m_Sinv->apply(tmp1, pStar);
270 m_Bt->apply(pStar, BtpStar);
271 m_Finv->apply(input.topRows(uSize) - BtpStar, uStar);
275 m_Sinv->apply(input.bottomRows(pSize) - m_B * uStar, dp);
278 m_Bt->apply(dp, tmp2);
280 x.topRows(uSize).noalias() = uStar - m_velMinv * tmp2;
281 x.bottomRows(pSize) = pStar + m_alphaP * dp;
285template <
class T,
int MatOrder,
class BlockFType>
288 int uSize = m_Finv->rows();
289 int pSize = m_Sinv->rows();
291 x.resize(uSize + pSize, 1);
294 m_Sinv->apply(input.bottomRows(pSize), tmpX);
295 x.bottomRows(pSize) = tmpX;
297 m_Finv->apply(input.topRows(uSize), tmpX);
298 x.topRows(uSize) = tmpX;
Block triangular preconditioner for the Stokes problem.
Definition gsINSPreconditioners.h:782
Block diagonal preconditioner for the Stokes problem.
Definition gsINSPreconditioners.h:704
virtual void apply(const gsMatrix< T > &input, gsMatrix< T > &x) const
Apply the preconditioner. Computes the vector \fx = P^{-1} y\f.
Definition gsINSPreconditioners.hpp:286
Augmented Lagrangian preconditioner.
Definition gsINSPreconditioners.h:377
static void fillALmodifSystem_into(gsSparseMatrix< T, MatOrder > &matGamma, gsMatrix< T > &rhsGamma, const std::map< std::string, gsSparseMatrix< T, MatOrder > > &mat, const gsMatrix< T > &rhs, const gsOptionList &opt)
Fill the Augmented Lagrangian linear system.
Definition gsINSPreconditioners.hpp:182
static void fillALgammaPart_into(gsSparseMatrix< T, MatOrder > &matGammaPart, gsMatrix< T > &rhsGammaPart, const std::map< std::string, gsSparseMatrix< T, MatOrder > > &mat, const gsMatrix< T > &rhs, const gsOptionList &opt)
Fill the extra part of the Augmented Lagrangian linear system.
Definition gsINSPreconditioners.hpp:141
virtual void apply(const gsMatrix< T > &input, gsMatrix< T > &x) const
Apply the preconditioner. Computes the vector \fx = P^{-1} y\f.
Definition gsINSPreconditioners.hpp:120
Least-squares commutator preconditioner.
Definition gsINSPreconditioners.h:191
MSIMPLER preconditioner.
Definition gsINSPreconditioners.h:613
virtual void apply(const gsMatrix< T > &input, gsMatrix< T > &x) const
Apply the preconditioner. Computes the vector \fx = P^{-1} y\f.
Definition gsINSPreconditioners.hpp:255
Pressure convection-diffusion preconditioner.
Definition gsINSPreconditioners.h:253
Modified pressure convection-diffusion preconditioner.
Definition gsINSPreconditioners.h:315
SIMPLER preconditioner.
Definition gsINSPreconditioners.h:544
virtual void apply(const gsMatrix< T > &input, gsMatrix< T > &x) const
Apply the preconditioner. Computes the vector \fx = P^{-1} y\f.
Definition gsINSPreconditioners.hpp:224
SIMPLE preconditioner.
Definition gsINSPreconditioners.h:457
virtual void apply(const gsMatrix< T > &input, gsMatrix< T > &x) const
Apply the preconditioner. Computes the vector \fx = P^{-1} y\f.
Definition gsINSPreconditioners.hpp:199
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
void addInt(const std::string &label, const std::string &desc, const index_t &value)
Adds a option named label, with description desc and value value.
Definition gsOptionList.cpp:201
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
void addReal(const std::string &label, const std::string &desc, const Real &value)
Adds a option named label, with description desc and value value.
Definition gsOptionList.cpp:211
void addSwitch(const std::string &label, const std::string &desc, const bool &value)
Adds a option named label, with description desc and value value.
Definition gsOptionList.cpp:235
Sparse matrix class, based on gsEigen::SparseMatrix.
Definition gsSparseMatrix.h:139
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
#define gsInfo
Definition gsDebug.h:43
The G+Smo namespace, containing all definitions for the library.
gsVector< index_t > getNnzVectorPerOuter(const gsSparseMatrix< T, MatOrder > &mat)
Get a vector of nonzero entries per outer index (row or column depending on the matrix storage order)...
Definition gsFlowUtils.h:116