Ejemplo n.º 1
0
def single_layer(
    space, points, wavenumber, parameters=None, device_interface=None, precision=None
):
    """Return a Helmholtz single-layer potential operator."""
    from bempp.core.dense_potential_assembler import DensePotentialAssembler
    from bempp.api.operators import OperatorDescriptor
    from bempp.api.operators import _add_wavenumber
    from bempp.api.assembly.potential_operator import PotentialOperator

    options = {"KERNEL_FUNCTION": "helmholtz_single_layer"}
    _add_wavenumber(options, wavenumber)

    return PotentialOperator(
        DensePotentialAssembler(
            space,
            OperatorDescriptor(
                "helmholtz_single_layer_potential", options, "default_dense"
            ),
            points,
            1,
            True,
            device_interface,
            precision,
            parameters=parameters,
        )
    )
Ejemplo n.º 2
0
def electric_field(space, evaluation_points, wave_number, parameters=None):
    """Return the Maxwell electric field potential operator

    Parameters
    ----------
    space : bempp.api.space.Space
        The function space over which to assemble the potential.
    evaluation_points : numpy.ndarray
        A (3 x N) array of N evaluation points, where each column corresponds to
        the coordinates of one evaluation point.
    wave_number : complex
        Wavenumber of the operator.
    parameters : bempp.api.common.ParameterList
        Parameters for the operator. If none given
        the default global parameter object
        `bempp.api.global_parameters` is used.

    """
    import bempp
    from bempp.api.assembly.potential_operator import PotentialOperator
    from bempp.api.assembly.discrete_boundary_operator import \
        GeneralNonlocalDiscreteBoundaryOperator
    from bempp.core.operators.potential.maxwell import electric_field_ext

    if space.has_non_barycentric_space:
        space = space.non_barycentric_space

    if parameters is None:
        parameters = bempp.api.global_parameters

    return PotentialOperator(
        GeneralNonlocalDiscreteBoundaryOperator(
            electric_field_ext(space._impl, evaluation_points, wave_number,
                               parameters)), 3, space, evaluation_points)
Ejemplo n.º 3
0
def electric_field(
    space,
    points,
    wavenumber,
    parameters=None,
    assembler="dense",
    device_interface=None,
    precision=None,
):
    """Return a Maxwell electric far-field potential operator."""
    import bempp.api
    from bempp.api.operators import OperatorDescriptor
    from bempp.api.assembly.potential_operator import PotentialOperator
    from bempp.api.assembly.assembler import PotentialAssembler

    if precision is None:
        precision = bempp.api.DEFAULT_PRECISION

    operator_descriptor = OperatorDescriptor(
        "maxwell_far_field_electric_field_potential",  # Identifier
        [_np.real(wavenumber), _np.imag(wavenumber)],  # Options
        "helmholtz_far_field_single_layer",  # Kernel type
        "maxwell_electric_far_field",  # Assembly type
        precision,  # Precision
        True,  # Is complex
        None,  # Singular part
        3,  # Kernel dimension
    )

    return PotentialOperator(
        PotentialAssembler(space, points, operator_descriptor,
                           device_interface, assembler, parameters))
Ejemplo n.º 4
0
def single_layer_gradient(space, evaluation_points, parameters=None):
    """Return the Laplace single-layer gradient potential operator

    Parameters
    ----------
    space : bempp.api.space.Space
        The function space over which to assemble the potential.
    evaluation_points : numpy.ndarray
        A (3 x N) array of N evaluation points, where each column corresponds to
        the coordinates of one evaluation point.
    parameters : bempp.api.common.ParameterList
        Parameters for the operator. If none given
        the default global parameter object
        `bempp.api.global_parameters` is used.

    """

    import bempp
    from bempp.api.assembly.potential_operator import PotentialOperator
    from bempp.api.assembly.discrete_boundary_operator import \
        GeneralNonlocalDiscreteBoundaryOperator
    #pylint: disable=no-name-in-module
    from bempp.core.operators.potential.laplace import single_layer_gradient_ext

    if space.has_non_barycentric_space:
        space = space.non_barycentric_space

    if parameters is None:
        parameters = bempp.api.global_parameters

    return PotentialOperator(
        GeneralNonlocalDiscreteBoundaryOperator(
            single_layer_gradient_ext(space._impl, evaluation_points,
                                      parameters)), 3, space,
        evaluation_points)
Ejemplo n.º 5
0
def double_layer(
    space,
    points,
    parameters=None,
    assembler="dense",
    device_interface=None,
    precision=None,
):
    """Return a Laplace single-layer potential operator."""
    import bempp.api
    from bempp.api.operators import OperatorDescriptor
    from bempp.api.assembly.potential_operator import PotentialOperator
    from bempp.api.assembly.assembler import PotentialAssembler

    if precision is None:
        precision = bempp.api.DEFAULT_PRECISION

    operator_descriptor = OperatorDescriptor(
        "laplace_double_layer_potential",  # Identifier
        [],  # Options
        "laplace_double_layer",  # Kernel type
        "default_scalar",  # Assembly type
        precision,  # Precision
        False,  # Is complex
        None,  # Singular part
        1,  # Kernel dimension
    )

    return PotentialOperator(
        PotentialAssembler(space, points, operator_descriptor,
                           device_interface, assembler, parameters))
