Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Markus Holzer
lbmpy
Commits
1ce2c1d7
Commit
1ce2c1d7
authored
Aug 06, 2021
by
Markus Holzer
Browse files
Revert central moment transform changes
parent
7bc65dd3
Pipeline
#33589
failed with stages
in 10 minutes and 16 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
lbmpy/methods/momentbased/centralmomentbasedmethod.py
View file @
1ce2c1d7
...
...
@@ -10,13 +10,12 @@ from lbmpy.moment_transforms import (FastCentralMomentTransform,
PRE_COLLISION_CENTRAL_MOMENT
,
POST_COLLISION_CENTRAL_MOMENT
)
from
lbmpy.moments
import
(
polynomial_to_exponent_representation
,
MOMENT_SYMBOLS
,
moment_matrix
,
set_up_shift_matrix
,
statistical_quantity_symbol
)
statistical_quantity_symbol
,
extract_monomials
,
exponent_tuple_sort_key
)
def
relax_central_moments
(
moment_indices
,
pre_collision_values
,
relaxation_rates
,
equilibrium_values
,
post_collision_base
=
POST_COLLISION_CENTRAL_MOMENT
):
post_collision_symbols
=
[
sp
.
Symbol
(
f
'
{
post_collision_base
}
_
{
""
.
join
(
str
(
i
)
for
i
in
m
)
}
'
)
for
m
in
moment_indices
]
equilibrium_vec
=
sp
.
Matrix
(
equilibrium_values
)
moment_vec
=
sp
.
Matrix
(
pre_collision_values
)
...
...
@@ -26,6 +25,7 @@ def relax_central_moments(moment_indices, pre_collision_values,
return
AssignmentCollection
(
main_assignments
)
# =============================== LB Method Implementation ===========================================================
...
...
@@ -255,11 +255,12 @@ class CentralMomentBasedLbMethod(AbstractLbMethod):
if
cqe
is
None
:
cqe
=
self
.
_conserved_quantity_computation
.
equilibrium_input_equations_from_pdfs
(
f
)
moment_polynomials
=
list
(
self
.
moments
)
moments_as_exponents
=
list
(
extract_monomials
(
list
(
self
.
moments
),
dim
=
2
))
moments_as_exponents
=
sorted
(
moments_as_exponents
,
key
=
exponent_tuple_sort_key
)
# 1) Get Forward Transformation from PDFs to central moments
pdfs_to_k_transform
=
self
.
central_moment_transform_class
(
stencil
,
moment
_polynomial
s
,
density
,
velocity
,
conserved_quantity_equations
=
cqe
)
stencil
,
moment
s_as_exponent
s
,
density
,
velocity
,
conserved_quantity_equations
=
cqe
)
pdfs_to_k_eqs
=
pdfs_to_k_transform
.
forward_transform
(
f
,
simplification
=
pre_simplification
)
moments_as_exponents
=
pdfs_to_k_transform
.
moment_exponents
...
...
lbmpy/moment_transforms/centralmomenttransforms.py
View file @
1ce2c1d7
...
...
@@ -6,8 +6,7 @@ from pystencils.simp import (
from
pystencils.simp.assignment_collection
import
SymbolGen
from
pystencils.sympyextensions
import
subs_additive
,
fast_subs
from
lbmpy.moments
import
moment_matrix
,
set_up_shift_matrix
,
contained_moments
,
moments_up_to_order
,
\
monomial_to_polynomial_transformation_matrix
from
lbmpy.moments
import
moment_matrix
,
set_up_shift_matrix
,
contained_moments
,
moments_up_to_order
from
lbmpy.moments
import
statistical_quantity_symbol
as
sq_sym
from
.abstractmomenttransform
import
(
...
...
@@ -20,22 +19,22 @@ from .momenttransforms import PdfsToMomentsByChimeraTransform
class
PdfsToCentralMomentsByMatrix
(
AbstractMomentTransform
):
def
__init__
(
self
,
stencil
,
moment_
polynomial
s
,
def
__init__
(
self
,
stencil
,
moment_
exponent
s
,
equilibrium_density
,
equilibrium_velocity
,
pre_collision_central_moment_base
=
PRE_COLLISION_CENTRAL_MOMENT
,
post_collision_central_moment_base
=
POST_COLLISION_CENTRAL_MOMENT
,
**
kwargs
):
assert
len
(
moment_
polynomial
s
)
==
len
(
stencil
),
'Number of moments must match stencil'
assert
len
(
moment_
exponent
s
)
==
len
(
stencil
),
'Number of moments must match stencil'
super
(
PdfsToCentralMomentsByMatrix
,
self
).
__init__
(
stencil
,
equilibrium_density
,
equilibrium_velocity
,
moment_
polynomials
=
moment_polynomial
s
,
**
kwargs
)
moment_
exponents
=
moment_exponent
s
,
**
kwargs
)
moment_matrix_without_shift
=
moment_matrix
(
self
.
moment_
polynomial
s
,
self
.
stencil
)
shift_matrix
=
set_up_shift_matrix
(
self
.
moment_
polynomial
s
,
self
.
stencil
,
equilibrium_velocity
)
moment_matrix_without_shift
=
moment_matrix
(
self
.
moment_
exponent
s
,
self
.
stencil
)
shift_matrix
=
set_up_shift_matrix
(
self
.
moment_
exponent
s
,
self
.
stencil
,
equilibrium_velocity
)
self
.
forward_matrix
=
moment_matrix
(
self
.
moment_
polynomial
s
,
self
.
stencil
,
equilibrium_velocity
)
self
.
forward_matrix
=
moment_matrix
(
self
.
moment_
exponent
s
,
self
.
stencil
,
equilibrium_velocity
)
self
.
backward_matrix
=
moment_matrix_without_shift
.
inv
()
*
shift_matrix
.
inv
()
self
.
kappa_pre
=
pre_collision_central_moment_base
...
...
@@ -88,28 +87,25 @@ class PdfsToCentralMomentsByMatrix(AbstractMomentTransform):
class
FastCentralMomentTransform
(
AbstractMomentTransform
):
def
__init__
(
self
,
stencil
,
moment_
polynomial
s
,
moment_
exponent
s
,
equilibrium_density
,
equilibrium_velocity
,
conserved_quantity_equations
=
None
,
pre_collision_central_moment_base
=
PRE_COLLISION_CENTRAL_MOMENT
,
post_collision_central_moment_base
=
POST_COLLISION_CENTRAL_MOMENT
,
**
kwargs
):
assert
len
(
moment_
polynomial
s
)
==
len
(
stencil
),
'Number of moments must match stencil'
assert
len
(
moment_
exponent
s
)
==
len
(
stencil
),
'Number of moments must match stencil'
super
(
FastCentralMomentTransform
,
self
).
__init__
(
stencil
,
equilibrium_density
,
equilibrium_velocity
,
conserved_quantity_equations
=
conserved_quantity_equations
,
moment_
polynomials
=
moment_polynomial
s
,
**
kwargs
)
moment_
exponents
=
moment_exponent
s
,
**
kwargs
)
self
.
kappa_pre
=
pre_collision_central_moment_base
self
.
kappa_post
=
post_collision_central_moment_base
self
.
mono_to_poly_matrix
=
monomial_to_polynomial_transformation_matrix
(
self
.
moment_exponents
,
self
.
moment_polynomials
)
self
.
mat_transform
=
PdfsToCentralMomentsByMatrix
(
stencil
,
moment_
polynomial
s
,
equilibrium_density
,
equilibrium_velocity
,
stencil
,
moment_
exponent
s
,
equilibrium_density
,
equilibrium_velocity
,
conserved_quantity_equations
=
conserved_quantity_equations
,
pre_collision_central_moment_base
=
pre_collision_central_moment_base
,
post_collision_central_moment_base
=
post_collision_central_moment_base
,
...
...
@@ -163,7 +159,7 @@ class FastCentralMomentTransform(AbstractMomentTransform):
subexpressions
=
[
Assignment
(
lhs
,
rhs
)
for
lhs
,
rhs
in
subexpressions_dict
.
items
()]
symbol_gen
=
SymbolGen
(
subexpression_base
)
ac
=
AssignmentCollection
(
m
o
ment
_eq
s
,
subexpressions
=
subexpressions
,
ac
=
AssignmentCollection
(
m
ain_assign
ments
,
subexpressions
=
subexpressions
,
subexpression_symbol_generator
=
symbol_gen
)
if
simplification
:
ac
=
self
.
_simplify_lower_order_moments
(
ac
,
moment_symbol_base
)
...
...
@@ -299,29 +295,30 @@ class FastCentralMomentTransform(AbstractMomentTransform):
class
PdfsToCentralMomentsByShiftMatrix
(
AbstractMomentTransform
):
def
__init__
(
self
,
stencil
,
moment_
polynomial
s
,
def
__init__
(
self
,
stencil
,
moment_
exponent
s
,
equilibrium_density
,
equilibrium_velocity
,
conserved_quantity_equations
=
None
,
pre_collision_central_moment_base
=
PRE_COLLISION_CENTRAL_MOMENT
,
post_collision_central_moment_base
=
POST_COLLISION_CENTRAL_MOMENT
,
**
kwargs
):
assert
len
(
moment_
polynomial
s
)
==
len
(
stencil
),
'Number of moments must match stencil'
assert
len
(
moment_
exponent
s
)
==
len
(
stencil
),
'Number of moments must match stencil'
super
(
PdfsToCentralMomentsByShiftMatrix
,
self
).
__init__
(
stencil
,
equilibrium_density
,
equilibrium_velocity
,
conserved_quantity_equations
=
conserved_quantity_equations
,
moment_
polynomials
=
moment_polynomial
s
,
**
kwargs
)
moment_
exponents
=
moment_exponent
s
,
**
kwargs
)
self
.
raw_moment_transform
=
PdfsToMomentsByChimeraTransform
(
stencil
,
moment_polynomials
,
equilibrium_density
,
equilibrium_velocity
,
stencil
,
None
,
equilibrium_density
,
equilibrium_velocity
,
conserved_quantity_equations
=
conserved_quantity_equations
,
moment_exponents
=
moment_exponents
,
**
kwargs
)
self
.
kappa_pre
=
pre_collision_central_moment_base
self
.
kappa_post
=
post_collision_central_moment_base
self
.
shift_matrix
=
set_up_shift_matrix
(
self
.
moment_
polynomial
s
,
self
.
stencil
,
self
.
equilibrium_velocity
)
self
.
shift_matrix
=
set_up_shift_matrix
(
self
.
moment_
exponent
s
,
self
.
stencil
,
self
.
equilibrium_velocity
)
self
.
inv_shift_matrix
=
self
.
shift_matrix
.
inv
()
@
property
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment