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
74b891c3
Commit
74b891c3
authored
3 years ago
by
Markus Holzer
Browse files
Options
Downloads
Patches
Plain Diff
shortened some test cases
parent
e7823f08
No related branches found
No related tags found
1 merge request
!107
shorten test cases
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lbmpy_tests/test_conserved_quantity_relaxation_invariance.py
+21
-9
21 additions, 9 deletions
lbmpy_tests/test_conserved_quantity_relaxation_invariance.py
lbmpy_tests/test_diffusion.py
+12
-5
12 additions, 5 deletions
lbmpy_tests/test_diffusion.py
with
33 additions
and
14 deletions
lbmpy_tests/test_conserved_quantity_relaxation_invariance.py
+
21
−
9
View file @
74b891c3
...
...
@@ -58,7 +58,7 @@ def check_for_collision_rule_equivalence(collision_rule1, collision_rule2, use_n
for
eq1
,
eq2
in
zip
(
collision_rule1
.
main_assignments
,
collision_rule2
.
main_assignments
):
diff
=
sp
.
cancel
(
sp
.
expand
(
eq1
.
rhs
-
eq2
.
rhs
))
if
use_numeric_subs
:
assert
math
.
isclose
(
diff
,
0
,
rel_tol
=
0.0
,
abs_tol
=
1e-1
2
)
assert
math
.
isclose
(
diff
,
0
,
rel_tol
=
0.0
,
abs_tol
=
1e-1
0
)
else
:
assert
diff
==
0
...
...
@@ -78,8 +78,8 @@ def test_cumulant():
original_method
=
create_with_default_polynomial_cumulants
(
stencil
,
[
sp
.
Symbol
(
"
omega
"
)])
changed_method
=
__change_relaxation_rate_of_conserved_moments
(
original_method
)
check_method_equivalence
(
original_method
,
changed_method
,
True
,
True
)
check_method_equivalence
(
original_method
,
changed_method
,
False
,
True
)
check_method_equivalence
(
original_method
,
changed_method
,
True
,
use_numeric_subs
=
True
)
check_method_equivalence
(
original_method
,
changed_method
,
False
,
use_numeric_subs
=
True
)
@pytest.mark.longrun
...
...
@@ -89,8 +89,8 @@ def test_srt():
maxwellian_moments
=
True
)
changed_method
=
__change_relaxation_rate_of_conserved_moments
(
original_method
)
check_method_equivalence
(
original_method
,
changed_method
,
True
)
check_method_equivalence
(
original_method
,
changed_method
,
False
)
check_method_equivalence
(
original_method
,
changed_method
,
True
,
use_numeric_subs
=
True
)
check_method_equivalence
(
original_method
,
changed_method
,
False
,
use_numeric_subs
=
True
)
def
test_srt_short
():
...
...
@@ -99,8 +99,8 @@ def test_srt_short():
maxwellian_moments
=
True
)
changed_method
=
__change_relaxation_rate_of_conserved_moments
(
original_method
)
check_method_equivalence
(
original_method
,
changed_method
,
True
)
check_method_equivalence
(
original_method
,
changed_method
,
False
)
check_method_equivalence
(
original_method
,
changed_method
,
True
,
use_numeric_subs
=
False
)
check_method_equivalence
(
original_method
,
changed_method
,
False
,
use_numeric_subs
=
False
)
@pytest.mark.parametrize
(
'
stencil_name
'
,
[
Stencil
.
D2Q9
,
Stencil
.
D3Q19
,
Stencil
.
D3Q27
])
...
...
@@ -117,8 +117,8 @@ def test_trt(stencil_name, continuous_moments):
@pytest.mark.parametrize
(
'
method_name
'
,
[
Method
.
TRT_KBC_N1
,
Method
.
TRT_KBC_N2
,
Method
.
TRT_KBC_N3
,
Method
.
TRT_KBC_N4
])
@pytest.mark.parametrize
(
'
dim
'
,
[
2
,
3
])
def
test_trt_kbc_long
(
method_name
,
dim
):
def
test_trt_kbc
(
method_name
):
dim
=
2
method_nr
=
method_name
.
name
[
-
1
]
original_method
=
create_trt_kbc
(
dim
,
sp
.
Symbol
(
"
omega1
"
),
sp
.
Symbol
(
"
omega2
"
),
method_name
=
'
KBC-N
'
+
method_nr
,
...
...
@@ -127,3 +127,15 @@ def test_trt_kbc_long(method_name, dim):
check_method_equivalence
(
original_method
,
changed_method
,
True
)
check_method_equivalence
(
original_method
,
changed_method
,
False
)
@pytest.mark.parametrize
(
'
method_name
'
,
[
Method
.
TRT_KBC_N1
,
Method
.
TRT_KBC_N2
,
Method
.
TRT_KBC_N3
,
Method
.
TRT_KBC_N4
])
@pytest.mark.longrun
def
test_trt_kbc_long
(
method_name
):
dim
=
3
method_nr
=
method_name
.
name
[
-
1
]
original_method
=
create_trt_kbc
(
dim
,
sp
.
Symbol
(
"
omega1
"
),
sp
.
Symbol
(
"
omega2
"
),
method_name
=
'
KBC-N
'
+
method_nr
,
maxwellian_moments
=
False
)
changed_method
=
__change_relaxation_rate_of_conserved_moments
(
original_method
)
check_method_equivalence
(
original_method
,
changed_method
,
True
)
check_method_equivalence
(
original_method
,
changed_method
,
False
)
This diff is collapsed.
Click to expand it.
lbmpy_tests/test_diffusion.py
+
12
−
5
View file @
74b891c3
...
...
@@ -75,8 +75,8 @@ def test_diffusion():
C(x,y) = 1 * erfc(y / sqrt(4Dx/u))
The hydrodynamic field is not simulated, instead a constant velocity is assumed.
"""
"""
pytest
.
importorskip
(
"
pycuda
"
)
# Parameters
domain_size
=
(
1600
,
160
)
omega
=
1.38
...
...
@@ -84,9 +84,10 @@ def test_diffusion():
velocity
=
0.05
time_steps
=
50000
stencil
=
LBStencil
(
Stencil
.
D2Q9
)
target
=
ps
.
Target
.
GPU
# Data Handling
dh
=
ps
.
create_data_handling
(
domain_size
=
domain_size
)
dh
=
ps
.
create_data_handling
(
domain_size
=
domain_size
,
default_target
=
target
)
vel_field
=
dh
.
add_array
(
'
vel_field
'
,
values_per_cell
=
stencil
.
D
)
dh
.
fill
(
'
vel_field
'
,
velocity
,
0
,
ghost_layers
=
True
)
...
...
@@ -96,7 +97,9 @@ def test_diffusion():
dh
.
fill
(
'
con_field
'
,
0.0
,
ghost_layers
=
True
)
pdfs
=
dh
.
add_array
(
'
pdfs
'
,
values_per_cell
=
stencil
.
Q
)
dh
.
fill
(
'
pdfs
'
,
0.0
,
ghost_layers
=
True
)
pdfs_tmp
=
dh
.
add_array
(
'
pdfs_tmp
'
,
values_per_cell
=
stencil
.
Q
)
dh
.
fill
(
'
pdfs_tmp
'
,
0.0
,
ghost_layers
=
True
)
# Lattice Boltzmann method
lbm_config
=
LBMConfig
(
stencil
=
stencil
,
method
=
Method
.
MRT
,
relaxation_rates
=
[
1
,
1.5
,
1
,
1.5
,
1
],
...
...
@@ -104,21 +107,24 @@ def test_diffusion():
weighted
=
True
,
kernel_type
=
'
stream_pull_collide
'
)
lbm_opt
=
LBMOptimisation
(
symbolic_field
=
pdfs
,
symbolic_temporary_field
=
pdfs_tmp
)
config
=
ps
.
CreateKernelConfig
(
target
=
dh
.
default_target
,
cpu_openmp
=
True
)
method
=
create_lb_method
(
lbm_config
=
lbm_config
)
method
.
set_conserved_moments_relaxation_rate
(
omega
)
lbm_config
=
replace
(
lbm_config
,
lb_method
=
method
)
update_rule
=
create_lb_update_rule
(
lbm_config
=
lbm_config
,
lbm_optimisation
=
lbm_opt
)
kernel
=
ps
.
create_kernel
(
update_rule
).
compile
()
kernel
=
ps
.
create_kernel
(
update_rule
,
config
=
config
).
compile
()
# PDF initalization
init
=
pdf_initialization_assignments
(
method
,
con_field
.
center
,
vel_field
.
center_vector
,
pdfs
.
center_vector
)
dh
.
run_kernel
(
ps
.
create_kernel
(
init
).
compile
())
dh
.
all_to_gpu
()
# Boundary Handling
bh
=
LatticeBoltzmannBoundaryHandling
(
update_rule
.
method
,
dh
,
'
pdfs
'
,
name
=
"
bh
"
)
bh
=
LatticeBoltzmannBoundaryHandling
(
update_rule
.
method
,
dh
,
'
pdfs
'
,
name
=
"
bh
"
,
target
=
dh
.
default_target
)
add_box_boundary
(
bh
,
boundary
=
NeumannByCopy
())
bh
.
set_boundary
(
DiffusionDirichlet
(
0
),
slice_from_direction
(
'
W
'
,
dh
.
dim
))
bh
.
set_boundary
(
DiffusionDirichlet
(
1
),
slice_from_direction
(
'
S
'
,
dh
.
dim
))
...
...
@@ -129,6 +135,7 @@ def test_diffusion():
dh
.
run_kernel
(
kernel
)
dh
.
swap
(
"
pdfs
"
,
"
pdfs_tmp
"
)
dh
.
all_to_cpu
()
# Verification
x
=
np
.
arange
(
1
,
domain_size
[
0
],
1
)
y
=
np
.
arange
(
0
,
domain_size
[
1
],
1
)
...
...
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