Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP change lb density to delta_density in the generated kernels #4775

Open
wants to merge 1 commit into
base: python
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions maintainer/walberla_kernels/generate_lb_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
target = ps.Target.CPU

# Make sure we have the correct versions of the required dependencies
for module, requirement in [(ps, "==1.2"), (lbmpy, "==1.2")]:
assert pkg_resources.packaging.specifiers.SpecifierSet(requirement).contains(module.__version__), \
f"{module.__name__} version {module.__version__} doesn't match requirement {requirement}"
#for module, requirement in [(ps, "==1.2"), (lbmpy, "==1.2")]:
# assert pkg_resources.packaging.specifiers.SpecifierSet(requirement).contains(module.__version__), \
# f"{module.__name__} version {module.__version__} doesn't match requirement {requirement}"


def paramlist(parameters, keys):
Expand Down Expand Up @@ -101,6 +101,8 @@ def paramlist(parameters, keys):
stencil=stencil,
compressible=True,
weighted=True,
zero_centered=True,
delta_equilibrium=True,
relaxation_rates=relaxation_rates.rr_getter,
force_model=lbmpy.forcemodels.Schiller(force_field.center_vector)
)
Expand All @@ -126,7 +128,8 @@ def paramlist(parameters, keys):
method=lbmpy.Method.TRT,
relaxation_rate=sp.Symbol("omega_shear"),
compressible=True,
zero_centered=False,
zero_centered=True,
delta_equilibrium=True,
force_model=lbmpy.ForceModel.GUO,
force=force_field.center_vector,
kernel_type="collide_only")
Expand All @@ -149,7 +152,8 @@ def paramlist(parameters, keys):
# generate thermalized LB
collision_rule_thermalized = lbmpy.creationfunctions.create_lb_collision_rule(
method,
zero_centered=False,
zero_centered=True,
delta_equilibrium=True,
fluctuating={
"temperature": kT,
"block_offsets": "walberla",
Expand Down
5 changes: 4 additions & 1 deletion maintainer/walberla_kernels/templates/FieldAccessors.tmpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ namespace EquilibriumDistribution
inline {{dtype}}
get( stencil::Direction const direction,
Vector{{D}}< {{dtype}} > const & u = Vector{{D}}< {{dtype}} >( {{dtype}}(0.0) ),
{{dtype}} rho = {{dtype}}(1.0) )
{{dtype}} rho = {{dtype}}(0.0) )
{
{{dtype}} delta_rho = rho - {{dtype}}(1.0);
{% if not compressible %}
rho -= {{dtype}}(1.0);
{% endif %}
Expand All @@ -255,6 +256,7 @@ namespace Equilibrium
{{dtype}} const rho,
Cell const & cell )
{
{{dtype}} delta_rho = rho - {{dtype}}(1.0);
{%if not compressible %}
rho -= {{dtype}}(1.0);
{%endif %}
Expand Down Expand Up @@ -285,6 +287,7 @@ namespace Density
{{dtype}} const rho_in,
Cell const & cell )
{
{{dtype}} const delta_rho_in = rho_in - {{dtype}} (1.0);
const {{dtype}} & xyz0 = pdf_field->get(cell, uint_t{ 0u });
{% for i in range(Q) -%}
const {{dtype}} f_{{i}} = pdf_field->getF( &xyz0, uint_t{ {{i}}u });
Expand Down
3 changes: 2 additions & 1 deletion maintainer/walberla_kernels/walberla_lbm_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def generate_macroscopic_values_accessors(ctx, config, lb_method, templates):
cqc = lb_method.conserved_quantity_computation
vel_symbols = cqc.velocity_symbols
rho_sym = sp.Symbol("rho")
delta_rho_sym = sp.Symbol("delta_rho")
pdfs_sym = sp.symbols(f"f_:{lb_method.stencil.Q}")
vel_arr_symbols = [
IndexedBase(TypedSymbol("u", dtype=default_dtype), shape=(1,))[i]
Expand All @@ -166,7 +167,7 @@ def generate_macroscopic_values_accessors(ctx, config, lb_method, templates):

velocity_getters = make_velocity_getters(cqc, rho_sym, vel_arr_symbols)
density_velocity_setter_macroscopic_values = equations_to_code(
velocity_getters, variables_without_prefix=["rho", "u"], **kwargs)
velocity_getters, variables_without_prefix=["rho", "u", "delta_rho"], **kwargs)
momentum_density_getter = cqc.output_equations_from_pdfs(
pdfs_sym, {"density": rho_sym, "momentum_density": momentum_density_symbols})
unshifted_momentum_density_getter = cqc.output_equations_from_pdfs(
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
//! \\author pystencils
//======================================================================================================================

// kernel generated with pystencils v1.2, lbmpy v1.2,
// lbmpy_walberla/pystencils_walberla from waLBerla commit
// 4d10e7f2358fc4a4f7e99195d0f67f0b759ecb6f
// kernel generated with pystencils v1.3.1+2.g60e24c4, lbmpy
// v1.3.1+6.gcd1bc2f.dirty, lbmpy_walberla/pystencils_walberla from waLBerla
// commit 065ce5f311850371a97ac4766f47dbb5ca8424ba

#pragma once
#include "core/DataTypes.h"
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
//! \\author pystencils
//======================================================================================================================

// kernel generated with pystencils v1.2, lbmpy v1.2,
// lbmpy_walberla/pystencils_walberla from waLBerla commit
// 4d10e7f2358fc4a4f7e99195d0f67f0b759ecb6f
// kernel generated with pystencils v1.3.1+2.g60e24c4, lbmpy
// v1.3.1+6.gcd1bc2f.dirty, lbmpy_walberla/pystencils_walberla from waLBerla
// commit 065ce5f311850371a97ac4766f47dbb5ca8424ba

#pragma once
#include "core/DataTypes.h"
Expand Down
Loading