18template<
class T,
int MatOrder>
22#ifdef GISMO_WITH_PETSC
23 if (m_paramsRef.options().getSwitch(
"parallel"))
25 MPI_Barrier(PETSC_COMM_WORLD);
36template<
class T,
int MatOrder>
40#ifdef GISMO_WITH_PETSC
41 if (m_paramsRef.options().getSwitch(
"parallel"))
43 MPI_Barrier(PETSC_COMM_WORLD);
48 return m_clock.stop();
53template<
class T,
int MatOrder>
56 GISMO_ASSERT(solution.rows() > 0,
"The solution in applySolver() is empty!");
59 this->applySolver(mat, rhs, newSol);
61 real_t time0 = stopwatchStart();
62 solution.topRows(usize) = alpha_u * newSol.topRows(usize) + (1 - alpha_u)*solution.topRows(usize);
63 solution.bottomRows(pdofs) = alpha_p * newSol.bottomRows(pdofs) + (1 - alpha_p)*solution.bottomRows(pdofs);
64 real_t time1 = stopwatchStop();
66 m_solveT += time1 - time0;
74template<
class T,
int MatOrder>
77 real_t time0 = stopwatchStart();
78 m_solver.analyzePattern(mat);
79 real_t time1 = stopwatchStop();
81 m_setupT += time1 - time0;
85template<
class T,
int MatOrder>
88 real_t time0 = stopwatchStart();
89 m_solver.factorize(mat);
91 real_t time1 = stopwatchStop();
93 solution = m_solver.solve(rhs);
94 real_t time2 = stopwatchStop();
96 m_setupT += time1 - time0;
97 m_solveT += time2 - time1;
102template<
class T,
int MatOrder,
class SolverType>
105 real_t time0 = stopwatchStart();
107 real_t time1 = stopwatchStop();
109 m_setupT += time1 - time0;
112template<
class T,
int MatOrder,
class SolverType>
115 real_t time0 = stopwatchStart();
117 this->setupPreconditioner(mat);
119 SolverType solver(mat, m_precPtr);
120 solver.setMaxIterations(m_paramsRef.options().getInt(
"lin.maxIt"));
121 solver.setTolerance(m_paramsRef.options().getReal(
"lin.tol"));
123 real_t time1 = stopwatchStop();
125 solver.solve(rhs, solution);
127 real_t time2 = stopwatchStop();
129 m_setupT += time1 - time0;
130 m_solveT += time2 - time1;
132 m_linIterVector.push_back(solver.iterations());
137template<
class T,
int MatOrder,
class SolverType>
140 real_t time0 = stopwatchStart();
143 m_matrices.insert(std::make_pair(
"matNS", mat));
144 m_matrices.insert(std::make_pair(
"matMu", m_assemblerPtr->getMassMatrix(0)));
145 m_matrices.insert(std::make_pair(
"matMp", m_assemblerPtr->getMassMatrix(1)));
147 if (m_precType.substr(0, 3) ==
"PCD")
149 gsWarn <<
"PCD preconditioner not fully implemented yet, using LSC instead.";
150 m_precType.replace(0, 3,
"LSC");
158 m_precPtr = gsINSPreconditioner<T, MatOrder>::make(m_precType, m_matrices, m_precOpt);
160 real_t time1 = stopwatchStop();
162 m_setupT += time1 - time0;
virtual void applySolver(const gsSparseMatrix< T, MatOrder > &mat, const gsMatrix< T > &rhs, gsMatrix< T > &solution)
Solve the linear system.
Definition gsFlowLinSystSolver.hpp:86
virtual void setupSolver(const gsSparseMatrix< T, MatOrder > &mat)
Setup the linear solver for a given matrix.
Definition gsFlowLinSystSolver.hpp:75
virtual void setupPreconditioner(const gsSparseMatrix< T, MatOrder > &mat)
Setup the preconditioner for a given matrix.
Definition gsFlowLinSystSolver.hpp:138
virtual void setupPreconditioner(const gsSparseMatrix< T, MatOrder > &mat)
Setup the preconditioner for a given matrix.
Definition gsFlowLinSystSolver.hpp:103
virtual void applySolver(const gsSparseMatrix< T, MatOrder > &mat, const gsMatrix< T > &rhs, gsMatrix< T > &solution)
Solve the linear system.
Definition gsFlowLinSystSolver.hpp:113
virtual void applySolver(const gsSparseMatrix< T, MatOrder > &mat, const gsMatrix< T > &rhs, gsMatrix< T > &solution)
Solve the linear system.
Definition gsFlowLinSystSolver.h:69
T stopwatchStop()
Stop measuring time (decides whether to use gsStopwatch or MPI_Wtime)
Definition gsFlowLinSystSolver.hpp:37
T stopwatchStart()
Start measuring time (decides whether to use gsStopwatch or MPI_Wtime)
Definition gsFlowLinSystSolver.hpp:19
Gauss-Seidel preconditioner.
Definition gsSimplePreconditioners.h:279
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Sparse matrix class, based on gsEigen::SparseMatrix.
Definition gsSparseMatrix.h:139
@ symmetric
one total step is = one forward + one backward
Definition gsSimplePreconditioners.h:268
#define gsWarn
Definition gsDebug.h:50
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
The G+Smo namespace, containing all definitions for the library.