diff options
author | Adrian Kummerlaender | 2019-10-31 13:13:00 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2019-10-31 13:13:00 +0100 |
commit | e2b00f4ec963060be98939c7b0d12d6c00e50a02 (patch) | |
tree | 9b8729d491a2d9cb2b5fafe8284bc807ad21665a /boltzgen/utility | |
parent | c82b38122cc3ab7717cb0ba9ec530b4658bd03e4 (diff) | |
download | boltzgen-e2b00f4ec963060be98939c7b0d12d6c00e50a02.tar boltzgen-e2b00f4ec963060be98939c7b0d12d6c00e50a02.tar.gz boltzgen-e2b00f4ec963060be98939c7b0d12d6c00e50a02.tar.bz2 boltzgen-e2b00f4ec963060be98939c7b0d12d6c00e50a02.tar.lz boltzgen-e2b00f4ec963060be98939c7b0d12d6c00e50a02.tar.xz boltzgen-e2b00f4ec963060be98939c7b0d12d6c00e50a02.tar.zst boltzgen-e2b00f4ec963060be98939c7b0d12d6c00e50a02.zip |
Call symbolic generator inside code templates
This paves the way for dropping in other LBM collision models.
As a side benefit the default momenta calulcation is now fully inlined where possible.
Diffstat (limited to 'boltzgen/utility')
-rw-r--r-- | boltzgen/utility/optimizations.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/boltzgen/utility/optimizations.py b/boltzgen/utility/optimizations.py index 93dad09..6dc23e9 100644 --- a/boltzgen/utility/optimizations.py +++ b/boltzgen/utility/optimizations.py @@ -2,9 +2,17 @@ from sympy import * from sympy.codegen.rewriting import ReplaceOptim -expand_square = ReplaceOptim( +expand_pos_square = ReplaceOptim( lambda e: e.is_Pow and e.exp.is_integer and e.exp == 2, lambda p: UnevaluatedExpr(Mul(p.base, p.base, evaluate = False)) ) -custom = [ (expand_square, expand_square) ] + cse_main.basic_optimizations +expand_neg_square = ReplaceOptim( + lambda e: e.is_Pow and e.exp.is_integer and e.exp == -2, + lambda p: UnevaluatedExpr(Mul(p.base, p.base, evaluate = False)) +) + +custom = [ + (expand_pos_square, expand_pos_square), + (expand_neg_square, expand_neg_square) +] + cse_main.basic_optimizations |