Commit cb632b10 authored by Frederik Hennig's avatar Frederik Hennig
Browse files

Merge branch 'master' into fix_macroscopic_value_kernels

parents 84ce16ba e7823f08
Pipeline #35452 passed with stages
in 47 minutes and 49 seconds
This diff is collapsed.
from hashlib import sha256
from pystencils import Backend, Target
from pystencils import Backend, CreateKernelConfig, Target
from lbmpy.creationfunctions import create_lb_ast
from lbmpy.enums import Stencil, Method
from lbmpy.creationfunctions import LBMConfig
from lbmpy.stencils import LBStencil
def test_hash_equivalence_llvm():
import pytest
pytest.importorskip("llvmlite")
from pystencils.llvm.llvmjit import generate_llvm
ref_value = "a25d1507f222fc50c3900108835976445360b09ffd7f51635c441473f4baab23"
ast = create_lb_ast(stencil='D3Q19', method='srt', optimization={'backend': Backend.LLVM})
ref_value = "f1b1879e304fe8533977c885f2744516dd4964064a7e4ae64fd94b8426d995bb"
lbm_config = LBMConfig(stencil=LBStencil(Stencil.D2Q9), method=Method.SRT)
config = CreateKernelConfig(target=Target.CPU, backend=Backend.LLVM)
ast = create_lb_ast(lbm_config=lbm_config, config=config)
code = generate_llvm(ast)
hash_value = sha256(str(code).encode()).hexdigest()
assert hash_value == ref_value
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -87,7 +87,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
......@@ -101,7 +101,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
"version": "3.9.7"
}
},
"nbformat": 4,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
import numpy as np
from lbmpy.boundaries import UBB, NoSlip
from lbmpy.enums import ForceModel
from lbmpy.scenarios import create_channel
from pystencils import make_slice
......@@ -26,10 +27,11 @@ def test_force_on_boundary():
for parallel in (False, True) if wLB else (False,):
for boundary_obj in boundaries:
print("Testing parallel %d, boundary %s" % (parallel, boundary_obj.name))
step = create_channel(domain_size, force=1e-5, relaxation_rate=1.5, parallel=parallel, force_model='buick')
print(f"Testing parallel {parallel}, boundary {boundary_obj.name}")
step = create_channel(domain_size, force=1e-5, relaxation_rate=1.5, parallel=parallel,
force_model=ForceModel.BUICK)
force = calculate_force(step, boundary_obj)
print(" -> force = ", force)
print(f" -> force = {force}")
results.append(force)
for res in results[1:]:
......
This diff is collapsed.
......@@ -4,8 +4,10 @@ import numpy as np
import pytest
from lbmpy.boundaries import NoSlip
from lbmpy.enums import Method
from lbmpy.geometry import add_black_and_white_image, add_pipe_walls
from lbmpy.lbstep import LatticeBoltzmannStep
import lbmpy.plot as plt
from pystencils.slicing import make_slice
......@@ -23,23 +25,20 @@ def test_pipe():
plot = False
for domain_size in [(30, 10, 10), (30, 10)]:
for diameter in [5, 10, diameter_callback]:
sc = LatticeBoltzmannStep(domain_size=domain_size, method='srt', relaxation_rate=1.9,
optimization={})
sc = LatticeBoltzmannStep(domain_size=domain_size, method=Method.SRT, relaxation_rate=1.9)
add_pipe_walls(sc.boundary_handling, diameter)
if plot:
import lbmpy.plot as plt
from pystencils.slicing import make_slice
if len(domain_size) == 2:
plt.boundary_handling(sc.boundary_handling)
plt.title("2D, diameter=%s" % (str(diameter,)))
plt.title(f"2D, diameter={str(diameter,)}")
plt.show()
elif len(domain_size) == 3:
plt.subplot(1, 2, 1)
plt.boundary_handling(sc.boundary_handling, make_slice[0.5, :, :])
plt.title("3D, diameter=%s" % (str(diameter,)))
plt.title(f"3D, diameter={str(diameter,)}")
plt.subplot(1, 2, 2)
plt.boundary_handling(sc.boundary_handling, make_slice[:, 0.5, :])
plt.title("3D, diameter=%s" % (str(diameter, )))
plt.title(f"3D, diameter={str(diameter, )}")
plt.show()
......@@ -51,14 +50,12 @@ def get_test_image_path():
def test_image():
pytest.importorskip('scipy.ndimage')
sc = LatticeBoltzmannStep(domain_size=(50, 40), method='srt', relaxation_rate=1.9,
optimization={})
sc = LatticeBoltzmannStep(domain_size=(50, 40), method=Method.SRT, relaxation_rate=1.9)
add_black_and_white_image(sc.boundary_handling, get_test_image_path(), keep_aspect_ratio=True)
def test_slice_mask_combination():
sc = LatticeBoltzmannStep(domain_size=(30, 30), method='srt', relaxation_rate=1.9,
optimization={})
sc = LatticeBoltzmannStep(domain_size=(30, 30), method=Method.SRT, relaxation_rate=1.9)
def callback(*coordinates):
x = coordinates[0]
......
This diff is collapsed.
This diff is collapsed.
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