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
a2a08c23
Commit
a2a08c23
authored
3 months ago
by
Frederik Hennig
Browse files
Options
Downloads
Patches
Plain Diff
fix data types on boundary force vector
parent
5586d82d
No related branches found
No related tags found
1 merge request
!172
Changes for compatibility with pystencils 2.0
Pipeline
#77909
canceled
3 months ago
Stage: Code Quality
Stage: pretest
Stage: test
Stage: docs
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lbmpy/boundaries/boundaryhandling.py
+5
-2
5 additions, 2 deletions
src/lbmpy/boundaries/boundaryhandling.py
tests/test_boundary_handling.py
+21
-3
21 additions, 3 deletions
tests/test_boundary_handling.py
with
26 additions
and
5 deletions
src/lbmpy/boundaries/boundaryhandling.py
+
5
−
2
View file @
a2a08c23
...
...
@@ -12,6 +12,9 @@ from lbmpy.advanced_streaming.utility import is_inplace, Timestep, AccessPdfValu
from
.._compat
import
IS_PYSTENCILS_2
if
IS_PYSTENCILS_2
:
from
pystencils.types
import
PsNumericType
class
LatticeBoltzmannBoundaryHandling
(
BoundaryHandling
):
"""
...
...
@@ -188,10 +191,10 @@ def create_lattice_boltzmann_boundary_kernel(pdf_field, index_field, lb_method,
**
kernel_creation_args
)
default_data_type
=
config
.
get_option
(
"
default_dtype
"
)
default_data_type
:
PsNumericType
=
config
.
get_option
(
"
default_dtype
"
)
if
force_vector
is
None
:
force_vector_type
=
np
.
dtype
([(
f
"
F_
{
i
}
"
,
default_data_type
.
c_nam
e
)
for
i
in
range
(
dim
)],
align
=
True
)
force_vector_type
=
np
.
dtype
([(
f
"
F_
{
i
}
"
,
default_data_type
.
numpy_dtyp
e
)
for
i
in
range
(
dim
)],
align
=
True
)
force_vector
=
Field
.
create_generic
(
'
force_vector
'
,
spatial_dimensions
=
1
,
dtype
=
force_vector_type
,
field_type
=
FieldType
.
INDEXED
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_boundary_handling.py
+
21
−
3
View file @
a2a08c23
...
...
@@ -15,6 +15,8 @@ from pystencils import create_data_handling, make_slice, Target, CreateKernelCon
from
pystencils.slicing
import
slice_from_direction
from
pystencils.stencil
import
inverse_direction
from
lbmpy._compat
import
IS_PYSTENCILS_2
def
mirror_stencil
(
direction
,
mirror_axis
):
for
i
,
n
in
enumerate
(
mirror_axis
):
...
...
@@ -448,8 +450,17 @@ def test_force_on_boundary(given_force_vector, dtype):
method
=
create_lb_method
(
lbm_config
=
LBMConfig
(
stencil
=
stencil
,
method
=
Method
.
SRT
,
relaxation_rate
=
1.8
))
noslip
=
NoSlip
(
name
=
"
noslip
"
,
calculate_force_on_boundary
=
True
)
bouzidi
=
NoSlipLinearBouzidi
(
name
=
"
bouzidi
"
,
calculate_force_on_boundary
=
True
)
qq_bounce_Back
=
QuadraticBounceBack
(
name
=
"
qqBB
"
,
relaxation_rate
=
1.8
,
calculate_force_on_boundary
=
True
)
bouzidi
=
NoSlipLinearBouzidi
(
name
=
"
bouzidi
"
,
data_type
=
dtype
,
calculate_force_on_boundary
=
True
)
qq_bounce_Back
=
QuadraticBounceBack
(
name
=
"
qqBB
"
,
relaxation_rate
=
1.8
,
data_type
=
dtype
,
calculate_force_on_boundary
=
True
)
boundary_objects
=
[
noslip
,
bouzidi
,
qq_bounce_Back
]
for
boundary
in
boundary_objects
:
...
...
@@ -465,7 +476,14 @@ def test_force_on_boundary(given_force_vector, dtype):
index_field
=
ps
.
Field
(
'
indexVector
'
,
ps
.
FieldType
.
INDEXED
,
index_struct_dtype
,
layout
=
[
0
],
shape
=
(
ps
.
TypedSymbol
(
"
indexVectorSize
"
,
"
int32
"
),
1
),
strides
=
(
1
,
1
))
create_lattice_boltzmann_boundary_kernel
(
pdfs
,
index_field
,
method
,
boundary
,
force_vector
=
force_vector
)
create_lattice_boltzmann_boundary_kernel
(
pdfs
,
index_field
,
method
,
boundary
,
force_vector
=
force_vector
,
**
({
"
default_dtype
"
:
dtype
}
if
IS_PYSTENCILS_2
else
dict
())
)
def
_numpy_data_type_for_boundary_object
(
boundary_object
,
dim
):
...
...
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