diff --git a/lbmpy/boundaries/boundaryconditions.py b/lbmpy/boundaries/boundaryconditions.py index 6632228176e5b9d40c56004f00846a88edcde8e8..ddf82effa543ae31cf72407a3a27a30d4ff3000e 100644 --- a/lbmpy/boundaries/boundaryconditions.py +++ b/lbmpy/boundaries/boundaryconditions.py @@ -260,16 +260,3 @@ class StreamInConstant(LbBoundary): def __eq__(self, other): return type(other) == StreamInConstant # end class StreamInConstant - - -# ------------------------- Old, Deprecated Implementation ------------------------- - -class Boundary(LbBoundary): - - def __init__(self, name=None): - from lbmpy.boundaries.boundaryhandling import deprecation_message - deprecation_message() - self._name = name - - def __call__(self, pdf_field, direction_symbol, lb_method, index_field): - raise NotImplementedError("Boundary class has to overwrite __call__") diff --git a/lbmpy/boundaries/boundaryhandling.py b/lbmpy/boundaries/boundaryhandling.py index 600d01bea159d4390565bcf4a1231c2b52707f9a..b8a52fcf43b301ef47f5ca747b67ca0a00d36efc 100644 --- a/lbmpy/boundaries/boundaryhandling.py +++ b/lbmpy/boundaries/boundaryhandling.py @@ -65,7 +65,7 @@ class LatticeBoltzmannBoundaryHandling(BoundaryHandling): return create_lattice_boltzmann_boundary_kernel( symbolic_field, symbolic_index_field, self._lb_method, boundary_obj, prev_timestep=prev_timestep, streaming_pattern=self._streaming_pattern, - target=self._target, openmp=self._openmp) + target=self._target, cpu_openmp=self._openmp) class InplaceStreamingBoundaryInfo(object): @@ -175,11 +175,7 @@ class LbmWeightInfo(CustomCodeNode): def create_lattice_boltzmann_boundary_kernel(pdf_field, index_field, lb_method, boundary_functor, prev_timestep=Timestep.BOTH, streaming_pattern='pull', - target='cpu', openmp=True, **kernel_creation_args): - from lbmpy.boundaries.boundaryconditions import Boundary as OldBoundary - if isinstance(boundary_functor, OldBoundary): - return create_lattice_boltzmann_boundary_kernel_old(pdf_field, index_field, lb_method, boundary_functor, - target=target, openmp=openmp, **kernel_creation_args) + target='cpu', **kernel_creation_args): index_dtype = index_field.dtype.numpy_dtype.fields['dir'][0] offsets_dtype = index_field.dtype.numpy_dtype.fields['x'][0] @@ -197,7 +193,7 @@ def create_lattice_boltzmann_boundary_kernel(pdf_field, index_field, lb_method, elements = [Assignment(dir_symbol, index_field[0]('dir'))] elements += boundary_assignments.all_assignments - kernel = create_indexed_kernel(elements, [index_field], target=target, cpu_openmp=openmp, **kernel_creation_args) + kernel = create_indexed_kernel(elements, [index_field], target=target, **kernel_creation_args) # Code Elements ahead of the loop index_arrs_node = indexing.create_code_node() @@ -205,28 +201,3 @@ def create_lattice_boltzmann_boundary_kernel(pdf_field, index_field, lb_method, kernel.body.insert_front(node) kernel.body.insert_front(index_arrs_node) return kernel - - -# ----------------------------- Old, Deprecated Implementation ----------------------- - -def deprecation_message(): - import warnings - deprecation_message = "The old code generation scheme for LB boundaries has been deprecated. " \ - + "Please update your boundary implementation to derive from ``LbBoundary`` " \ - + "and use the new implementation scheme based on `BetweenTimestepsIndexing`." - warnings.simplefilter('always', DeprecationWarning) - warnings.warn(deprecation_message, DeprecationWarning, stacklevel=2) - warnings.simplefilter('default', DeprecationWarning) - - -def create_lattice_boltzmann_boundary_kernel_old(pdf_field, index_field, lb_method, boundary_functor, - target='cpu', openmp=True, **kernel_creation_args): - deprecation_message() - from pystencils.boundaries.boundaryhandling import BoundaryOffsetInfo - elements = [BoundaryOffsetInfo(lb_method.stencil), LbmWeightInfo(lb_method)] - index_arr_dtype = index_field.dtype.numpy_dtype - dir_symbol = TypedSymbol("dir", index_arr_dtype.fields['dir'][0]) - elements += [Assignment(dir_symbol, index_field[0]('dir'))] - elements += boundary_functor(pdf_field=pdf_field, direction_symbol=dir_symbol, - lb_method=lb_method, index_field=index_field) - return create_indexed_kernel(elements, [index_field], target=target, cpu_openmp=openmp, **kernel_creation_args) diff --git a/lbmpy/moments.py b/lbmpy/moments.py index 13a84ce62c52cff5ac155c96ec703dd20f04d8fa..bd42fc9f54db89500e5b3e686d885e3e849fc38f 100644 --- a/lbmpy/moments.py +++ b/lbmpy/moments.py @@ -453,10 +453,10 @@ def extract_monomials(sequence_of_polynomials, dim=3): dim: length of returned exponent tuples >>> x, y, z = MOMENT_SYMBOLS - >>> extract_monomials([x**2 + y**2 + y, y + y**2]) - {(0, 2, 0), (0, 1, 0), (2, 0, 0)} - >>> extract_monomials([x**2 + y**2 + y, y + y**2], dim=2) - {(0, 1), (0, 2), (2, 0)} + >>> extract_monomials([x**2 + y**2 + y, y + y**2]) == {(0, 1, 0),(0, 2, 0),(2, 0, 0)} + True + >>> extract_monomials([x**2 + y**2 + y, y + y**2], dim=2) == {(0, 1), (0, 2), (2, 0)} + True """ monomials = set() for polynomial in sequence_of_polynomials: @@ -477,10 +477,11 @@ def monomial_to_polynomial_transformation_matrix(monomials, polynomials): >>> polys = [7 * x**2 + 3 * x + 2 * y **2, \ 9 * x**2 - 5 * x] >>> mons = list(extract_monomials(polys, dim=2)) + >>> mons.sort() >>> monomial_to_polynomial_transformation_matrix(mons, polys) Matrix([ - [ 3, 2, 7], - [-5, 0, 9]]) + [2, 3, 7], + [0, -5, 9]]) """ dim = len(monomials[0]) diff --git a/lbmpy_tests/test_force.py b/lbmpy_tests/test_force.py index 79872b7b17d7927af3b3bfdbcd2724ebdcd6d2b7..31412d8ce9d2b63da5b78d531b3c22a06d90875b 100644 --- a/lbmpy_tests/test_force.py +++ b/lbmpy_tests/test_force.py @@ -117,7 +117,7 @@ def test_modes(stencil, force_model): # The stress moments should match eq. 47 from https://doi.org/10.1023/A:1010414013942 u = method.first_order_equilibrium_moment_symbols def traceless(m): - tr = sp.simplify(sp.Trace(m)) + tr = sp.simplify(sum([m[i,i] for i in range(dim)])) return m - tr/m.shape[0]*sp.eye(m.shape[0]) C = sp.Rational(1,2) * (2 + lambda_s) * (traceless(sp.Matrix(u) * sp.Matrix(F).transpose()) + \ traceless(sp.Matrix(F) * sp.Matrix(u).transpose())) + \