Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
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
pystencils
Commits
3e707253
Commit
3e707253
authored
7 years ago
by
Martin Bauer
Browse files
Options
Downloads
Patches
Plain Diff
Advanced boundary handling for lbmpy
parent
ffd7b240
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
plot2d.py
+0
-43
0 additions, 43 deletions
plot2d.py
with
0 additions
and
43 deletions
plot2d.py
+
0
−
43
View file @
3e707253
...
...
@@ -53,49 +53,6 @@ def multipleScalarFields(field, **kwargs):
colorbar
()
def
plotBoundaryHandling
(
boundaryHandling
,
boundaryNameToColor
=
None
):
"""
Shows boundary cells
:param boundaryHandling: instance of :class:`lbmpy.boundaries.BoundaryHandling`
:param boundaryNameToColor: optional dictionary mapping boundary names to colors
"""
import
matplotlib
import
matplotlib.pyplot
as
plt
if
len
(
boundaryHandling
.
flagField
.
shape
)
!=
2
:
raise
NotImplementedError
(
"
Only implemented for 2D boundary handlings
"
)
if
boundaryNameToColor
:
fixedColors
=
boundaryNameToColor
else
:
fixedColors
=
{
'
fluid
'
:
'
#1f77ff11
'
,
'
noSlip
'
:
'
#000000
'
}
boundaryNames
=
[]
flagValues
=
[]
for
name
,
flag
in
sorted
(
boundaryHandling
.
getBoundaryNameToFlagDict
().
items
(),
key
=
lambda
l
:
l
[
1
]):
boundaryNames
.
append
(
name
)
flagValues
.
append
(
flag
)
defaultCycler
=
matplotlib
.
rcParams
[
'
axes.prop_cycle
'
]
colorValues
=
[
fixedColors
[
name
]
if
name
in
fixedColors
else
cycle
[
'
color
'
]
for
cycle
,
name
in
zip
(
defaultCycler
,
boundaryNames
)]
cmap
=
matplotlib
.
colors
.
ListedColormap
(
colorValues
)
bounds
=
np
.
array
(
flagValues
,
dtype
=
float
)
-
0.5
bounds
=
list
(
bounds
)
+
[
bounds
[
-
1
]
+
1
]
norm
=
matplotlib
.
colors
.
BoundaryNorm
(
bounds
,
cmap
.
N
)
flagField
=
boundaryHandling
.
flagField
.
swapaxes
(
0
,
1
)
plt
.
imshow
(
flagField
,
interpolation
=
'
none
'
,
origin
=
'
lower
'
,
cmap
=
cmap
,
norm
=
norm
)
patches
=
[
matplotlib
.
patches
.
Patch
(
color
=
color
,
label
=
name
)
for
color
,
name
in
zip
(
colorValues
,
boundaryNames
)]
plt
.
axis
(
'
equal
'
)
plt
.
legend
(
handles
=
patches
,
bbox_to_anchor
=
(
1.02
,
0.5
),
loc
=
2
,
borderaxespad
=
0.
)
# ------------------------------------------- Animations ---------------------------------------------------------------
...
...
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