Ejemplo n.º 6
0
def magnetic_field(space,
                   points,
                   wavenumber,
                   parameters=None,
                   device_interface=None,
                   precision=None):
    """Return a Maxwell magnetic far-field potential operator."""
    from bempp.core.dense_potential_assembler import DensePotentialAssembler
    from bempp.api.operators import OperatorDescriptor
    from bempp.api.operators import _add_wavenumber
    from bempp.api.assembly.potential_operator import PotentialOperator

    options = {}
    _add_wavenumber(options, wavenumber)

    return PotentialOperator(
        DensePotentialAssembler(
            space,
            OperatorDescriptor("maxwell_magnetic_far_field", options,
                               "maxwell_magnetic_far_field"),
            points,
            3,
            True,
            device_interface,
            precision,
            parameters=parameters,
        ))
Ejemplo n.º 7
0
def single_layer(space, evaluation_points, wave_number, parameters=None):
    """Return the Helmholtz single-layer far field operator.

    Parameters
    ----------
    space : bempp.api.space.Space
        The function space over which to assemble the potential.
    evaluation_points : numpy.ndarray
        A (3 x N) array of N evaluation points, where each column corresponds to
        the coordinates of one evaluation point. For the far field the points
        should lie on the unit sphere.
    parameters : bempp.api.common.ParameterList
        Parameters for the operator. If none given
        the default global parameter object
        `bempp.api.global_parameters` is used.

    """

    import bempp
    from bempp.api.assembly.potential_operator import PotentialOperator
    from bempp.api.assembly.discrete_boundary_operator import \
        GeneralNonlocalDiscreteBoundaryOperator
    from bempp.core.operators.far_field.helmholtz import single_layer_ext

    if space.has_non_barycentric_space:
        space = space.non_barycentric_space

    if parameters is None:
        parameters = bempp.api.global_parameters

    return PotentialOperator(
        GeneralNonlocalDiscreteBoundaryOperator(
            single_layer_ext(space._impl, evaluation_points, wave_number,
                             parameters)), 1, space, evaluation_points)
Ejemplo n.º 8
0
def double_layer(
    space,
    points,
    wavenumber,
    parameters=None,
    assembler="dense",
    device_interface=None,
    precision=None,
):
    """Return a Helmholtz double-layer potential operator."""
    import bempp.api
    from bempp.api.operators import OperatorDescriptor
    from bempp.api.assembly.potential_operator import PotentialOperator
    from bempp.api.assembly.assembler import PotentialAssembler
    from .modified_helmholtz import double_layer as modified_double_layer

    if _np.real(wavenumber) == 0:
        return modified_double_layer(
            space,
            points,
            wavenumber,
            parameters,
            assembler,
            device_interface,
            precision,
        )

    if precision is None:
        precision = bempp.api.DEFAULT_PRECISION

    operator_descriptor = OperatorDescriptor(
        "helmholtz_double_layer_potential",  # Identifier
        [_np.real(wavenumber), _np.imag(wavenumber)],  # Options
        "helmholtz_double_layer",  # Kernel type
        "default_scalar",  # Assembly type
        precision,  # Precision
        True,  # Is complex
        None,  # Singular part
        1,  # Kernel dimension
    )

    return PotentialOperator(
        PotentialAssembler(space, points, operator_descriptor,
                           device_interface, assembler, parameters))
Ejemplo n.º 9
0
def double_layer(
    space,
    points,
    omega,
    parameters=None,
    assembler="dense",
    device_interface=None,
    precision=None,
):
    """Return a modified Helmholtz double-layer potential operator."""
    import bempp.api
    from bempp.api.operators import OperatorDescriptor
    from bempp.api.assembly.potential_operator import PotentialOperator
    from bempp.api.assembly.assembler import PotentialAssembler

    if _np.imag(omega) != 0:
        raise ValueError("'omega' must be real.")

    if precision is None:
        precision = bempp.api.DEFAULT_PRECISION

    operator_descriptor = OperatorDescriptor(
        "modified_helmholtz_double_layer_potential",  # Identifier
        [omega],  # Options
        "modified_helmholtz_double_layer",  # Kernel type
        "default_scalar",  # Assembly type
        precision,  # Precision
        False,  # Is complex
        None,  # Singular part
        1,  # Kernel dimension
    )

    return PotentialOperator(
        PotentialAssembler(
            space, points, operator_descriptor, device_interface, assembler, parameters
        )
    )
Ejemplo n.º 10
0
def magnetic_field(
    space,
    points,
    wavenumber,
    parameters=None,
    assembler="dense",
    device_interface=None,
    precision=None,
):
    """Return a Maxwell magnetic field potential operator."""
    from bempp.api.operators import OperatorDescriptor
    from bempp.api.assembly.potential_operator import PotentialOperator
    from bempp.api.assembly.assembler import PotentialAssembler
    import bempp.api

    if space.identifier != "rwg0":
        raise ValueError("Space must be an RWG type function space.")

    if precision is None:
        precision = bempp.api.DEFAULT_PRECISION

    operator_descriptor = OperatorDescriptor(
        "maxwell_magnetic_field_potential",  # Identifier
        [_np.real(wavenumber), _np.imag(wavenumber)],  # Options
        "helmholtz_single_layer",  # Kernel type
        "maxwell_magnetic_field",  # Assembly type
        precision,  # Precision
        True,  # Is complex
        None,  # Singular part
        3,  # Kernel dimension
    )

    return PotentialOperator(
        PotentialAssembler(
            space, points, operator_descriptor, device_interface, assembler, parameters
        )
    )