Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Aland, Sebastian
amdis
Commits
b26c7ec3
Commit
b26c7ec3
authored
Nov 14, 2011
by
Thomas Witkowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PetscSolverGlobalMatrix works now for multiple rhs.
parent
e73db218
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
20 deletions
+29
-20
AMDiS/src/parallel/PetscSolverGlobalMatrix.cc
AMDiS/src/parallel/PetscSolverGlobalMatrix.cc
+28
-18
AMDiS/src/parallel/PetscSolverGlobalMatrix.h
AMDiS/src/parallel/PetscSolverGlobalMatrix.h
+1
-2
No files found.
AMDiS/src/parallel/PetscSolverGlobalMatrix.cc
View file @
b26c7ec3
...
...
@@ -94,6 +94,20 @@ namespace AMDiS {
MatAssemblyBegin
(
petscMatrix
,
MAT_FINAL_ASSEMBLY
);
MatAssemblyEnd
(
petscMatrix
,
MAT_FINAL_ASSEMBLY
);
// === Init PETSc solver. ===
KSPCreate
(
PETSC_COMM_WORLD
,
&
solver
);
KSPGetPC
(
solver
,
&
pc
);
KSPSetOperators
(
solver
,
petscMatrix
,
petscMatrix
,
SAME_NONZERO_PATTERN
);
KSPSetTolerances
(
solver
,
0.0
,
1e-8
,
PETSC_DEFAULT
,
PETSC_DEFAULT
);
KSPSetType
(
solver
,
KSPBCGS
);
KSPMonitorSet
(
solver
,
myKSPMonitor
,
PETSC_NULL
,
0
);
KSPSetFromOptions
(
solver
);
PCSetFromOptions
(
pc
);
// Do not delete the solution vector, use it for the initial guess.
if
(
!
zeroStartVector
)
KSPSetInitialGuessNonzero
(
solver
,
PETSC_TRUE
);
MSG
(
"Fill petsc matrix needed %.5f seconds
\n
"
,
MPI
::
Wtime
()
-
wtime
);
}
...
...
@@ -138,20 +152,6 @@ namespace AMDiS {
VecAssemblyEnd
(
petscSolVec
);
}
// === Init PETSc solver. ===
KSPCreate
(
PETSC_COMM_WORLD
,
&
solver
);
KSPGetPC
(
solver
,
&
pc
);
KSPSetOperators
(
solver
,
petscMatrix
,
petscMatrix
,
SAME_NONZERO_PATTERN
);
KSPSetTolerances
(
solver
,
0.0
,
1e-8
,
PETSC_DEFAULT
,
PETSC_DEFAULT
);
KSPSetType
(
solver
,
KSPBCGS
);
KSPMonitorSet
(
solver
,
myKSPMonitor
,
PETSC_NULL
,
0
);
KSPSetFromOptions
(
solver
);
PCSetFromOptions
(
pc
);
// Do not delete the solution vector, use it for the initial guess.
if
(
!
zeroStartVector
)
KSPSetInitialGuessNonzero
(
solver
,
PETSC_TRUE
);
// PETSc.
KSPSolve
(
solver
,
petscRhsVec
,
petscSolVec
);
...
...
@@ -182,17 +182,27 @@ namespace AMDiS {
// === Destroy PETSc's variables. ===
#ifdef HAVE_PETSC_DEV
MatDestroy
(
&
petscMatrix
);
VecDestroy
(
&
petscRhsVec
);
#else
VecDestroy
(
petscRhsVec
);
#endif
}
void
PetscSolverGlobalMatrix
::
destroyMatrixData
()
{
FUNCNAME
(
"PetscSolverGlobalMatrix::destroyMatrixData()"
);
#ifdef HAVE_PETSC_DEV
MatDestroy
(
&
petscMatrix
);
KSPDestroy
(
&
solver
);
VecDestroy
(
&
petscSolVec
);
VecDestroy
(
&
petscTmpVec
);
KSPDestroy
(
&
solver
);
#else
MatDestroy
(
petscMatrix
);
Vec
Destroy
(
petscRhsVec
);
KSP
Destroy
(
solver
);
VecDestroy
(
petscSolVec
);
VecDestroy
(
petscTmpVec
);
KSPDestroy
(
solver
);
#endif
}
...
...
AMDiS/src/parallel/PetscSolverGlobalMatrix.h
View file @
b26c7ec3
...
...
@@ -50,8 +50,7 @@ namespace AMDiS {
void
solvePetscMatrix
(
SystemVector
&
vec
,
AdaptInfo
*
adaptInfo
);
void
destroyMatrixData
()
{}
void
destroyMatrixData
();
protected:
/// Creates a new non zero pattern structure for the PETSc matrix.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment