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, ) )
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))
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))
def create_operator( identifier, domain, range_, dual_to_range, parameters, assembler, operator_options, compute_kernel, device_interface, precision, ): """Generic instantiation of operators.""" from bempp.api.operators import OperatorDescriptor from bempp.api import default_device from bempp.api import get_precision if device_interface is None: device_interface = default_device() if precision is None: precision = get_precision(device_interface) assembler = _assembler.AssemblerInterface(domain, dual_to_range, assembler, device_interface, precision, parameters) descriptor = OperatorDescriptor(identifier, operator_options, compute_kernel) return _boundary_operator.BoundaryOperatorWithAssembler( domain, range_, dual_to_range, assembler, descriptor)
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, ))
def create_operator( identifier, domain, range_, dual_to_range, parameters, assembler, operator_options, kernel_type, assembly_type, device_interface, precision, is_complex, ): """Generic instantiation of operators.""" from bempp.api.operators import OperatorDescriptor import bempp.api if precision is None: precision = bempp.api.DEFAULT_PRECISION if assembler != "only_singular_part": # Add operator for singular part assembly. Needed for certain fast methods. singular_part = create_operator( identifier, domain, range_, dual_to_range, parameters, "only_singular_part", operator_options, kernel_type, assembly_type, device_interface, precision, is_complex, ) else: singular_part = None assembler = _assembler.AssemblerInterface( domain, dual_to_range, assembler, device_interface, precision, parameters ) kernel_dimension = 1 descriptor = OperatorDescriptor( identifier, operator_options, kernel_type, assembly_type, precision, is_complex, singular_part, kernel_dimension, ) return _boundary_operator.BoundaryOperatorWithAssembler( domain, range_, dual_to_range, assembler, descriptor )
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))
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 ) )
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 ) )