Exemplo n.º 1
0
def test_build_matrix_of_rankine_and_reflected_rankine():
    gf = Delhommeau()
    sphere = Sphere(radius=1.0, ntheta=2, nphi=3, clip_free_surface=True)

    S, V = gf.evaluate(sphere.mesh, sphere.mesh, 0.0, -np.infty, 0.0)
    S_ref = np.array([[
        -0.15413386, -0.21852682, -0.06509213, -0.16718431, -0.06509213,
        -0.16718431
    ],
                      [
                          -0.05898834, -0.39245688, -0.04606661, -0.18264734,
                          -0.04606661, -0.18264734
                      ],
                      [
                          -0.06509213, -0.16718431, -0.15413386, -0.21852682,
                          -0.06509213, -0.16718431
                      ],
                      [
                          -0.04606661, -0.18264734, -0.05898834, -0.39245688,
                          -0.04606661, -0.18264734
                      ],
                      [
                          -0.06509213, -0.16718431, -0.06509213, -0.16718431,
                          -0.15413386, -0.21852682
                      ],
                      [
                          -0.04606661, -0.18264734, -0.04606661, -0.18264734,
                          -0.05898834, -0.39245688
                      ]])
    assert np.allclose(S, S_ref)

    S, V = gf.evaluate(sphere.mesh, sphere.mesh, 0.0, -np.infty, np.infty)
    S_ref = np.array([[
        -0.12666269, -0.07804937, -0.03845837, -0.03993999, -0.03845837,
        -0.03993999
    ],
                      [
                          -0.02106031, -0.16464793, -0.01169102, -0.02315146,
                          -0.01169102, -0.02315146
                      ],
                      [
                          -0.03845837, -0.03993999, -0.12666269, -0.07804937,
                          -0.03845837, -0.03993999
                      ],
                      [
                          -0.01169102, -0.02315146, -0.02106031, -0.16464793,
                          -0.01169102, -0.02315146
                      ],
                      [
                          -0.03845837, -0.03993999, -0.03845837, -0.03993999,
                          -0.12666269, -0.07804937
                      ],
                      [
                          -0.01169102, -0.02315146, -0.01169102, -0.02315146,
                          -0.02106031, -0.16464793
                      ]])
    assert np.allclose(S, S_ref)
Exemplo n.º 2
0
    def __init__(self,
                 *,
                 green_function=Delhommeau(),
                 engine=BasicMatrixEngine()):
        self.green_function = green_function
        self.engine = engine

        try:
            self.exportable_settings = {
                **self.green_function.exportable_settings,
                **self.engine.exportable_settings
            }
        except AttributeError:
            pass
Exemplo n.º 3
0
    def __init__(self, **params):
        green_function = Delhommeau(
            **{
                key: params[key]
                for key in params if key in _arguments(Delhommeau.__init__)
            })
        if 'hierarchical_matrices' in params and params[
                'hierarchical_matrices']:
            engine = HierarchicalToeplitzMatrixEngine(
                **{
                    key: params[key]
                    for key in params if key in _arguments(
                        HierarchicalToeplitzMatrixEngine.__init__)
                })
        else:
            engine = BasicMatrixEngine(
                **{
                    key: params[key]
                    for key in params
                    if key in _arguments(BasicMatrixEngine.__init__)
                })

        super().__init__(green_function=green_function, engine=engine)
Exemplo n.º 4
0
def test_cache_matrices():
    """Test how the BasicMatrixEngine caches the interaction matrices."""
    gf = Delhommeau()
    params_1 = (sphere.mesh, sphere.mesh, 0.0, -np.infty, 1.0, gf)
    params_2 = (sphere.mesh, sphere.mesh, 0.0, -np.infty, 2.0, gf)

    # No cache
    engine = BasicMatrixEngine(matrix_cache_size=0)
    S, K = engine.build_matrices(*params_1)
    S_again, K_again = engine.build_matrices(*params_1)
    assert S is not S_again
    assert K is not K_again

    # Cache
    engine = BasicMatrixEngine(matrix_cache_size=1)
    S, K = engine.build_matrices(*params_1)
    S_again, K_again = engine.build_matrices(*params_1)
    _, _ = engine.build_matrices(*params_2)
    S_once_more, K_once_more = engine.build_matrices(*params_2)
    assert S is S_again
    assert S is not S_once_more
    assert K is K_again
    assert K is not K_once_more
Exemplo n.º 5
0
def test_exportable_settings():
    gf = Delhommeau(tabulation_nb_integration_points=50)
    assert gf.exportable_settings['green_function'] == 'Delhommeau'
    assert gf.exportable_settings['tabulation_nb_integration_points'] == 50
    assert gf.exportable_settings[
        'finite_depth_prony_decomposition_method'] == 'fortran'

    gf2 = XieDelhommeau()
    assert gf2.exportable_settings['green_function'] == 'XieDelhommeau'

    engine = BasicMatrixEngine(matrix_cache_size=0)
    assert engine.exportable_settings['engine'] == 'BasicMatrixEngine'
    assert engine.exportable_settings['matrix_cache_size'] == 0
    assert engine.exportable_settings['linear_solver'] == 'gmres'

    solver = BEMSolver(green_function=gf, engine=engine)
    assert solver.exportable_settings['green_function'] == 'Delhommeau'
    assert solver.exportable_settings['tabulation_nb_integration_points'] == 50
    assert solver.exportable_settings[
        'finite_depth_prony_decomposition_method'] == 'fortran'
    assert solver.exportable_settings['engine'] == 'BasicMatrixEngine'
    assert solver.exportable_settings['matrix_cache_size'] == 0
    assert solver.exportable_settings['linear_solver'] == 'gmres'