Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
lbmpy
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
pycodegen
lbmpy
Commits
60d1b071
Commit
60d1b071
authored
5 years ago
by
Martin Bauer
Browse files
Options
Downloads
Patches
Plain Diff
More flexible plotting of field access (AA, EsoTwist..)
parent
81c6c262
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#21068
failed
5 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lbmpy/fieldaccess.py
+14
-7
14 additions, 7 deletions
lbmpy/fieldaccess.py
lbmpy/plot.py
+5
-2
5 additions, 2 deletions
lbmpy/plot.py
with
19 additions
and
9 deletions
lbmpy/fieldaccess.py
+
14
−
7
View file @
60d1b071
...
...
@@ -202,10 +202,10 @@ class EsoTwistEvenTimeStepAccessor(PdfFieldAccessor):
# -------------------------------------------- Visualization -----------------------------------------------------------
def
visualize_field_mapping
(
axes
,
stencil
,
field_mapping
,
color
=
'
b
'
):
def
visualize_field_mapping
(
axes
,
stencil
,
field_mapping
,
inverted
=
False
,
color
=
'
b
'
):
from
lbmpy.plot
import
LbGrid
grid
=
LbGrid
(
3
,
3
)
grid
.
fill_with_default_arrows
()
grid
.
fill_with_default_arrows
(
inverted
=
inverted
)
for
field_access
,
direction
in
zip
(
field_mapping
,
stencil
):
field_position
=
stencil
[
field_access
.
index
[
0
]]
neighbor
=
field_access
.
offsets
...
...
@@ -214,7 +214,8 @@ def visualize_field_mapping(axes, stencil, field_mapping, color='b'):
grid
.
draw
(
axes
)
def
visualize_pdf_field_accessor
(
pdf_field_accessor
,
figure
=
None
):
def
visualize_pdf_field_accessor
(
pdf_field_accessor
,
title
=
True
,
read_plot_params
=
{},
write_plot_params
=
{},
figure
=
None
):
from
lbmpy.stencils
import
get_stencil
if
figure
is
None
:
...
...
@@ -232,8 +233,14 @@ def visualize_pdf_field_accessor(pdf_field_accessor, figure=None):
ax_left
=
figure
.
add_subplot
(
1
,
2
,
1
)
ax_right
=
figure
.
add_subplot
(
1
,
2
,
2
)
visualize_field_mapping
(
ax_left
,
stencil
,
pre_collision_accesses
,
color
=
'
k
'
)
visualize_field_mapping
(
ax_right
,
stencil
,
post_collision_accesses
,
color
=
'
r
'
)
if
'
color
'
not
in
read_plot_params
:
read_plot_params
[
'
color
'
]
=
'
k
'
if
'
color
'
not
in
write_plot_params
:
write_plot_params
[
'
color
'
]
=
'
r
'
ax_left
.
set_title
(
"
Read
"
)
ax_right
.
set_title
(
"
Write
"
)
visualize_field_mapping
(
ax_left
,
stencil
,
pre_collision_accesses
,
**
read_plot_params
)
visualize_field_mapping
(
ax_right
,
stencil
,
post_collision_accesses
,
**
write_plot_params
)
if
title
:
ax_left
.
set_title
(
"
Read
"
)
ax_right
.
set_title
(
"
Write
"
)
This diff is collapsed.
Click to expand it.
lbmpy/plot.py
+
5
−
2
View file @
60d1b071
...
...
@@ -139,14 +139,17 @@ class LbGrid:
self
.
annotations
[(
cell
,
arrow_position
)]
=
Text
(
arrow_end
[
0
],
arrow_end
[
1
],
annotation
,
**
annotation_kwargs
)
def
fill_with_default_arrows
(
self
,
**
kwargs
):
def
fill_with_default_arrows
(
self
,
inverted
=
False
,
**
kwargs
):
"""
Fills the complete grid with the default pdf arrows
"""
for
x
in
range
(
self
.
_xCells
):
for
y
in
range
(
self
.
_yCells
):
for
dx
in
[
-
1
,
0
,
1
]:
for
dy
in
[
-
1
,
0
,
1
]:
kwargs
.
setdefault
(
'
color
'
,
'
#bbbbbb
'
)
self
.
add_arrow
((
x
,
y
),
(
dx
,
dy
),
(
dx
,
dy
),
**
kwargs
)
if
not
inverted
:
self
.
add_arrow
((
x
,
y
),
(
dx
,
dy
),
(
dx
,
dy
),
**
kwargs
)
else
:
self
.
add_arrow
((
x
,
y
),
(
dx
,
dy
),
(
-
dx
,
-
dy
),
**
kwargs
)
def
draw
(
self
,
ax
):
"""
Draw the grid into a given matplotlib axes object
"""
...
...
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