From c98cac510011ce916b9faa29a039a46967749a42 Mon Sep 17 00:00:00 2001 From: Christoph Rettinger <christoph.rettinger@fau.de> Date: Fri, 28 Feb 2020 10:30:08 +0100 Subject: [PATCH] Explicitly set moments in codegen files to avoid unnoticed changes in lbmpy --- .../FluidParticleCoupling/GeneratedLBM.py | 17 ++++++++++++++--- .../GeneratedLBMWithForce.py | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/apps/benchmarks/FluidParticleCoupling/GeneratedLBM.py b/apps/benchmarks/FluidParticleCoupling/GeneratedLBM.py index bf127f8eb..461291dbd 100644 --- a/apps/benchmarks/FluidParticleCoupling/GeneratedLBM.py +++ b/apps/benchmarks/FluidParticleCoupling/GeneratedLBM.py @@ -5,15 +5,26 @@ from lbmpy_walberla import generate_lattice_model from pystencils_walberla import CodeGeneration from lbmpy.creationfunctions import create_lb_collision_rule -from lbmpy.moments import is_even, get_order +from lbmpy.moments import is_even, get_order, MOMENT_SYMBOLS from lbmpy.stencils import get_stencil -from lbmpy.methods import mrt_orthogonal_modes_literature with CodeGeneration() as ctx: stencil = get_stencil("D3Q19", 'walberla') omega = sp.symbols("omega_:%d" % len(stencil)) - moments = mrt_orthogonal_modes_literature(stencil, True, False) + + x, y, z = MOMENT_SYMBOLS + one = sp.Rational(1, 1) + sq = x ** 2 + y ** 2 + z ** 2 + moments = [ + [one, x, y, z], # [0, 3, 5, 7] + [sq - 1], # [1] + [3 * sq ** 2 - 6 * sq + 1], # [2] + [(3 * sq - 5) * x, (3 * sq - 5) * y, (3 * sq - 5) * z], # [4, 6, 8] + [3 * x ** 2 - sq, y ** 2 - z ** 2, x * y, y * z, x * z], # [9, 11, 13, 14, 15] + [(2 * sq - 3) * (3 * x ** 2 - sq), (2 * sq - 3) * (y ** 2 - z ** 2)], # [10, 12] + [(y ** 2 - z ** 2) * x, (z ** 2 - x ** 2) * y, (x ** 2 - y ** 2) * z] # [16, 17, 18] + ] method = create_lb_method(stencil=stencil, method='mrt', maxwellian_moments=False, nested_moments=moments) def modification_func(moment, eq, rate): diff --git a/apps/benchmarks/FluidParticleCoupling/GeneratedLBMWithForce.py b/apps/benchmarks/FluidParticleCoupling/GeneratedLBMWithForce.py index d52d67dfc..9293f976f 100644 --- a/apps/benchmarks/FluidParticleCoupling/GeneratedLBMWithForce.py +++ b/apps/benchmarks/FluidParticleCoupling/GeneratedLBMWithForce.py @@ -5,10 +5,9 @@ from lbmpy_walberla import generate_lattice_model from pystencils_walberla import CodeGeneration from lbmpy.creationfunctions import create_lb_collision_rule -from lbmpy.moments import is_even, get_order +from lbmpy.moments import is_even, get_order, MOMENT_SYMBOLS from lbmpy.stencils import get_stencil from lbmpy.forcemodels import Luo -from lbmpy.methods import mrt_orthogonal_modes_literature with CodeGeneration() as ctx: @@ -18,7 +17,19 @@ with CodeGeneration() as ctx: stencil = get_stencil("D3Q19", 'walberla') omega = sp.symbols("omega_:%d" % len(stencil)) - moments = mrt_orthogonal_modes_literature(stencil, True, False) + x, y, z = MOMENT_SYMBOLS + one = sp.Rational(1, 1) + sq = x ** 2 + y ** 2 + z ** 2 + moments = [ + [one, x, y, z], # [0, 3, 5, 7] + [sq - 1], # [1] + [3 * sq ** 2 - 6 * sq + 1], # [2] + [(3 * sq - 5) * x, (3 * sq - 5) * y, (3 * sq - 5) * z], # [4, 6, 8] + [3 * x ** 2 - sq, y ** 2 - z ** 2, x * y, y * z, x * z], # [9, 11, 13, 14, 15] + [(2 * sq - 3) * (3 * x ** 2 - sq), (2 * sq - 3) * (y ** 2 - z ** 2)], # [10, 12] + [(y ** 2 - z ** 2) * x, (z ** 2 - x ** 2) * y, (x ** 2 - y ** 2) * z] # [16, 17, 18] + ] + methodWithForce = create_lb_method(stencil=stencil, method='mrt', maxwellian_moments=False, force_model=forcemodel, nested_moments=moments) -- GitLab