***
Wartungsfenster jeden ersten Mittwoch vormittag im Monat
***
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
COMMICS
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Insights
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
ASC
Praetorius
COMMICS
Commits
67fb8dde
Commit
67fb8dde
authored
6 years ago
by
Carl-Martin Pfeiler
Browse files
Options
Downloads
Patches
Plain Diff
added ml, splu impl for pract. ML as default
parent
ac76e58c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
integrators/_details/interfaces/tpsPreconditioner.py
+31
-10
31 additions, 10 deletions
integrators/_details/interfaces/tpsPreconditioner.py
with
31 additions
and
10 deletions
integrators/_details/interfaces/tpsPreconditioner.py
+
31
−
10
View file @
67fb8dde
...
...
@@ -108,6 +108,7 @@ class TPSPreconditioner(_preconditionerInterface._PreconditionerInterface):
import
scipy.sparse.linalg
import
scipy.sparse
as
sp
import
numpy
as
np
import
pyamg
if
(
self
.
parameters
.
alphaPreconditioner
==
None
):
A
=
self
.
_A_stat
[:
self
.
_A_stat
.
shape
[
0
]
//
3
,
:
self
.
_A_stat
.
shape
[
0
]
//
3
]
...
...
@@ -115,16 +116,34 @@ class TPSPreconditioner(_preconditionerInterface._PreconditionerInterface):
A
=
self
.
_A_stat_precond
[:
self
.
_A_stat_precond
.
shape
[
0
]
//
3
\
,
:
self
.
_A_stat_precond
.
shape
[
0
]
//
3
]
self
.
_Compute_Q
()
metaPre
=
1.0
/
A
.
diagonal
()
metaP
=
lambda
x
:
metaPre
*
x
P
=
scipy
.
sparse
.
linalg
.
LinearOperator
(
A
.
shape
,
matvec
=
metaP
)
self
.
_prePractical
=
lambda
y
:
np
.
concatenate
((
\
scipy
.
sparse
.
linalg
.
cg
(
A
,
y
[:
y
.
size
//
3
],
tol
=
self
.
_solvetol
/
10
,
M
=
P
)[
0
],
\
scipy
.
sparse
.
linalg
.
cg
(
A
,
y
[
y
.
size
//
3
:
2
*
y
.
size
//
3
],
tol
=
self
.
_solvetol
/
10
,
M
=
P
)[
0
],
\
scipy
.
sparse
.
linalg
.
cg
(
A
,
y
[
2
*
y
.
size
//
3
:],
tol
=
self
.
_solvetol
/
10
,
M
=
P
)[
0
]))
# trying ML, SPLU, CG preconditioner, ML as default
# (CG not working well for h << lex)
# it seems ML faster, but SPLU less iterations
# way faster than true inverse, especially for large NV
opt
=
"
ml
"
# "ml", "splu"
if
opt
==
"
ml
"
:
ml
=
pyamg
.
ruge_stuben_solver
(
A
)
pre
=
ml
.
aspreconditioner
()
self
.
_prePractical
=
lambda
y
:
np
.
concatenate
((
\
(
pre
*
y
[:
y
.
size
//
3
],
pre
*
y
[
y
.
size
//
3
:
2
*
y
.
size
//
3
],
pre
*
y
[
2
*
y
.
size
//
3
:])))
elif
opt
==
"
splu
"
:
cgs
=
pyamg
.
coarse_grid_solver
(
"
splu
"
)
self
.
_prePractical
=
lambda
y
:
np
.
concatenate
((
\
(
cgs
(
A
,
y
[:
y
.
size
//
3
]),
\
cgs
(
A
,
y
[
y
.
size
//
3
:
2
*
y
.
size
//
3
]),
\
cgs
(
A
,
y
[
2
*
y
.
size
//
3
:]))))
elif
opt
==
"
cg
"
:
metaPre
=
1.0
/
A
.
diagonal
()
metaP
=
lambda
x
:
metaPre
*
x
P
=
scipy
.
sparse
.
linalg
.
LinearOperator
(
A
.
shape
,
matvec
=
metaP
)
self
.
_prePractical
=
lambda
y
:
np
.
concatenate
((
\
scipy
.
sparse
.
linalg
.
cg
(
A
,
y
[:
y
.
size
//
3
],
tol
=
self
.
_solvetol
/
10
,
M
=
P
)[
0
],
\
scipy
.
sparse
.
linalg
.
cg
(
A
,
y
[
y
.
size
//
3
:
2
*
y
.
size
//
3
],
tol
=
self
.
_solvetol
/
10
,
M
=
P
)[
0
],
\
scipy
.
sparse
.
linalg
.
cg
(
A
,
y
[
2
*
y
.
size
//
3
:],
tol
=
self
.
_solvetol
/
10
,
M
=
P
)[
0
]))
practical2D
=
lambda
x
:
\
self
.
_Q
.
dot
(
self
.
_prePractical
(
self
.
_Q
.
transpose
().
dot
(
x
)))
...
...
@@ -147,9 +166,11 @@ class TPSPreconditioner(_preconditionerInterface._PreconditionerInterface):
A
=
self
.
_A_stat_precond
[:
self
.
_A_stat_precond
.
shape
[
0
]
//
3
\
,
:
self
.
_A_stat_precond
.
shape
[
0
]
//
3
]
# trying AMG, SPLU, CG preconditioner, CG as default.
# trying ML, SPLU, CG preconditioner, ML as default
# (CG not working well for h << lex)
# it seems ML faster, but SPLU less iterations
# way faster than true inverse, especially for large NV
opt
=
"
cg
"
# "ml", "splu"
opt
=
"
ml
"
# "ml", "splu"
if
opt
==
"
ml
"
:
ml
=
pyamg
.
ruge_stuben_solver
(
A
)
pre
=
ml
.
aspreconditioner
()
...
...
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