Skip to content
Snippets Groups Projects
Select Git revision
  • a4fb0c009d98d0e7779cc80853fb40951ddcece1
  • master default protected
  • v2.0-dev protected
  • zikeliml/Task-96-dotExporterForAST
  • zikeliml/124-rework-tutorials
  • fma
  • fhennig/v2.0-deprecations
  • holzer-master-patch-46757
  • 66-absolute-access-is-probably-not-copied-correctly-after-_eval_subs
  • gpu_bufferfield_fix
  • hyteg
  • vectorization_sqrt_fix
  • target_dh_refactoring
  • const_fix
  • improved_comm
  • gpu_liveness_opts
  • release/1.3.7 protected
  • release/1.3.6 protected
  • release/2.0.dev0 protected
  • release/1.3.5 protected
  • release/1.3.4 protected
  • release/1.3.3 protected
  • release/1.3.2 protected
  • release/1.3.1 protected
  • release/1.3 protected
  • release/1.2 protected
  • release/1.1.1 protected
  • release/1.1 protected
  • release/1.0.1 protected
  • release/1.0 protected
  • release/0.4.4 protected
  • last/Kerncraft
  • last/OpenCL
  • last/LLVM
  • release/0.4.3 protected
  • release/0.4.2 protected
36 results

test_math_functions.py

Blame
  • test_weights.py 1.55 KiB
    import pytest
    from lbmpy.creationfunctions import create_lb_method, LBMConfig
    from lbmpy.enums import Method, Stencil
    from lbmpy.maxwellian_equilibrium import get_weights
    from lbmpy.stencils import LBStencil
    
    
    def compare_weights(method, zero_centered, continuous_equilibrium, stencil_name):
        stencil = LBStencil(stencil_name)
        hardcoded_weights = get_weights(stencil)
    
        method = create_lb_method(LBMConfig(stencil=stencil, method=method, zero_centered=zero_centered, 
                                            continuous_equilibrium=continuous_equilibrium))
        weights = method.weights
    
        for i in range(len(weights)):
            assert hardcoded_weights[i] == weights[i]
    
    
    @pytest.mark.parametrize('method', [Method.SRT, Method.TRT])
    @pytest.mark.parametrize('zero_centered', [False, True])
    @pytest.mark.parametrize('continuous_equilibrium', [False, True])
    @pytest.mark.parametrize('stencil_name', [Stencil.D2Q9, Stencil.D3Q7])
    def test_weight_calculation(method, zero_centered, continuous_equilibrium, stencil_name):
        compare_weights(method, zero_centered, continuous_equilibrium, stencil_name)
    
    
    @pytest.mark.parametrize('method', [Method.MRT, Method.CENTRAL_MOMENT])
    @pytest.mark.parametrize('continuous_equilibrium', [False, True])
    @pytest.mark.parametrize('zero_centered', [False, True])
    @pytest.mark.parametrize('stencil_name', [Stencil.D3Q15, Stencil.D3Q19, Stencil.D3Q27])
    @pytest.mark.longrun
    def test_weight_calculation_longrun(method, zero_centered, continuous_equilibrium, stencil_name):
        compare_weights(method, zero_centered, continuous_equilibrium, stencil_name)