Skip to content
Snippets Groups Projects
Commit 74b891c3 authored by Markus Holzer's avatar Markus Holzer
Browse files

shortened some test cases

parent e7823f08
Branches
Tags
No related merge requests found
......@@ -58,7 +58,7 @@ def check_for_collision_rule_equivalence(collision_rule1, collision_rule2, use_n
for eq1, eq2 in zip(collision_rule1.main_assignments, collision_rule2.main_assignments):
diff = sp.cancel(sp.expand(eq1.rhs - eq2.rhs))
if use_numeric_subs:
assert math.isclose(diff, 0, rel_tol=0.0, abs_tol=1e-12)
assert math.isclose(diff, 0, rel_tol=0.0, abs_tol=1e-10)
else:
assert diff == 0
......@@ -78,8 +78,8 @@ def test_cumulant():
original_method = create_with_default_polynomial_cumulants(stencil, [sp.Symbol("omega")])
changed_method = __change_relaxation_rate_of_conserved_moments(original_method)
check_method_equivalence(original_method, changed_method, True, True)
check_method_equivalence(original_method, changed_method, False, True)
check_method_equivalence(original_method, changed_method, True, use_numeric_subs=True)
check_method_equivalence(original_method, changed_method, False, use_numeric_subs=True)
@pytest.mark.longrun
......@@ -89,8 +89,8 @@ def test_srt():
maxwellian_moments=True)
changed_method = __change_relaxation_rate_of_conserved_moments(original_method)
check_method_equivalence(original_method, changed_method, True)
check_method_equivalence(original_method, changed_method, False)
check_method_equivalence(original_method, changed_method, True, use_numeric_subs=True)
check_method_equivalence(original_method, changed_method, False, use_numeric_subs=True)
def test_srt_short():
......@@ -99,8 +99,8 @@ def test_srt_short():
maxwellian_moments=True)
changed_method = __change_relaxation_rate_of_conserved_moments(original_method)
check_method_equivalence(original_method, changed_method, True)
check_method_equivalence(original_method, changed_method, False)
check_method_equivalence(original_method, changed_method, True, use_numeric_subs=False)
check_method_equivalence(original_method, changed_method, False, use_numeric_subs=False)
@pytest.mark.parametrize('stencil_name', [Stencil.D2Q9, Stencil.D3Q19, Stencil.D3Q27])
......@@ -117,8 +117,8 @@ def test_trt(stencil_name, continuous_moments):
@pytest.mark.parametrize('method_name', [Method.TRT_KBC_N1, Method.TRT_KBC_N2, Method.TRT_KBC_N3, Method.TRT_KBC_N4])
@pytest.mark.parametrize('dim', [2, 3])
def test_trt_kbc_long(method_name, dim):
def test_trt_kbc(method_name):
dim = 2
method_nr = method_name.name[-1]
original_method = create_trt_kbc(dim, sp.Symbol("omega1"), sp.Symbol("omega2"),
method_name='KBC-N' + method_nr,
......@@ -127,3 +127,15 @@ def test_trt_kbc_long(method_name, dim):
check_method_equivalence(original_method, changed_method, True)
check_method_equivalence(original_method, changed_method, False)
@pytest.mark.parametrize('method_name', [Method.TRT_KBC_N1, Method.TRT_KBC_N2, Method.TRT_KBC_N3, Method.TRT_KBC_N4])
@pytest.mark.longrun
def test_trt_kbc_long(method_name):
dim = 3
method_nr = method_name.name[-1]
original_method = create_trt_kbc(dim, sp.Symbol("omega1"), sp.Symbol("omega2"),
method_name='KBC-N' + method_nr,
maxwellian_moments=False)
changed_method = __change_relaxation_rate_of_conserved_moments(original_method)
check_method_equivalence(original_method, changed_method, True)
check_method_equivalence(original_method, changed_method, False)
......@@ -75,8 +75,8 @@ def test_diffusion():
C(x,y) = 1 * erfc(y / sqrt(4Dx/u))
The hydrodynamic field is not simulated, instead a constant velocity is assumed.
"""
"""
pytest.importorskip("pycuda")
# Parameters
domain_size = (1600, 160)
omega = 1.38
......@@ -84,9 +84,10 @@ def test_diffusion():
velocity = 0.05
time_steps = 50000
stencil = LBStencil(Stencil.D2Q9)
target = ps.Target.GPU
# Data Handling
dh = ps.create_data_handling(domain_size=domain_size)
dh = ps.create_data_handling(domain_size=domain_size, default_target=target)
vel_field = dh.add_array('vel_field', values_per_cell=stencil.D)
dh.fill('vel_field', velocity, 0, ghost_layers=True)
......@@ -96,7 +97,9 @@ def test_diffusion():
dh.fill('con_field', 0.0, ghost_layers=True)
pdfs = dh.add_array('pdfs', values_per_cell=stencil.Q)
dh.fill('pdfs', 0.0, ghost_layers=True)
pdfs_tmp = dh.add_array('pdfs_tmp', values_per_cell=stencil.Q)
dh.fill('pdfs_tmp', 0.0, ghost_layers=True)
# Lattice Boltzmann method
lbm_config = LBMConfig(stencil=stencil, method=Method.MRT, relaxation_rates=[1, 1.5, 1, 1.5, 1],
......@@ -104,21 +107,24 @@ def test_diffusion():
weighted=True, kernel_type='stream_pull_collide')
lbm_opt = LBMOptimisation(symbolic_field=pdfs, symbolic_temporary_field=pdfs_tmp)
config = ps.CreateKernelConfig(target=dh.default_target, cpu_openmp=True)
method = create_lb_method(lbm_config=lbm_config)
method.set_conserved_moments_relaxation_rate(omega)
lbm_config = replace(lbm_config, lb_method=method)
update_rule = create_lb_update_rule(lbm_config=lbm_config, lbm_optimisation=lbm_opt)
kernel = ps.create_kernel(update_rule).compile()
kernel = ps.create_kernel(update_rule, config=config).compile()
# PDF initalization
init = pdf_initialization_assignments(method, con_field.center,
vel_field.center_vector, pdfs.center_vector)
dh.run_kernel(ps.create_kernel(init).compile())
dh.all_to_gpu()
# Boundary Handling
bh = LatticeBoltzmannBoundaryHandling(update_rule.method, dh, 'pdfs', name="bh")
bh = LatticeBoltzmannBoundaryHandling(update_rule.method, dh, 'pdfs', name="bh", target=dh.default_target)
add_box_boundary(bh, boundary=NeumannByCopy())
bh.set_boundary(DiffusionDirichlet(0), slice_from_direction('W', dh.dim))
bh.set_boundary(DiffusionDirichlet(1), slice_from_direction('S', dh.dim))
......@@ -129,6 +135,7 @@ def test_diffusion():
dh.run_kernel(kernel)
dh.swap("pdfs", "pdfs_tmp")
dh.all_to_cpu()
# Verification
x = np.arange(1, domain_size[0], 1)
y = np.arange(0, domain_size[1], 1)
......
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