Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
148d583e
Commit
148d583e
authored
12 years ago
by
Sebastien Blaise
Browse files
Options
Downloads
Patches
Plain Diff
PETSc preconditioning not done when matrix is not modified
parent
ca80ad25
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Solver/linearSystemPETSc.cpp
+10
-5
10 additions, 5 deletions
Solver/linearSystemPETSc.cpp
Solver/linearSystemPETSc.h
+2
-2
2 additions, 2 deletions
Solver/linearSystemPETSc.h
Solver/linearSystemPETSc.hpp
+10
-5
10 additions, 5 deletions
Solver/linearSystemPETSc.hpp
with
22 additions
and
12 deletions
Solver/linearSystemPETSc.cpp
+
10
−
5
View file @
148d583e
...
...
@@ -61,6 +61,7 @@ void linearSystemPETScBlockDouble::addToMatrix(int row, int col,
modval
(
jj
,
ii
)
=
buff
;
}
#endif
_matrixModified
=
true
;
}
void
linearSystemPETScBlockDouble
::
addToRightHandSide
(
int
row
,
...
...
@@ -199,14 +200,17 @@ int linearSystemPETScBlockDouble::systemSolve()
{
if
(
!
_kspAllocated
)
_kspCreate
();
if
(
_parameters
[
"matrix_reuse"
]
==
"same_sparsity"
)
KSPSetOperators
(
_ksp
,
_a
,
_a
,
SAME_NONZERO_PATTERN
);
else
if
(
_parameters
[
"matrix_reuse"
]
==
"same_matrix"
)
if
(
!
_matrixModified
||
_parameters
[
"matrix_reuse"
]
==
"same_matrix"
)
KSPSetOperators
(
_ksp
,
_a
,
_a
,
SAME_PRECONDITIONER
);
else
if
(
_parameters
[
"matrix_reuse"
]
==
"same_sparsity"
)
KSPSetOperators
(
_ksp
,
_a
,
_a
,
SAME_NONZERO_PATTERN
);
else
KSPSetOperators
(
_ksp
,
_a
,
_a
,
DIFFERENT_NONZERO_PATTERN
);
MatAssemblyBegin
(
_a
,
MAT_FINAL_ASSEMBLY
);
MatAssemblyEnd
(
_a
,
MAT_FINAL_ASSEMBLY
);
if
(
_matrixModified
&&
_parameters
[
"matrix_reuse"
]
!=
"same_matrix"
){
MatAssemblyBegin
(
_a
,
MAT_FINAL_ASSEMBLY
);
MatAssemblyEnd
(
_a
,
MAT_FINAL_ASSEMBLY
);
}
_matrixModified
=
false
;
VecAssemblyBegin
(
_b
);
VecAssemblyEnd
(
_b
);
KSPSolve
(
_ksp
,
_b
,
_x
);
...
...
@@ -289,6 +293,7 @@ linearSystemPETScBlockDouble::linearSystemPETScBlockDouble(bool sequential)
_entriesPreAllocated
=
false
;
_isAllocated
=
false
;
_kspAllocated
=
false
;
_matrixModified
=
true
;
_sequential
=
sequential
;
}
...
...
This diff is collapsed.
Click to expand it.
Solver/linearSystemPETSc.h
+
2
−
2
View file @
148d583e
...
...
@@ -48,7 +48,7 @@ class linearSystemPETSc : public linearSystem<scalar> {
protected:
MPI_Comm
_comm
;
int
_blockSize
;
// for block Matrix
bool
_isAllocated
,
_kspAllocated
,
_entriesPreAllocated
;
bool
_isAllocated
,
_kspAllocated
,
_entriesPreAllocated
,
_matrixModified
;
Mat
_a
;
Vec
_b
,
_x
;
KSP
_ksp
;
...
...
@@ -82,7 +82,7 @@ class linearSystemPETSc : public linearSystem<scalar> {
};
class
linearSystemPETScBlockDouble
:
public
linearSystem
<
fullMatrix
<
double
>
>
{
bool
_entriesPreAllocated
,
_isAllocated
,
_kspAllocated
;
bool
_entriesPreAllocated
,
_isAllocated
,
_kspAllocated
,
_matrixModified
;
sparsityPattern
_sparsity
;
Mat
_a
;
Vec
_b
,
_x
;
...
...
This diff is collapsed.
Click to expand it.
Solver/linearSystemPETSc.hpp
+
10
−
5
View file @
148d583e
...
...
@@ -40,6 +40,7 @@ linearSystemPETSc<scalar>::linearSystemPETSc(MPI_Comm com)
_isAllocated
=
false
;
_blockSize
=
0
;
_kspAllocated
=
false
;
_matrixModified
=
true
;
}
template
<
class
scalar
>
...
...
@@ -212,6 +213,7 @@ void linearSystemPETSc<scalar>::addToMatrix(int row, int col, const scalar &val)
PetscInt
i
=
row
,
j
=
col
;
PetscScalar
s
=
val
;
_try
(
MatSetValues
(
_a
,
1
,
&
i
,
1
,
&
j
,
&
s
,
ADD_VALUES
));
_matrixModified
=
true
;
}
template
<
class
scalar
>
...
...
@@ -272,14 +274,17 @@ int linearSystemPETSc<scalar>::systemSolve()
{
if
(
!
_kspAllocated
)
_kspCreate
();
if
(
linearSystem
<
scalar
>::
_parameters
[
"matrix_reuse"
]
==
"same_sparsity"
)
_try
(
KSPSetOperators
(
_ksp
,
_a
,
_a
,
SAME_NONZERO_PATTERN
));
else
if
(
linearSystem
<
scalar
>::
_parameters
[
"matrix_reuse"
]
==
"same_matrix"
)
if
(
!
_matrixModified
||
linearSystem
<
scalar
>::
_parameters
[
"matrix_reuse"
]
==
"same_matrix"
)
_try
(
KSPSetOperators
(
_ksp
,
_a
,
_a
,
SAME_PRECONDITIONER
));
else
if
(
linearSystem
<
scalar
>::
_parameters
[
"matrix_reuse"
]
==
"same_sparsity"
)
_try
(
KSPSetOperators
(
_ksp
,
_a
,
_a
,
SAME_NONZERO_PATTERN
));
else
_try
(
KSPSetOperators
(
_ksp
,
_a
,
_a
,
DIFFERENT_NONZERO_PATTERN
));
_try
(
MatAssemblyBegin
(
_a
,
MAT_FINAL_ASSEMBLY
));
_try
(
MatAssemblyEnd
(
_a
,
MAT_FINAL_ASSEMBLY
));
if
(
_matrixModified
&&
_parameters
[
"matrix_reuse"
]
!=
"same_matrix"
){
_try
(
MatAssemblyBegin
(
_a
,
MAT_FINAL_ASSEMBLY
));
_try
(
MatAssemblyEnd
(
_a
,
MAT_FINAL_ASSEMBLY
));
}
_matrixModified
=
false
;
/*MatInfo info;
MatGetInfo(_a, MAT_LOCAL, &info);
printf("mallocs %.0f nz_allocated %.0f nz_used %.0f nz_unneeded %.0f\n", info.mallocs, info.nz_allocated, info.nz_used, info.nz_unneeded);*/
...
...
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