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
11c94c03
Commit
11c94c03
authored
4 weeks ago
by
Philipp Suffa
Browse files
Options
Downloads
Patches
Plain Diff
Fixes error, where psm plus force fails for macroscopic getter and setters
parent
b9073ad6
No related branches found
No related tags found
1 merge request
!187
Optmizations for kernel generation for the partially saturated cells method
Pipeline
#79745
failed
4 weeks ago
Stage: pretest
Stage: test
Stage: docs
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lbmpy/macroscopic_value_kernels.py
+17
-3
17 additions, 3 deletions
src/lbmpy/macroscopic_value_kernels.py
src/lbmpy/partially_saturated_cells.py
+4
-4
4 additions, 4 deletions
src/lbmpy/partially_saturated_cells.py
with
21 additions
and
7 deletions
src/lbmpy/macroscopic_value_kernels.py
+
17
−
3
View file @
11c94c03
...
@@ -7,6 +7,7 @@ from pystencils.field import Field, get_layout_of_array
...
@@ -7,6 +7,7 @@ from pystencils.field import Field, get_layout_of_array
from
pystencils.enums
import
Target
from
pystencils.enums
import
Target
from
lbmpy.advanced_streaming.utility
import
get_accessor
,
Timestep
from
lbmpy.advanced_streaming.utility
import
get_accessor
,
Timestep
from
lbmpy.partially_saturated_cells
import
replace_fraction_symbol_with_field
from
lbmpy.relaxationrates
import
get_shear_relaxation_rate
from
lbmpy.relaxationrates
import
get_shear_relaxation_rate
from
lbmpy.utils
import
second_order_moment_tensor
from
lbmpy.utils
import
second_order_moment_tensor
...
@@ -26,7 +27,7 @@ def get_field_accesses(lb_method, pdfs, streaming_pattern, previous_timestep, pr
...
@@ -26,7 +27,7 @@ def get_field_accesses(lb_method, pdfs, streaming_pattern, previous_timestep, pr
return
field_accesses
return
field_accesses
def
pdf_initialization_assignments
(
lb_method
,
density
,
velocity
,
pdfs
,
def
pdf_initialization_assignments
(
lb_method
,
density
,
velocity
,
pdfs
,
fraction_field_access
=
None
,
streaming_pattern
=
'
pull
'
,
previous_timestep
=
Timestep
.
BOTH
,
streaming_pattern
=
'
pull
'
,
previous_timestep
=
Timestep
.
BOTH
,
set_pre_collision_pdfs
=
False
):
set_pre_collision_pdfs
=
False
):
"""
Assignments to initialize the pdf field with equilibrium
"""
"""
Assignments to initialize the pdf field with equilibrium
"""
...
@@ -42,10 +43,16 @@ def pdf_initialization_assignments(lb_method, density, velocity, pdfs,
...
@@ -42,10 +43,16 @@ def pdf_initialization_assignments(lb_method, density, velocity, pdfs,
setter_eqs
=
lb_method
.
get_equilibrium
(
conserved_quantity_equations
=
inp_eqs
)
setter_eqs
=
lb_method
.
get_equilibrium
(
conserved_quantity_equations
=
inp_eqs
)
setter_eqs
=
setter_eqs
.
new_with_substitutions
({
sym
:
field_accesses
[
i
]
setter_eqs
=
setter_eqs
.
new_with_substitutions
({
sym
:
field_accesses
[
i
]
for
i
,
sym
in
enumerate
(
lb_method
.
post_collision_pdf_symbols
)})
for
i
,
sym
in
enumerate
(
lb_method
.
post_collision_pdf_symbols
)})
if
lb_method
.
fraction_field
is
not
None
:
if
fraction_field_access
is
None
:
raise
ValueError
(
"
If setting up LBM with PSM, please specify a fraction field access in the macroscopic setter
"
)
else
:
setter_eqs
=
replace_fraction_symbol_with_field
(
setter_eqs
,
lb_method
.
fraction_field
,
fraction_field_access
)
return
setter_eqs
return
setter_eqs
def
macroscopic_values_getter
(
lb_method
,
density
,
velocity
,
pdfs
,
def
macroscopic_values_getter
(
lb_method
,
density
,
velocity
,
pdfs
,
fraction_field_access
=
None
,
streaming_pattern
=
'
pull
'
,
previous_timestep
=
Timestep
.
BOTH
,
streaming_pattern
=
'
pull
'
,
previous_timestep
=
Timestep
.
BOTH
,
use_pre_collision_pdfs
=
False
):
use_pre_collision_pdfs
=
False
):
...
@@ -58,7 +65,14 @@ def macroscopic_values_getter(lb_method, density, velocity, pdfs,
...
@@ -58,7 +65,14 @@ def macroscopic_values_getter(lb_method, density, velocity, pdfs,
output_spec
[
'
velocity
'
]
=
velocity
output_spec
[
'
velocity
'
]
=
velocity
if
density
is
not
None
:
if
density
is
not
None
:
output_spec
[
'
density
'
]
=
density
output_spec
[
'
density
'
]
=
density
return
cqc
.
output_equations_from_pdfs
(
field_accesses
,
output_spec
)
getter_equ
=
cqc
.
output_equations_from_pdfs
(
field_accesses
,
output_spec
)
if
lb_method
.
fraction_field
is
not
None
:
if
fraction_field_access
is
None
:
raise
ValueError
(
"
If setting up LBM with PSM, please specify a fraction field access in the macroscopic getter
"
)
else
:
getter_equ
=
replace_fraction_symbol_with_field
(
getter_equ
,
lb_method
.
fraction_field
,
fraction_field_access
)
return
getter_equ
macroscopic_values_setter
=
pdf_initialization_assignments
macroscopic_values_setter
=
pdf_initialization_assignments
...
...
This diff is collapsed.
Click to expand it.
src/lbmpy/partially_saturated_cells.py
+
4
−
4
View file @
11c94c03
...
@@ -104,10 +104,10 @@ def get_psm_force_from_solid_collision(solid_collisions, stencil, object_force_f
...
@@ -104,10 +104,10 @@ def get_psm_force_from_solid_collision(solid_collisions, stencil, object_force_f
return
AssignmentCollection
(
force_assignments
)
return
AssignmentCollection
(
force_assignments
)
def
replace_fraction_symbol_with_field
(
assignments
,
psm_c
onfi
g
):
def
replace_fraction_symbol_with_field
(
assignments
,
fraction_field_symbol
,
fracti
on
_
fi
eld_access
):
new_assignments
=
[]
new_assignments
=
[]
for
ass
in
assignments
:
for
ass
in
assignments
:
rhs
=
ass
.
rhs
.
subs
(
psm_config
.
fraction_field_symbol
,
psm_config
.
fraction_field
.
center
(
0
))
rhs
=
ass
.
rhs
.
subs
(
fraction_field_symbol
,
fraction_field
_access
.
center
(
0
))
new_assignments
.
append
(
Assignment
(
ass
.
lhs
,
rhs
))
new_assignments
.
append
(
Assignment
(
ass
.
lhs
,
rhs
))
return
new_assignments
return
new_assignments
...
@@ -160,8 +160,8 @@ def replace_by_psm_collision_rule(collision_rule, psm_config):
...
@@ -160,8 +160,8 @@ def replace_by_psm_collision_rule(collision_rule, psm_config):
collision_assignments
.
append
(
Assignment
(
main
.
lhs
,
rhs
))
collision_assignments
.
append
(
Assignment
(
main
.
lhs
,
rhs
))
collision_assignments
=
AssignmentCollection
(
collision_assignments
)
collision_assignments
=
AssignmentCollection
(
collision_assignments
)
ac
=
LbmCollisionRule
(
method
,
replace_fraction_symbol_with_field
(
collision_assignments
,
psm_config
),
ac
=
LbmCollisionRule
(
method
,
replace_fraction_symbol_with_field
(
collision_assignments
,
psm_config
.
fraction_field_symbol
,
psm_config
.
fraction_field
),
replace_fraction_symbol_with_field
(
collision_rule
.
subexpressions
,
psm_config
),
replace_fraction_symbol_with_field
(
collision_rule
.
subexpressions
,
psm_config
.
fraction_field_symbol
,
psm_config
.
fraction_field
),
collision_rule
.
simplification_hints
)
collision_rule
.
simplification_hints
)
ac
.
topological_sort
()
ac
.
topological_sort
()
return
ac
return
ac
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