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
e8ee9f27
Commit
e8ee9f27
authored
1 year ago
by
Helen Schottenhamml
Browse files
Options
Downloads
Patches
Plain Diff
Write eddy-viscosity directly in SGS calculation.
parent
62d719d0
No related branches found
No related tags found
1 merge request
!165
Rework SGS models
Pipeline
#60998
failed
1 year ago
Stage: pretest
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lbmpy/creationfunctions.py
+6
-1
6 additions, 1 deletion
src/lbmpy/creationfunctions.py
src/lbmpy/turbulence_models.py
+15
-5
15 additions, 5 deletions
src/lbmpy/turbulence_models.py
with
21 additions
and
6 deletions
src/lbmpy/creationfunctions.py
+
6
−
1
View file @
e8ee9f27
...
...
@@ -241,6 +241,10 @@ class LBMConfig:
A pystencils Field can be passed here, where the calculated free relaxation rate of
an entropic or subgrid-scale method is written to
"""
eddy_viscosity_field
:
Field
=
None
"""
A pystencils Field can be passed here, where the eddy-viscosity of a subgrid-scale model is written.
"""
subgrid_scale_model
:
Union
[
SubgridScaleModel
,
tuple
[
SubgridScaleModel
,
float
],
tuple
[
SubgridScaleModel
,
int
]]
=
None
"""
Choose a subgrid-scale model (SGS) for large-eddy simulations. ``omega_output_field`` can be set to
...
...
@@ -727,7 +731,8 @@ def create_lb_collision_rule(lb_method=None, lbm_config=None, lbm_optimisation=N
model_constant
=
lbm_config
.
subgrid_scale_model
[
1
]
collision_rule
=
add_sgs_model
(
collision_rule
=
collision_rule
,
subgrid_scale_model
=
sgs_model
,
model_constant
=
model_constant
,
omega_output_field
=
lbm_config
.
omega_output_field
)
model_constant
=
model_constant
,
omega_output_field
=
lbm_config
.
omega_output_field
,
eddy_viscosity_field
=
lbm_config
.
eddy_viscosity_field
)
if
'
split_groups
'
in
collision_rule
.
simplification_hints
:
collision_rule
.
simplification_hints
[
'
split_groups
'
][
0
].
append
(
sp
.
Symbol
(
"
sgs_omega
"
))
...
...
This diff is collapsed.
Click to expand it.
src/lbmpy/turbulence_models.py
+
15
−
5
View file @
e8ee9f27
...
...
@@ -8,20 +8,21 @@ from pystencils import Assignment
from
lbmpy.enums
import
SubgridScaleModel
def
add_sgs_model
(
collision_rule
,
subgrid_scale_model
:
SubgridScaleModel
,
model_constant
=
None
,
omega_output_field
=
None
):
def
add_sgs_model
(
collision_rule
,
subgrid_scale_model
:
SubgridScaleModel
,
model_constant
=
None
,
omega_output_field
=
None
,
eddy_viscosity_field
=
None
):
r
"""
Wrapper for SGS models to provide default constants and outsource SGS model handling from creation routines.
"""
if
subgrid_scale_model
==
SubgridScaleModel
.
SMAGORINSKY
:
model_constant
=
model_constant
if
model_constant
else
sp
.
Float
(
0.12
)
return
add_smagorinsky_model
(
collision_rule
=
collision_rule
,
smagorinsky_constant
=
model_constant
,
omega_output_field
=
omega_output_field
)
omega_output_field
=
omega_output_field
,
eddy_viscosity_field
=
eddy_viscosity_field
)
if
subgrid_scale_model
==
SubgridScaleModel
.
QR
:
model_constant
=
model_constant
if
model_constant
else
sp
.
Rational
(
1
,
3
)
return
add_qr_model
(
collision_rule
=
collision_rule
,
qr_constant
=
model_constant
,
omega_output_field
=
omega_output_field
)
omega_output_field
=
omega_output_field
,
eddy_viscosity_field
=
eddy_viscosity_field
)
def
add_smagorinsky_model
(
collision_rule
,
smagorinsky_constant
,
omega_output_field
=
None
):
def
add_smagorinsky_model
(
collision_rule
,
smagorinsky_constant
,
omega_output_field
=
None
,
eddy_viscosity_field
=
None
):
r
"""
Adds a Smagorinsky model to a lattice Boltzmann collision rule. To add the Smagorinsky model to a LB scheme
one has to first compute the strain rate tensor $S_{ij}$ in each cell, and compute the turbulent
viscosity :math:`nu_t` from it. Then the local relaxation rate has to be adapted to match the total viscosity
...
...
@@ -71,13 +72,19 @@ def add_smagorinsky_model(collision_rule, smagorinsky_constant, omega_output_fie
collision_rule
.
subexpressions
+=
eqs
collision_rule
.
topological_sort
(
sort_subexpressions
=
True
,
sort_main_assignments
=
False
)
if
eddy_viscosity_field
:
collision_rule
.
main_assignments
.
append
(
Assignment
(
eddy_viscosity_field
.
center
,
smagorinsky_constant
**
2
*
sp
.
Rational
(
3
,
2
)
*
adapted_omega
*
second_order_neq_moments
))
if
omega_output_field
:
collision_rule
.
main_assignments
.
append
(
Assignment
(
omega_output_field
.
center
,
adapted_omega
))
return
collision_rule
def
add_qr_model
(
collision_rule
,
qr_constant
,
omega_output_field
=
None
):
def
add_qr_model
(
collision_rule
,
qr_constant
,
omega_output_field
=
None
,
eddy_viscosity_field
=
None
):
r
"""
Adds a QR model to a lattice Boltzmann collision rule, see :cite:`rozema15`.
WARNING : this subgrid-scale model is only defined for isotropic grids
"""
...
...
@@ -134,6 +141,9 @@ def add_qr_model(collision_rule, qr_constant, omega_output_field=None):
collision_rule
.
subexpressions
+=
eqs
collision_rule
.
topological_sort
(
sort_subexpressions
=
True
,
sort_main_assignments
=
False
)
if
eddy_viscosity_field
:
collision_rule
.
main_assignments
.
append
(
Assignment
(
eddy_viscosity_field
.
center
,
nu_e
))
if
omega_output_field
:
collision_rule
.
main_assignments
.
append
(
Assignment
(
omega_output_field
.
center
,
adapted_omega
))
...
...
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