Commit f0a13c22 authored by itischler's avatar itischler
Browse files

formatting

parent 3bc8668a
Pipeline #32430 failed with stages
in 17 minutes and 47 seconds
import warnings
# import warnings
import numpy as np
import sympy as sp
......@@ -6,8 +6,6 @@ from jinja2 import Environment, PackageLoader, StrictUndefined, Template
from sympy.tensor import IndexedBase
import pystencils as ps
#from lbmpy.creationfunctions import create_lb_update_rule, update_with_default_parameters
from lbmpy.fieldaccess import CollideOnlyInplaceAccessor, StreamPullTwoFieldsAccessor
from lbmpy.relaxationrates import relaxation_rate_scaling
from lbmpy.stencils import get_stencil
......@@ -95,7 +93,7 @@ def __lattice_model(generation_context, class_name, lb_method, stream_collide_as
'Q': len(lb_method.stencil),
'compressible': lb_method.conserved_quantity_computation.compressible,
'weights': ",".join(str(w.evalf()) + constant_suffix for w in lb_method.weights),
'inverse_weights': ",".join(str((1/w).evalf()) + constant_suffix for w in lb_method.weights),
'inverse_weights': ",".join(str((1 / w).evalf()) + constant_suffix for w in lb_method.weights),
'equilibrium_from_direction': stencil_switch_statement(lb_method.stencil, equilibrium),
'symmetric_equilibrium_from_direction': stencil_switch_statement(lb_method.stencil, symmetric_equilibrium),
......@@ -108,7 +106,7 @@ def __lattice_model(generation_context, class_name, lb_method, stream_collide_as
'momentum_density_getter': equations_to_code(momentum_density_getter, variables_without_prefix=pdfs_sym,
dtype=dtype_string),
'second_momentum_getter': equations_to_code(second_momentum_getter, variables_without_prefix=pdfs_sym,
dtype=dtype_string),
dtype=dtype_string),
'density_velocity_setter_macroscopic_values': density_velocity_setter_macroscopic_values,
......@@ -120,7 +118,10 @@ def __lattice_model(generation_context, class_name, lb_method, stream_collide_as
'target': 'cpu',
'namespace': 'lbm',
'headers': required_headers,
'need_block_offsets': ['block_offset_{}'.format(i) in [param.symbol.name for param in stream_collide_ast.get_parameters()] for i in range(3)],
'need_block_offsets': [
'block_offset_{}'.format(i) in [param.symbol.name for param in stream_collide_ast.get_parameters()] for i in
range(3)],
}
env = Environment(loader=PackageLoader('lbmpy_walberla'), undefined=StrictUndefined)
......@@ -155,7 +156,8 @@ def generate_lattice_model(generation_context, class_name, collision_rule, field
create_kernel_params['cpu_vectorize_info']['assume_inner_stride_one'] = False
src_field = ps.Field.create_generic('pdfs', dim, dtype, index_dimensions=1, layout=field_layout, index_shape=(q,))
dst_field = ps.Field.create_generic('pdfs_tmp', dim, dtype, index_dimensions=1, layout=field_layout, index_shape=(q,))
dst_field = ps.Field.create_generic('pdfs_tmp', dim, dtype, index_dimensions=1, layout=field_layout,
index_shape=(q,))
stream_collide_update_rule = create_lbm_kernel(collision_rule, src_field, dst_field, StreamPullTwoFieldsAccessor())
stream_collide_ast = create_kernel(stream_collide_update_rule, **create_kernel_params)
......@@ -167,7 +169,8 @@ def generate_lattice_model(generation_context, class_name, collision_rule, field
collide_ast.function_name = 'kernel_collide'
collide_ast.assumed_inner_stride_one = create_kernel_params['cpu_vectorize_info']['assume_inner_stride_one']
stream_update_rule = create_stream_pull_only_kernel(lb_method.stencil, None, 'pdfs', 'pdfs_tmp', field_layout, dtype)
stream_update_rule = create_stream_pull_only_kernel(lb_method.stencil, None, 'pdfs', 'pdfs_tmp', field_layout,
dtype)
stream_ast = create_kernel(stream_update_rule, **create_kernel_params)
stream_ast.function_name = 'kernel_stream'
stream_ast.assumed_inner_stride_one = create_kernel_params['cpu_vectorize_info']['assume_inner_stride_one']
......@@ -309,9 +312,11 @@ def equations_to_code(equations, variable_prefix="lm.", variables_without_prefix
result = []
left_hand_side_names = [e.lhs.name for e in equations]
for eq in equations:
assignment = SympyAssignment(type_expr(eq.lhs,dtype=dtype),
assignment = SympyAssignment(type_expr(eq.lhs, dtype=dtype),
type_expr(field_and_symbol_substitute(eq.rhs, variable_prefix,
variables_without_prefix + left_hand_side_names),dtype=dtype))
variables_without_prefix
+ left_hand_side_names),
dtype=dtype))
result.append(c_backend(assignment))
return "\n".join(result)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment