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
Markus Holzer
lbmpy
Commits
d193fd9d
Commit
d193fd9d
authored
1 year ago
by
Philipp Suffa
Browse files
Options
Downloads
Plain Diff
Merge branch 'CastFieldReads' into 'master'
Cast field reads also in BC See merge request
pycodegen/lbmpy!153
parents
2068f36f
29b7cce8
Branches
Branches containing commit
Tags
release/1.3.2
Tags containing commit
No related merge requests found
Pipeline
#57169
failed
1 year ago
Stage: pretest
Stage: test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lbmpy/boundaries/boundaryhandling.py
+9
-5
9 additions, 5 deletions
lbmpy/boundaries/boundaryhandling.py
lbmpy/updatekernels.py
+6
-3
6 additions, 3 deletions
lbmpy/updatekernels.py
with
15 additions
and
8 deletions
lbmpy/boundaries/boundaryhandling.py
+
9
−
5
View file @
d193fd9d
...
@@ -2,12 +2,13 @@ import numpy as np
...
@@ -2,12 +2,13 @@ import numpy as np
import
sympy
as
sp
import
sympy
as
sp
from
lbmpy.advanced_streaming.indexing
import
BetweenTimestepsIndexing
from
lbmpy.advanced_streaming.indexing
import
BetweenTimestepsIndexing
from
lbmpy.advanced_streaming.utility
import
is_inplace
,
Timestep
,
AccessPdfValues
from
lbmpy.advanced_streaming.utility
import
is_inplace
,
Timestep
,
AccessPdfValues
from
pystencils
import
Field
,
Assignment
,
TypedSymbol
,
create_kernel
from
pystencils
import
Assignment
,
Field
,
TypedSymbol
,
create_kernel
from
pystencils.stencil
import
inverse_direction
from
pystencils.stencil
import
inverse_direction
from
pystencils
import
CreateKernelConfig
,
Target
from
pystencils
import
CreateKernelConfig
,
Target
from
pystencils.boundaries
import
BoundaryHandling
from
pystencils.boundaries
import
BoundaryHandling
from
pystencils.boundaries.createindexlist
import
numpy_data_type_for_boundary_object
from
pystencils.boundaries.createindexlist
import
numpy_data_type_for_boundary_object
from
pystencils.backends.cbackend
import
CustomCodeNode
from
pystencils.backends.cbackend
import
CustomCodeNode
from
pystencils.simp
import
add_subexpressions_for_field_reads
class
LatticeBoltzmannBoundaryHandling
(
BoundaryHandling
):
class
LatticeBoltzmannBoundaryHandling
(
BoundaryHandling
):
...
@@ -194,13 +195,16 @@ def create_lattice_boltzmann_boundary_kernel(pdf_field, index_field, lb_method,
...
@@ -194,13 +195,16 @@ def create_lattice_boltzmann_boundary_kernel(pdf_field, index_field, lb_method,
boundary_assignments
=
boundary_functor
(
f_out
,
f_in
,
dir_symbol
,
inv_dir
,
lb_method
,
index_field
)
boundary_assignments
=
boundary_functor
(
f_out
,
f_in
,
dir_symbol
,
inv_dir
,
lb_method
,
index_field
)
boundary_assignments
=
indexing
.
substitute_proxies
(
boundary_assignments
)
boundary_assignments
=
indexing
.
substitute_proxies
(
boundary_assignments
)
# Code Elements inside the loop
elements
=
[
Assignment
(
dir_symbol
,
index_field
[
0
](
'
dir
'
))]
elements
+=
boundary_assignments
.
all_assignments
config
=
CreateKernelConfig
(
index_fields
=
[
index_field
],
target
=
target
,
default_number_int
=
"
int32
"
,
config
=
CreateKernelConfig
(
index_fields
=
[
index_field
],
target
=
target
,
default_number_int
=
"
int32
"
,
skip_independence_check
=
True
,
**
kernel_creation_args
)
skip_independence_check
=
True
,
**
kernel_creation_args
)
default_data_type
=
config
.
data_type
.
default_factory
()
if
pdf_field
.
dtype
!=
default_data_type
:
boundary_assignments
=
add_subexpressions_for_field_reads
(
boundary_assignments
,
data_type
=
default_data_type
)
elements
=
[
Assignment
(
dir_symbol
,
index_field
[
0
](
'
dir
'
))]
elements
+=
boundary_assignments
.
all_assignments
kernel
=
create_kernel
(
elements
,
config
=
config
)
kernel
=
create_kernel
(
elements
,
config
=
config
)
# Code Elements ahead of the loop
# Code Elements ahead of the loop
...
...
This diff is collapsed.
Click to expand it.
lbmpy/updatekernels.py
+
6
−
3
View file @
d193fd9d
...
@@ -10,7 +10,8 @@ from pystencils.sympyextensions import fast_subs
...
@@ -10,7 +10,8 @@ from pystencils.sympyextensions import fast_subs
# -------------------------------------------- LBM Kernel Creation -----------------------------------------------------
# -------------------------------------------- LBM Kernel Creation -----------------------------------------------------
def
create_lbm_kernel
(
collision_rule
,
src_field
,
dst_field
=
None
,
accessor
=
StreamPullTwoFieldsAccessor
()):
def
create_lbm_kernel
(
collision_rule
,
src_field
,
dst_field
=
None
,
accessor
=
StreamPullTwoFieldsAccessor
(),
data_type
=
None
):
"""
Replaces the pre- and post collision symbols in the collision rule by field accesses.
"""
Replaces the pre- and post collision symbols in the collision rule by field accesses.
Args:
Args:
...
@@ -19,6 +20,7 @@ def create_lbm_kernel(collision_rule, src_field, dst_field=None, accessor=Stream
...
@@ -19,6 +20,7 @@ def create_lbm_kernel(collision_rule, src_field, dst_field=None, accessor=Stream
dst_field: field used for writing pdf values if accessor.is_inplace this parameter is ignored
dst_field: field used for writing pdf values if accessor.is_inplace this parameter is ignored
accessor: instance of PdfFieldAccessor, defining where to read and write values
accessor: instance of PdfFieldAccessor, defining where to read and write values
to create e.g. a fused stream-collide kernel See
'
fieldaccess.PdfFieldAccessor
'
to create e.g. a fused stream-collide kernel See
'
fieldaccess.PdfFieldAccessor
'
data_type: If a datatype is given the field reads are isolated and written to TypedSymbols of type data_type
Returns:
Returns:
LbmCollisionRule where pre- and post collision symbols have been replaced
LbmCollisionRule where pre- and post collision symbols have been replaced
...
@@ -49,8 +51,9 @@ def create_lbm_kernel(collision_rule, src_field, dst_field=None, accessor=Stream
...
@@ -49,8 +51,9 @@ def create_lbm_kernel(collision_rule, src_field, dst_field=None, accessor=Stream
new_split_groups
.
append
([
fast_subs
(
e
,
substitutions
)
for
e
in
split_group
])
new_split_groups
.
append
([
fast_subs
(
e
,
substitutions
)
for
e
in
split_group
])
result
.
simplification_hints
[
'
split_groups
'
]
=
new_split_groups
result
.
simplification_hints
[
'
split_groups
'
]
=
new_split_groups
if
accessor
.
is_inplace
:
if
accessor
.
is_inplace
or
(
data_type
is
not
None
and
src_field
.
dtype
!=
data_type
):
result
=
add_subexpressions_for_field_reads
(
result
,
subexpressions
=
True
,
main_assignments
=
True
)
result
=
add_subexpressions_for_field_reads
(
result
,
subexpressions
=
True
,
main_assignments
=
True
,
data_type
=
data_type
)
return
result
return
result
...
...
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