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
ea8431f5
Commit
ea8431f5
authored
4 years ago
by
Frederik Hennig
Browse files
Options
Downloads
Patches
Plain Diff
Changed SimpleExtrapolationOutflow to a link-wise approach
parent
e14f9152
No related branches found
No related tags found
1 merge request
!53
Link-Wise Extrapolation Outflow
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lbmpy/boundaries/boundaryconditions.py
+15
-13
15 additions, 13 deletions
lbmpy/boundaries/boundaryconditions.py
lbmpy_tests/test_extrapolation_outflow.py
+18
-16
18 additions, 16 deletions
lbmpy_tests/test_extrapolation_outflow.py
with
33 additions
and
29 deletions
lbmpy/boundaries/boundaryconditions.py
+
15
−
13
View file @
ea8431f5
...
...
@@ -221,10 +221,6 @@ class SimpleExtrapolationOutflow(LbBoundary):
name: optional name of the boundary.
"""
# We need each fluid cell only once, the direction of the outflow is given
# in the constructor.
single_link
=
True
def
__init__
(
self
,
normal_direction
,
stencil
,
name
=
None
):
if
isinstance
(
normal_direction
,
str
):
normal_direction
=
direction_string_to_offset
(
normal_direction
,
dim
=
len
(
stencil
[
0
]))
...
...
@@ -235,17 +231,23 @@ class SimpleExtrapolationOutflow(LbBoundary):
self
.
normal_direction
=
normal_direction
super
(
SimpleExtrapolationOutflow
,
self
).
__init__
(
name
)
def
__call__
(
self
,
f_out
,
f_in
,
dir_symbol
,
inv_dir
,
lb_method
,
index_fiel
d
):
stencil
=
lb_method
.
stencil
def
get_additional_code_nodes
(
self
,
lb_metho
d
):
"""
Return a list of code nodes that will be added in the generated code before the index field loop.
boundary_assignments
=
[]
for
i
,
stencil_dir
in
enumerate
(
stencil
):
if
all
(
n
==
0
or
n
==
-
s
for
s
,
n
in
zip
(
stencil_dir
,
self
.
normal_direction
)):
asm
=
Assignment
(
f_out
[
self
.
normal_direction
](
i
),
f_out
.
center
(
i
))
boundary_assignments
.
append
(
asm
)
Args:
lb_method: Lattice Boltzmann method. See :func:`lbmpy.creationfunctions.create_lb_method`
print
(
boundary_assignments
)
return
boundary_assignments
Returns:
list containing LbmWeightInfo and NeighbourOffsetArrays
"""
return
[
NeighbourOffsetArrays
(
lb_method
.
stencil
)]
def
__call__
(
self
,
f_out
,
f_in
,
dir_symbol
,
inv_dir
,
lb_method
,
index_field
):
neighbor_offset
=
NeighbourOffsetArrays
.
neighbour_offset
(
dir_symbol
,
lb_method
.
stencil
)
tangential_offset
=
tuple
(
offset
-
normal
for
offset
,
normal
in
zip
(
neighbor_offset
,
self
.
normal_direction
))
return
Assignment
(
f_in
.
center
(
inv_dir
[
dir_symbol
]),
f_out
[
tangential_offset
](
inv_dir
[
dir_symbol
]))
# end class SimpleExtrapolationOutflow
...
...
This diff is collapsed.
Click to expand it.
lbmpy_tests/test_extrapolation_outflow.py
+
18
−
16
View file @
ea8431f5
...
...
@@ -10,6 +10,7 @@ from lbmpy.creationfunctions import create_lb_method
from
lbmpy.advanced_streaming.utility
import
streaming_patterns
from
pystencils.slicing
import
get_ghost_region_slice
from
itertools
import
product
@pytest.mark.parametrize
(
'
stencil
'
,
[
'
D2Q9
'
,
'
D3Q27
'
])
@pytest.mark.parametrize
(
'
streaming_pattern
'
,
streaming_patterns
)
...
...
@@ -19,7 +20,7 @@ def test_pdf_simple_extrapolation(stencil, streaming_pattern):
values_per_cell
=
len
(
stencil
)
# Field contains exactly one fluid cell
domain_size
=
(
1
,)
*
dim
domain_size
=
(
3
,)
*
dim
for
timestep
in
get_timesteps
(
streaming_pattern
):
dh
=
create_data_handling
(
domain_size
,
default_target
=
'
cpu
'
)
lb_method
=
create_lb_method
(
stencil
=
stencil
)
...
...
@@ -36,30 +37,31 @@ def test_pdf_simple_extrapolation(stencil, streaming_pattern):
pdf_arr
=
dh
.
cpu_arrays
[
pdf_field
.
name
]
# Set up the domain with artificial PDF values
center
=
(
1
,)
*
dim
#
center = (1,) * dim
out_access
=
AccessPdfValues
(
stencil
,
streaming_pattern
,
timestep
,
'
out
'
)
for
q
in
range
(
values_per_cell
):
out_access
.
write_pdf
(
pdf_arr
,
center
,
q
,
q
)
for
cell
in
product
(
*
(
range
(
1
,
4
)
for
_
in
range
(
dim
))):
for
q
in
range
(
values_per_cell
):
out_access
.
write_pdf
(
pdf_arr
,
cell
,
q
,
q
)
# Do boundary handling
bh
(
prev_timestep
=
timestep
)
center
=
np
.
array
(
center
)
# Check PDF values
in_access
=
AccessPdfValues
(
stencil
,
streaming_pattern
,
timestep
.
next
(),
'
in
'
)
# Inbound in center cell
for
q
,
streaming_dir
in
enumerate
(
stencil
):
f
=
in_access
.
read_pdf
(
pdf_arr
,
center
,
q
)
assert
f
==
q
# Outbound in neighbors
for
normal_dir
in
stencil
[
1
:]:
for
q
,
streaming_dir
in
enumerate
(
stencil
):
neighbor
=
center
+
np
.
array
(
normal_dir
)
if
all
(
n
==
0
or
n
==
-
s
for
s
,
n
in
zip
(
streaming_dir
,
normal_dir
)):
f
=
out_access
.
read_pdf
(
pdf_arr
,
neighbor
,
q
)
assert
f
==
q
for
cell
in
product
(
*
(
range
(
1
,
4
)
for
_
in
range
(
dim
))):
for
q
in
range
(
values_per_cell
):
f
=
in_access
.
read_pdf
(
pdf_arr
,
cell
,
q
)
assert
f
==
q
# # Outbound in neighbors
# for normal_dir in stencil[1:]:
# for q, streaming_dir in enumerate(stencil):
# neighbor = center + np.array(normal_dir)
# if all(n == 0 or n == -s for s, n in zip(streaming_dir, normal_dir)):
# f = out_access.read_pdf(pdf_arr, neighbor, q)
# assert f == q
def
test_extrapolation_outflow_initialization_by_copy
():
...
...
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