Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Frederik Hennig
lbmpy
Commits
6b1145e7
Commit
6b1145e7
authored
Nov 02, 2020
by
Markus Holzer
Browse files
Added assertions for boundary test case
parent
2504b1bb
Pipeline
#27666
waiting for manual action with stage
in 24 minutes and 14 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lbmpy_tests/test_boundary_handling.py
View file @
6b1145e7
...
...
@@ -19,8 +19,14 @@ def test_simple(target):
pytest
.
importorskip
(
'pyopencl'
)
import
pystencils.opencl.autoinit
dh
=
create_data_handling
((
10
,
5
),
parallel
=
False
,
default_target
=
target
)
dh
=
create_data_handling
((
4
,
4
),
parallel
=
False
,
default_target
=
target
)
dh
.
add_array
(
'pdfs'
,
values_per_cell
=
9
,
cpu
=
True
,
gpu
=
target
!=
'cpu'
)
for
i
in
range
(
9
):
dh
.
fill
(
"pdfs"
,
i
,
value_idx
=
i
,
ghost_layers
=
True
)
if
target
==
'gpu'
:
dh
.
all_to_gpu
()
lb_func
=
create_lb_function
(
stencil
=
'D2Q9'
,
compressible
=
False
,
relaxation_rate
=
1.8
,
...
...
@@ -29,7 +35,7 @@ def test_simple(target):
bh
=
LatticeBoltzmannBoundaryHandling
(
lb_func
.
method
,
dh
,
'pdfs'
,
target
=
target
)
wall
=
NoSlip
()
moving_wall
=
UBB
((
0.00
1
,
0
))
moving_wall
=
UBB
((
1
,
0
))
bh
.
set_boundary
(
wall
,
make_slice
[
0
,
:])
bh
.
set_boundary
(
wall
,
make_slice
[
-
1
,
:])
bh
.
set_boundary
(
wall
,
make_slice
[:,
0
])
...
...
@@ -38,6 +44,64 @@ def test_simple(target):
bh
.
prepare
()
bh
()
if
target
==
'gpu'
:
dh
.
all_to_cpu
()
# left lower corner
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
0
,
0
,
6
]
==
7
)
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
0
,
1
,
4
]
==
3
)
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
0
,
1
,
6
]
==
7
)
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
1
,
0
,
1
]
==
2
)
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
1
,
0
,
6
]
==
7
)
# left side
assert
(
all
(
dh
.
cpu_arrays
[
'pdfs'
][
0
,
2
:
4
,
4
]
==
3
))
assert
(
all
(
dh
.
cpu_arrays
[
'pdfs'
][
0
,
2
:
4
,
6
]
==
7
))
assert
(
all
(
dh
.
cpu_arrays
[
'pdfs'
][
0
,
2
:
4
,
5
]
==
5
))
# left upper corner
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
0
,
4
,
4
]
==
3
)
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
0
,
4
,
8
]
==
5
)
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
0
,
5
,
8
]
==
5
+
6
/
36
)
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
1
,
5
,
8
]
==
5
+
6
/
36
)
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
1
,
5
,
2
]
==
1
)
# top side
assert
(
all
(
dh
.
cpu_arrays
[
'pdfs'
][
2
:
4
,
5
,
2
]
==
1
))
assert
(
all
(
dh
.
cpu_arrays
[
'pdfs'
][
2
:
4
,
5
,
7
]
==
6
-
6
/
36
))
assert
(
all
(
dh
.
cpu_arrays
[
'pdfs'
][
2
:
4
,
5
,
8
]
==
5
+
6
/
36
))
# right upper corner
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
4
,
5
,
2
]
==
1
)
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
4
,
5
,
7
]
==
6
-
6
/
36
)
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
5
,
5
,
7
]
==
6
-
6
/
36
)
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
5
,
4
,
3
]
==
4
)
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
5
,
4
,
7
]
==
6
)
# right side
assert
(
all
(
dh
.
cpu_arrays
[
'pdfs'
][
5
,
2
:
4
,
3
]
==
4
))
assert
(
all
(
dh
.
cpu_arrays
[
'pdfs'
][
5
,
2
:
4
,
5
]
==
8
))
assert
(
all
(
dh
.
cpu_arrays
[
'pdfs'
][
5
,
2
:
4
,
7
]
==
6
))
# right lower corner
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
5
,
1
,
3
]
==
4
)
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
5
,
1
,
5
]
==
8
)
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
5
,
0
,
5
]
==
8
)
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
4
,
0
,
1
]
==
2
)
assert
(
dh
.
cpu_arrays
[
'pdfs'
][
4
,
0
,
5
]
==
8
)
# lower side
assert
(
all
(
dh
.
cpu_arrays
[
'pdfs'
][
0
,
2
:
4
,
4
]
==
3
))
assert
(
all
(
dh
.
cpu_arrays
[
'pdfs'
][
0
,
2
:
4
,
6
]
==
7
))
assert
(
all
(
dh
.
cpu_arrays
[
'pdfs'
][
0
,
2
:
4
,
8
]
==
5
))
def
test_exotic_boundaries
():
step
=
LatticeBoltzmannStep
((
50
,
50
),
relaxation_rate
=
1.8
,
compressible
=
False
,
periodicity
=
False
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment