Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Özgür Ozan Sen
ogs
Commits
3a6c2bf0
Commit
3a6c2bf0
authored
10 years ago
by
wenqing
Browse files
Options
Downloads
Patches
Plain Diff
added a member for quiting program
parent
87529fce
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MathLib/LinAlg/PETSc/PETScLinearSolver.cpp
+2
-8
2 additions, 8 deletions
MathLib/LinAlg/PETSc/PETScLinearSolver.cpp
MathLib/LinAlg/PETSc/PETScLinearSolver.h
+16
-8
16 additions, 8 deletions
MathLib/LinAlg/PETSc/PETScLinearSolver.h
with
18 additions
and
16 deletions
MathLib/LinAlg/PETSc/PETScLinearSolver.cpp
+
2
−
8
View file @
3a6c2bf0
...
...
@@ -60,7 +60,7 @@ bool PETScLinearSolver::solve(const PETScVector &b, PETScVector &x)
PetscPrintf
(
PETSC_COMM_WORLD
,
"
\n
Linear solver %s with %s preconditioner"
,
ksp_type
,
pc_type
);
i
nt
its
;
PetscI
nt
its
;
KSPGetIterationNumber
(
_solver
,
&
its
);
PetscPrintf
(
PETSC_COMM_WORLD
,
"
\n
Convergence in %d iterations.
\n
"
,
its
);
PetscPrintf
(
PETSC_COMM_WORLD
,
"
\n
================================================
\n
"
);
...
...
@@ -68,10 +68,10 @@ bool PETScLinearSolver::solve(const PETScVector &b, PETScVector &x)
else
if
(
reason
==
KSP_DIVERGED_ITS
)
{
PetscPrintf
(
PETSC_COMM_WORLD
,
"
\n
Warning: maximum number of iterations reached.
\n
"
);
converged
=
false
;
}
else
{
converged
=
false
;
if
(
reason
==
KSP_DIVERGED_INDEFINITE_PC
)
{
PetscPrintf
(
PETSC_COMM_WORLD
,
"
\n
Divergence because of indefinite preconditioner,"
);
...
...
@@ -82,7 +82,6 @@ bool PETScLinearSolver::solve(const PETScVector &b, PETScVector &x)
PetscPrintf
(
PETSC_COMM_WORLD
,
"
\n
KSPBICG method was detected so the method could not continue to enlarge the Krylov space."
);
PetscPrintf
(
PETSC_COMM_WORLD
,
"
\n
Try to run again with another solver.
\n
"
);
}
else
if
(
reason
==
KSP_DIVERGED_NONSYMMETRIC
)
{
PetscPrintf
(
PETSC_COMM_WORLD
,
"
\n
Matrix or preconditioner is unsymmetric but KSP requires symmetric.
\n
"
);
...
...
@@ -91,11 +90,6 @@ bool PETScLinearSolver::solve(const PETScVector &b, PETScVector &x)
{
PetscPrintf
(
PETSC_COMM_WORLD
,
"
\n
Divergence detected, use command option -ksp_monitor or -log_summary to check the details.
\n
"
);
}
PetscPrintf
(
PETSC_COMM_WORLD
,
"
\n
Linear solver (PETSc KSP) failed, quit now.
\n
"
);
KSPDestroy
(
&
_solver
);
PetscFinalize
();
std
::
exit
(
EXIT_FAILURE
);
}
#ifdef TEST_MEM_PETSC
...
...
This diff is collapsed.
Click to expand it.
MathLib/LinAlg/PETSc/PETScLinearSolver.h
+
16
−
8
View file @
3a6c2bf0
...
...
@@ -52,18 +52,13 @@ class PETScLinearSolver
/*!
Solve a system of equations.
\param b The right hand of the equations.
\param b The right hand
side
of the equations.
\param x The solutions to be solved.
\return true: converged, false: diverged due to exceeding
the maximum iterations.
\return true: converged, false: diverged.
*/
bool
solve
(
const
PETScVector
&
b
,
PETScVector
&
x
);
/*!
\brief Get number of iterations.
If function solve(...) returns false, the return value is
exactly the maximum iterations.
*/
/// Get number of iterations.
PetscInt
getNumberOfIterations
()
const
{
PetscInt
its
=
0
;
...
...
@@ -71,6 +66,19 @@ class PETScLinearSolver
return
its
;
}
/*!
\brief Function used to prepare quiting of program
Release memory and conclude the program before exit.
It must be called before exit() being called after solver fails
to converge.
*/
void
Finalize
()
{
PetscPrintf
(
PETSC_COMM_WORLD
,
"
\n
Linear solver (PETSc KSP) failed, quit now.
\n
"
);
KSPDestroy
(
&
_solver
);
PetscFinalize
();
}
private
:
/// Matrix, kept as a member only for solving successive linear equation
/// that preconditioner matrix may vary.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment