Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itischler
lbmpy
Commits
107c35da
Commit
107c35da
authored
Feb 04, 2021
by
Michael Kuron
Browse files
Merge branch 'warnings' into 'master'
Fix warnings See merge request
pycodegen/lbmpy!59
parents
dd98681c
38a17b0b
Changes
3
Hide whitespace changes
Inline
Side-by-side
doc/notebooks/demo_thermalized_lbm.ipynb
View file @
107c35da
...
@@ -26,11 +26,11 @@
...
@@ -26,11 +26,11 @@
method
method
```
```
%%%% Output: execute_result
%%%% Output: execute_result
<lbmpy.methods.momentbased.momentbasedmethod.MomentBasedLbMethod at 0x7f
ee5d180fd
0>
<lbmpy.methods.momentbased.momentbasedmethod.MomentBasedLbMethod at 0x7f
53ba131fa
0>
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
...and modify its collision table. The `create_lb_method_from_existing` function provides a convenient way to do this.
...and modify its collision table. The `create_lb_method_from_existing` function provides a convenient way to do this.
We pass a custom function that receives a row of the collision table and returns a modified version of it.
We pass a custom function that receives a row of the collision table and returns a modified version of it.
...
@@ -52,11 +52,11 @@
...
@@ -52,11 +52,11 @@
thermalized_method
thermalized_method
```
```
%%%% Output: execute_result
%%%% Output: execute_result
<lbmpy.methods.momentbased.momentbasedmethod.MomentBasedLbMethod at 0x7f
ee54d8ee8
0>
<lbmpy.methods.momentbased.momentbasedmethod.MomentBasedLbMethod at 0x7f
53b1d12a9
0>
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
## 2) Creating the kernel equations
## 2) Creating the kernel equations
...
@@ -81,11 +81,11 @@
...
@@ -81,11 +81,11 @@
debug_output = dh.add_array('dbg')
debug_output = dh.add_array('dbg')
linear_congruent_rng_eqs = [ps.Assignment(seedField(i), seedField(i) * 1664525 + 1013904223)
linear_congruent_rng_eqs = [ps.Assignment(seedField(i), seedField(i) * 1664525 + 1013904223)
for i, _ in enumerate(random_number_symbols)]
for i, _ in enumerate(random_number_symbols)]
floatEqs = [ps.Assignment(ps.TypedSymbol(s.name, np.float), seedField(i) / max_seed_type)
floatEqs = [ps.Assignment(ps.TypedSymbol(s.name, np.float
64
), seedField(i) / max_seed_type)
for i, s in enumerate(random_number_symbols)]
for i, s in enumerate(random_number_symbols)]
rng_eqs = linear_congruent_rng_eqs + floatEqs + [ps.Assignment(debug_output.center, seedField(0) / max_seed_type)]
rng_eqs = linear_congruent_rng_eqs + floatEqs + [ps.Assignment(debug_output.center, seedField(0) / max_seed_type)]
rng_eqs
rng_eqs
```
```
...
...
lbmpy/geometry.py
View file @
107c35da
...
@@ -231,17 +231,17 @@ def add_black_and_white_image(boundary_handling, image_file, target_slice=None,
...
@@ -231,17 +231,17 @@ def add_black_and_white_image(boundary_handling, image_file, target_slice=None,
# binarize
# binarize
zoomed_image
[
zoomed_image
<=
254
]
=
0
zoomed_image
[
zoomed_image
<=
254
]
=
0
zoomed_image
[
zoomed_image
>
254
]
=
1
zoomed_image
[
zoomed_image
>
254
]
=
1
zoomed_image
=
np
.
logical_not
(
zoomed_image
.
astype
(
np
.
bool
))
zoomed_image
=
np
.
logical_not
(
zoomed_image
.
astype
(
bool
))
# resize necessary if aspect ratio should be constant
# resize necessary if aspect ratio should be constant
if
zoomed_image
.
shape
!=
target_size
:
if
zoomed_image
.
shape
!=
target_size
:
resized_image
=
np
.
zeros
(
target_size
,
dtype
=
np
.
bool
)
resized_image
=
np
.
zeros
(
target_size
,
dtype
=
bool
)
mid
=
[(
ts
-
s
)
//
2
for
ts
,
s
in
zip
(
target_size
,
zoomed_image
.
shape
)]
mid
=
[(
ts
-
s
)
//
2
for
ts
,
s
in
zip
(
target_size
,
zoomed_image
.
shape
)]
resized_image
[
mid
[
0
]:
zoomed_image
.
shape
[
0
]
+
mid
[
0
],
mid
[
1
]:
zoomed_image
.
shape
[
1
]
+
mid
[
1
]]
=
zoomed_image
resized_image
[
mid
[
0
]:
zoomed_image
.
shape
[
0
]
+
mid
[
0
],
mid
[
1
]:
zoomed_image
.
shape
[
1
]
+
mid
[
1
]]
=
zoomed_image
zoomed_image
=
resized_image
zoomed_image
=
resized_image
def
callback
(
*
coordinates
):
def
callback
(
*
coordinates
):
result
=
np
.
zeros_like
(
coordinates
[
0
],
dtype
=
np
.
bool
)
result
=
np
.
zeros_like
(
coordinates
[
0
],
dtype
=
bool
)
mask_start
=
[
int
(
coordinates
[
i
][(
0
,)
*
dim
]
-
0.5
)
for
i
in
range
(
dim
)]
mask_start
=
[
int
(
coordinates
[
i
][(
0
,)
*
dim
]
-
0.5
)
for
i
in
range
(
dim
)]
mask_end
=
[
int
(
coordinates
[
i
][(
-
1
,)
*
dim
]
+
1
-
0.5
)
for
i
in
range
(
dim
)]
mask_end
=
[
int
(
coordinates
[
i
][(
-
1
,)
*
dim
]
+
1
-
0.5
)
for
i
in
range
(
dim
)]
...
...
lbmpy_tests/test_geometry_setup_serial.py
View file @
107c35da
...
@@ -63,6 +63,6 @@ def test_slice_mask_combination():
...
@@ -63,6 +63,6 @@ def test_slice_mask_combination():
print
(
"x"
,
coordinates
[
0
][:,
0
])
print
(
"x"
,
coordinates
[
0
][:,
0
])
print
(
"y"
,
coordinates
[
1
][
0
,
:])
print
(
"y"
,
coordinates
[
1
][
0
,
:])
print
(
x
.
shape
)
print
(
x
.
shape
)
return
np
.
ones_like
(
x
,
dtype
=
np
.
bool
)
return
np
.
ones_like
(
x
,
dtype
=
bool
)
sc
.
boundary_handling
.
set_boundary
(
NoSlip
(),
make_slice
[
6
:
7
,
-
1
],
callback
)
sc
.
boundary_handling
.
set_boundary
(
NoSlip
(),
make_slice
[
6
:
7
,
-
1
],
callback
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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