IFEM 90A354
PETScSolParams.h
Go to the documentation of this file.
1// $Id$
2//==============================================================================
14//==============================================================================
15
16#ifndef _PETSC_SOL_PARAMS_H
17#define _PETSC_SOL_PARAMS_H
18
19#include "LinSolParams.h"
20#include "PETScSupport.h"
21
22#include <set>
23#include <string>
24#include <vector>
25
26class ProcessAdm;
27class SettingMap;
28
29typedef std::vector<int> IntVec;
30typedef std::vector<IntVec> IntMat;
31typedef std::vector<std::string> StringVec;
32typedef std::vector<StringVec> StringMat;
33typedef std::vector<IS> ISVec;
34typedef std::vector<ISVec> ISMat;
35
37enum SchurPrec { SIMPLE, MSIMPLER, PCD };
38
39
47{
48public:
52 PETScSolParams(const LinSolParams& spar, const ProcessAdm& padm) :
53 params(spar), adm(padm)
54 {}
55
58 {
59 }
60
67 void setupPC(PC& pc, size_t block,
68 const std::string& prefix,
69 const std::set<int>& blockEqs,
70 bool setup);
71
73 size_t getNoBlocks() const { return params.getNoBlocks(); }
74
76 const LinSolParams::BlockParams& getBlock(size_t i) const { return params.getBlock(i); }
77
79 int getIntValue(const std::string& key) const { return params.getIntValue(key); }
80
82 double getDoubleValue(const std::string& key) const { return params.getDoubleValue(key); }
83
85 std::string getStringValue(const std::string& key) const { return params.getStringValue(key); }
86
88 bool hasValue(const std::string& key) const { return params.hasValue(key); }
89
92
93protected:
99 bool addDirSmoother(PC pc, const Mat& P,
100 int iBlock, const ISMat& dirIndexSet);
101
105 void setMLOptions(const std::string& prefix, const SettingMap& map);
106
110 void setGAMGOptions(const std::string& prefix, const SettingMap& map);
111
115 void setHypreOptions(const std::string& prefix, const SettingMap& map);
116
121 void setupCoarseSolver(PC& pc, const std::string& prefix, const SettingMap& map);
122
129 void setupSmoothers(PC& pc, size_t iBlock,
130 const ISMat& dirIndexSet,
131 const std::set<int>& blockEqs,
132 bool setup);
133
141 void setupAdditiveSchwarz(PC& pc, size_t block,
142 bool asmlu, bool smoother,
143 const std::set<int>& blockEqs,
144 bool setup);
145
148};
149
150#endif
Linear solver parameters for PETSc matrices.
std::vector< ISVec > ISMat
Index set matrix.
Definition PETScMatrix.h:30
std::vector< ISVec > ISMat
Index set matrix.
Definition PETScSolParams.h:34
std::vector< StringVec > StringMat
String matrix.
Definition PETScSolParams.h:32
std::vector< IntVec > IntMat
Integer matrix.
Definition PETScSolParams.h:30
std::vector< std::string > StringVec
String vector.
Definition PETScSolParams.h:31
std::vector< int > IntVec
Integer vector.
Definition PETScSolParams.h:29
SchurPrec
Schur preconditioner methods.
Definition PETScSolParams.h:37
std::vector< IS > ISVec
Index set vector.
Definition PETScSolParams.h:33
IFEM PETSc support.
Linear solver settings for a block of the linear system.
Definition LinSolParams.h:80
Class for linear solver parameters.
Definition LinSolParams.h:67
const BlockParams & getBlock(size_t i) const
Obtain settings for a given block.
Definition LinSolParams.h:106
size_t getNoBlocks() const
Number of blocks in matrix system.
Definition LinSolParams.h:103
LinAlg::LinearSystemType getLinSysType() const
Returns the linear system type.
Definition LinSolParams.h:109
Class for PETSc solver parameters.
Definition PETScSolParams.h:47
void setupAdditiveSchwarz(PC &pc, size_t block, bool asmlu, bool smoother, const std::set< int > &blockEqs, bool setup)
Setup an additive Schwarz preconditioner.
Definition PETScSolParams.C:345
size_t getNoBlocks() const
Obtain number of blocks.
Definition PETScSolParams.h:73
LinAlg::LinearSystemType getLinSysType() const
Returns the linear system type.
Definition PETScSolParams.h:91
int getIntValue(const std::string &key) const
Get integer setting.
Definition PETScSolParams.h:79
~PETScSolParams()
Destructor.
Definition PETScSolParams.h:57
const ProcessAdm & adm
Reference to process administrator.
Definition PETScSolParams.h:147
bool hasValue(const std::string &key) const
Get integer setting.
Definition PETScSolParams.h:88
std::string getStringValue(const std::string &key) const
Get string setting.
Definition PETScSolParams.h:85
const LinSolParams::BlockParams & getBlock(size_t i) const
Obtain settings for a given block.
Definition PETScSolParams.h:76
bool addDirSmoother(PC pc, const Mat &P, int iBlock, const ISMat &dirIndexSet)
Set directional smoother.
Definition PETScSolParams.C:94
double getDoubleValue(const std::string &key) const
Get integer setting.
Definition PETScSolParams.h:82
void setHypreOptions(const std::string &prefix, const SettingMap &map)
Set Hypre options.
Definition PETScSolParams.C:181
void setMLOptions(const std::string &prefix, const SettingMap &map)
Set ML options.
Definition PETScSolParams.C:148
void setGAMGOptions(const std::string &prefix, const SettingMap &map)
Set GAMG options.
Definition PETScSolParams.C:168
void setupSmoothers(PC &pc, size_t iBlock, const ISMat &dirIndexSet, const std::set< int > &blockEqs, bool setup)
Setup the smoothers in a multigrid.
Definition PETScSolParams.C:268
PETScSolParams(const LinSolParams &spar, const ProcessAdm &padm)
Default constructor.
Definition PETScSolParams.h:52
void setupCoarseSolver(PC &pc, const std::string &prefix, const SettingMap &map)
Setup the coarse solver in a multigrid.
Definition PETScSolParams.C:196
const LinSolParams & params
Reference to linear solver parameters.
Definition PETScSolParams.h:146
void setupPC(PC &pc, size_t block, const std::string &prefix, const std::set< int > &blockEqs, bool setup)
Set up preconditioner parameters for PC object.
Definition PETScSolParams.C:20
Class for administration of MPI processes in IFEM library.
Definition ProcessAdm.h:33
A key-value store for settings.
Definition LinSolParams.h:32
bool hasValue(const std::string &key) const
Checks if the store holds a value for a key.
Definition LinSolParams.C:56
std::string getStringValue(const std::string &key) const
Obtain a value as a string.
Definition LinSolParams.C:26
int getIntValue(const std::string &key) const
Obtain a value as an integer.
Definition LinSolParams.C:36
double getDoubleValue(const std::string &key) const
Obtain a value as an double.
Definition LinSolParams.C:46
LinearSystemType
Enum defining linear system properties.
Definition LinAlgenums.h:35