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
Sebastian Bindgen
pystencils
Commits
6d9fc282
Commit
6d9fc282
authored
Oct 07, 2020
by
Frederik Hennig
Committed by
Markus Holzer
Oct 07, 2020
Browse files
Fix: Replaced accidental `continue` by `break` in boundaries/createindexlist.py
parent
43bdbcb8
Changes
2
Hide whitespace changes
Inline
Side-by-side
pystencils/boundaries/createindexlist.py
View file @
6d9fc282
...
...
@@ -51,7 +51,7 @@ def _create_boundary_neighbor_index_list_python(flag_field_arr, nr_of_ghost_laye
if
flag_field_arr
[
neighbor_cell
]
&
boundary_mask
:
result
.
append
(
cell
+
(
dir_idx
,))
if
single_link
:
continue
break
return
np
.
array
(
result
,
dtype
=
index_arr_dtype
)
...
...
pystencils_tests/test_boundary_indexlist_creation.py
0 → 100644
View file @
6d9fc282
import
numpy
as
np
from
itertools
import
product
import
pystencils.boundaries.createindexlist
as
cil
import
pytest
@
pytest
.
mark
.
parametrize
(
'single_link'
,
[
False
,
True
])
@
pytest
.
mark
.
skipif
(
not
cil
.
cython_funcs_available
,
reason
=
'Cython functions are not available'
)
def
test_equivalence_cython_python_version
(
single_link
):
# D2Q9
stencil_2d
=
tuple
((
x
,
y
)
for
x
,
y
in
product
([
-
1
,
0
,
1
],
[
-
1
,
0
,
1
]))
# D3Q19
stencil_3d
=
tuple
((
x
,
y
,
z
)
for
x
,
y
,
z
in
product
([
-
1
,
0
,
1
],
[
-
1
,
0
,
1
],
[
-
1
,
0
,
1
])
if
abs
(
x
)
+
abs
(
y
)
+
abs
(
z
)
<
3
)
for
dtype
in
[
int
,
np
.
int16
,
np
.
uint32
]:
fluid_mask
=
dtype
(
1
)
mask
=
dtype
(
2
)
flag_field_2d
=
np
.
ones
([
15
,
16
],
dtype
=
dtype
)
*
fluid_mask
flag_field_3d
=
np
.
ones
([
15
,
16
,
17
],
dtype
=
dtype
)
*
fluid_mask
flag_field_2d
[
0
,
:]
=
mask
flag_field_2d
[
-
1
,
:]
=
mask
flag_field_2d
[
7
,
7
]
=
mask
flag_field_3d
[
0
,
:,
:]
=
mask
flag_field_3d
[
-
1
,
:,
:]
=
mask
flag_field_3d
[
7
,
7
,
7
]
=
mask
result_python_2d
=
cil
.
_create_boundary_neighbor_index_list_python
(
flag_field_2d
,
1
,
mask
,
fluid_mask
,
stencil_2d
,
single_link
)
result_python_3d
=
cil
.
_create_boundary_neighbor_index_list_python
(
flag_field_3d
,
1
,
mask
,
fluid_mask
,
stencil_3d
,
single_link
)
result_cython_2d
=
cil
.
create_boundary_index_list
(
flag_field_2d
,
stencil_2d
,
mask
,
fluid_mask
,
1
,
True
,
single_link
)
result_cython_3d
=
cil
.
create_boundary_index_list
(
flag_field_3d
,
stencil_3d
,
mask
,
fluid_mask
,
1
,
True
,
single_link
)
np
.
testing
.
assert_equal
(
result_python_2d
,
result_cython_2d
)
np
.
testing
.
assert_equal
(
result_python_3d
,
result_cython_3d
)
@
pytest
.
mark
.
parametrize
(
'single_link'
,
[
False
,
True
])
@
pytest
.
mark
.
skipif
(
not
cil
.
cython_funcs_available
,
reason
=
'Cython functions are not available'
)
def
test_equivalence_cell_idx_list_cython_python_version
(
single_link
):
# D2Q9
stencil_2d
=
tuple
((
x
,
y
)
for
x
,
y
in
product
([
-
1
,
0
,
1
],
[
-
1
,
0
,
1
]))
# D3Q19
stencil_3d
=
tuple
((
x
,
y
,
z
)
for
x
,
y
,
z
in
product
([
-
1
,
0
,
1
],
[
-
1
,
0
,
1
],
[
-
1
,
0
,
1
])
if
abs
(
x
)
+
abs
(
y
)
+
abs
(
z
)
<
3
)
for
dtype
in
[
int
,
np
.
int16
,
np
.
uint32
]:
fluid_mask
=
dtype
(
1
)
mask
=
dtype
(
2
)
flag_field_2d
=
np
.
ones
([
15
,
16
],
dtype
=
dtype
)
*
fluid_mask
flag_field_3d
=
np
.
ones
([
15
,
16
,
17
],
dtype
=
dtype
)
*
fluid_mask
flag_field_2d
[
0
,
:]
=
mask
flag_field_2d
[
-
1
,
:]
=
mask
flag_field_2d
[
7
,
7
]
=
mask
flag_field_3d
[
0
,
:,
:]
=
mask
flag_field_3d
[
-
1
,
:,
:]
=
mask
flag_field_3d
[
7
,
7
,
7
]
=
mask
result_python_2d
=
cil
.
_create_boundary_cell_index_list_python
(
flag_field_2d
,
mask
,
fluid_mask
,
stencil_2d
,
single_link
)
result_python_3d
=
cil
.
_create_boundary_cell_index_list_python
(
flag_field_3d
,
mask
,
fluid_mask
,
stencil_3d
,
single_link
)
result_cython_2d
=
cil
.
create_boundary_index_list
(
flag_field_2d
,
stencil_2d
,
mask
,
fluid_mask
,
None
,
False
,
single_link
)
result_cython_3d
=
cil
.
create_boundary_index_list
(
flag_field_3d
,
stencil_3d
,
mask
,
fluid_mask
,
None
,
False
,
single_link
)
np
.
testing
.
assert_equal
(
result_python_2d
,
result_cython_2d
)
np
.
testing
.
assert_equal
(
result_python_3d
,
result_cython_3d
)
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