Commit 247ad9f9 authored by Martin Bauer's avatar Martin Bauer
Browse files

Rest of PEP8 renaming

parent 8a9497a9
......@@ -6,8 +6,8 @@ from pystencils.data_types import create_type, TypedSymbol
from pystencils_walberla.jinja_filters import add_pystencils_filters_to_jinja_env
from lbmpy.boundaries.boundaryhandling import create_lattice_boltzmann_boundary_kernel
from pystencils.boundaries.createindexlist import numpyDataTypeForBoundaryObject, \
boundaryIndexArrayCoordinateNames, directionMemberName
from pystencils.boundaries.createindexlist import numpy_data_type_for_boundary_object, \
boundary_index_array_coordinate_names, direction_member_name
from lbmpy_walberla.walberla_lbm_generation import KernelInfo
......@@ -17,10 +17,10 @@ def struct_from_numpy_dtype(struct_name, numpy_dtype):
equality_compare = []
constructor_params = []
constructor_initializer_list = []
for name, (subType, offset) in numpy_dtype.fields.items():
pystencils_type = create_type(subType)
for name, (sub_type, offset) in numpy_dtype.fields.items():
pystencils_type = create_type(sub_type)
result += " %s %s;\n" % (pystencils_type, name)
if name in boundaryIndexArrayCoordinateNames or name == directionMemberName:
if name in boundary_index_array_coordinate_names or name == direction_member_name:
constructor_params.append("%s %s_" % (pystencils_type, name))
constructor_initializer_list.append("%s(%s_)" % (name, name))
else:
......@@ -30,7 +30,8 @@ def struct_from_numpy_dtype(struct_name, numpy_dtype):
else:
equality_compare.append("%s == o.%s" % (name, name))
result += " %s(%s) : %s {}\n" % (struct_name, ", ".join(constructor_params), ", ".join(constructor_initializer_list))
result += " %s(%s) : %s {}\n" % \
(struct_name, ", ".join(constructor_params), ", ".join(constructor_initializer_list))
result += " bool operator==(const %s & o) const {\n return %s;\n }\n" % \
(struct_name, " && ".join(equality_compare))
result += "};\n"
......@@ -39,7 +40,7 @@ def struct_from_numpy_dtype(struct_name, numpy_dtype):
def create_boundary_class(boundary_object, lb_method, double_precision=True, target='cpu'):
struct_name = "IndexInfo"
index_struct_dtype = numpyDataTypeForBoundaryObject(boundary_object, lb_method.dim)
index_struct_dtype = numpy_data_type_for_boundary_object(boundary_object, lb_method.dim)
pdf_field = Field.create_generic('pdfs', lb_method.dim, np.float64 if double_precision else np.float32,
index_dimensions=1, layout='fzyx', index_shape=[len(lb_method.stencil)])
......@@ -52,7 +53,7 @@ def create_boundary_class(boundary_object, lb_method, double_precision=True, tar
stencil_info = [(i, ", ".join([str(e) for e in d])) for i, d in enumerate(lb_method.stencil)]
context = {
'className': boundary_object.name,
'class_name': boundary_object.name,
'StructName': struct_name,
'StructDeclaration': struct_from_numpy_dtype(struct_name, index_struct_dtype),
'kernel': KernelInfo(kernel, [], []),
......
......@@ -19,25 +19,25 @@ from lbmpy.creationfunctions import create_lb_method, update_with_default_parame
create_lb_ast
from lbmpy.updatekernels import create_stream_pull_only_kernel
cppPrinter = CustomSympyPrinter()
cpp_printer = CustomSympyPrinter()
REFINEMENT_SCALE_FACTOR = sp.Symbol("levelScaleFactor")
REFINEMENT_SCALE_FACTOR = sp.Symbol("level_scale_factor")
def stencil_switch_statement(stencil, values):
template = Template("""
using namespace stencil;
switch( direction ) {
{% for directionName, value in dir_to_value_dict.items() -%}
case {{directionName}}: return {{value}};
{% for direction_name, value in dir_to_value_dict.items() -%}
case {{direction_name}}: return {{value}};
{% endfor -%}
default:
WALBERLA_ABORT("Invalid Direction");
}
""")
dir_to_value_dict = {offset_to_direction_string(d): cppPrinter.doprint(v) for d, v in zip(stencil, values)}
dir_to_value_dict = {offset_to_direction_string(d): cpp_printer.doprint(v) for d, v in zip(stencil, values)}
return template.render(dir_to_value_dict=dir_to_value_dict)
......@@ -69,7 +69,7 @@ def expression_to_code(expr, variable_prefix="lm.", variables_without_prefix=[])
:param variables_without_prefix: this variables are not prefixed
:return: code string
"""
return cppPrinter.doprint(field_and_symbol_substitute(expr, variable_prefix, variables_without_prefix))
return cpp_printer.doprint(field_and_symbol_substitute(expr, variable_prefix, variables_without_prefix))
def equations_to_code(equations, variable_prefix="lm.", variables_without_prefix=[]):
......@@ -94,7 +94,7 @@ def equations_to_code(equations, variable_prefix="lm.", variables_without_prefix
def generate_lattice_model(lattice_model_name=None, optimization={}, refinement_scaling=None,
lb_method=None, **kwargs):
"""
Creates a waLBerla lattice model consisting of a source and header file
Creates a walberla lattice model consisting of a source and header file
:param lattice_model_name: name of the generated lattice model class. If None, it is assumed that this function was
called from a .gen.py file and the filename is taken as lattice model name
......@@ -168,9 +168,9 @@ def generate_lattice_model(lattice_model_name=None, optimization={}, refinement_
cqc = lb_method.conserved_quantity_computation
eq_input_from_input_eqs = cqc.equilibrium_input_equations_from_init_values(sp.Symbol("rhoIn"), vel_arr_symbols)
eq_input_from_input_eqs = cqc.equilibrium_input_equations_from_init_values(sp.Symbol("rho_in"), vel_arr_symbols)
density_velocity_setter_macroscopic_values = equations_to_code(eq_input_from_input_eqs,
variables_without_prefix=['rhoIn', 'u'])
variables_without_prefix=['rho_in', 'u'])
momentum_density_getter = cqc.output_equations_from_pdfs(pdfs_sym, {'density': rho_sym,
'momentum_density': momentum_density_symbols})
......@@ -188,7 +188,7 @@ def generate_lattice_model(lattice_model_name=None, optimization={}, refinement_
'equilibrium_from_direction': stencil_switch_statement(lb_method.stencil, equilibrium),
'symmetric_equilibrium_from_direction': stencil_switch_statement(lb_method.stencil, symmetric_equilibrium),
'asymmetric_equilibrium_from_direction': stencil_switch_statement(lb_method.stencil, asymmetric_equilibrium),
'equilibrium': [cppPrinter.doprint(e) for e in equilibrium],
'equilibrium': [cpp_printer.doprint(e) for e in equilibrium],
'macroscopic_velocity_shift': macroscopic_velocity_shift,
'density_getters': equations_to_code(cqc.output_equations_from_pdfs(pdfs_sym, {"density": rho_sym}),
......@@ -216,7 +216,7 @@ def generate_lattice_model(lattice_model_name=None, optimization={}, refinement_
def generate_lattice_model_files(class_name, *args, **kwargs):
"""
:param kwargs: see documentation of create_lb_ast, additionally
an instance of RefinementScaling can be passed with the 'refinementScaling' keyword
an instance of RefinementScaling can be passed with the 'refinement_scaling' keyword
"""
from pystencils_walberla.cmake_integration import codegen
......@@ -228,7 +228,7 @@ def generate_lattice_model_files(class_name, *args, **kwargs):
class RefinementScaling:
levelScaleFactor = sp.Symbol("levelScaleFactor")
level_scale_factor = sp.Symbol("level_scale_factor")
def __init__(self):
self.scaling_info = []
......@@ -256,18 +256,18 @@ class RefinementScaling:
else:
scaling_type = 'field_xyz'
field_access = field.center
expr = scaling_rule(field_access, self.levelScaleFactor)
expr = scaling_rule(field_access, self.level_scale_factor)
self.scaling_info.append((scaling_type, name, expression_to_code(expr, '')))
elif isinstance(parameter, Field.Access):
field_access = parameter
expr = scaling_rule(field_access, self.levelScaleFactor)
expr = scaling_rule(field_access, self.level_scale_factor)
name = field_access.field.name
self.scaling_info.append(('field_xyz', name, expression_to_code(expr, '')))
elif isinstance(parameter, sp.Symbol):
expr = scaling_rule(parameter, self.levelScaleFactor)
expr = scaling_rule(parameter, self.level_scale_factor)
self.scaling_info.append(('normal', parameter.name, expression_to_code(expr, '')))
elif isinstance(parameter, list) or isinstance(parameter, tuple):
for p in parameter:
self.add_scaling(p, scaling_rule)
else:
raise ValueError("Invalid value for viscosityRelaxationRate")
raise ValueError("Invalid value for viscosity_relaxation_rate")
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