Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-codegen
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Christian Heinigk
dune-codegen
Commits
2d8bcff3
Commit
2d8bcff3
authored
7 years ago
by
Dominic Kempf
Browse files
Options
Downloads
Patches
Plain Diff
Add block preconditioner transformation
parent
ff56a33b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/dune/perftool/ufl/transformations/blockpreconditioner.py
+82
-0
82 additions, 0 deletions
.../dune/perftool/ufl/transformations/blockpreconditioner.py
with
82 additions
and
0 deletions
python/dune/perftool/ufl/transformations/blockpreconditioner.py
0 → 100644
+
82
−
0
View file @
2d8bcff3
"""
Derive block preconditioners from residual forms
"""
from
dune.perftool.ufl.modified_terminals
import
Restriction
from
ufl.algorithms
import
MultiFunction
from
ufl.algorithms.map_integrands
import
map_integrands
import
ufl.classes
as
uc
import
itertools
class
OffDiagonalBlockSwitcher
(
MultiFunction
):
def
__init__
(
self
,
restrictions
):
self
.
restrictions
=
restrictions
self
.
res
=
Restriction
.
NONE
MultiFunction
.
__init__
(
self
)
def
expr
(
self
,
o
):
return
self
.
reuse_if_untouched
(
o
,
*
tuple
(
self
(
op
)
for
op
in
o
.
ufl_operands
))
def
positive_restricted
(
self
,
o
):
self
.
res
=
Restriction
.
POSITIVE
ret
=
self
(
o
.
ufl_operands
[
0
])
self
.
rest
=
Restriction
.
NONE
if
isinstance
(
ret
,
uc
.
Zero
):
return
ret
else
:
return
o
def
negative_restricted
(
self
,
o
):
self
.
res
=
Restriction
.
NEGATIVE
ret
=
self
(
o
.
ufl_operands
[
0
])
self
.
res
=
Restriction
.
NONE
if
isinstance
(
ret
,
uc
.
Zero
):
return
ret
else
:
return
o
def
reference_value
(
self
,
o
):
ret
=
self
(
o
.
ufl_operands
[
0
])
if
isinstance
(
ret
,
uc
.
Zero
):
return
ret
else
:
return
o
def
argument
(
self
,
o
):
if
self
.
res
==
self
.
restrictions
[
o
.
number
()]:
return
o
else
:
return
uc
.
Zero
(
shape
=
o
.
ufl_shape
,
free_indices
=
o
.
ufl_free_indices
,
index_dimensions
=
o
.
ufl_index_dimensions
)
def
list_restriction_tuples
(
diagonal
):
if
diagonal
:
yield
(
Restriction
.
NONE
,
Restriction
.
NONE
)
res
=
(
Restriction
.
POSITIVE
,
Restriction
.
NEGATIVE
)
amount
=
1
if
diagonal
else
2
for
rtup
in
itertools
.
product
(
res
,
res
):
if
len
(
set
(
rtup
))
==
amount
:
yield
rtup
def
_block_jacobian
(
form
,
diagonal
=
True
):
assert
(
len
(
form
.
arguments
())
==
2
)
forms
=
[]
for
rtup
in
list_restriction_tuples
(
diagonal
):
forms
.
append
(
map_integrands
(
OffDiagonalBlockSwitcher
(
rtup
),
form
))
return
sum
(
forms
)
def
diagonal_block_jacobian
(
form
):
return
_block_jacobian
(
form
)
def
offdiagonal_block_jacobian
(
form
):
return
_block_jacobian
(
form
,
False
)
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