Skip to content

Commit

Permalink
rename to bempp_cl
Browse files Browse the repository at this point in the history
  • Loading branch information
mscroggs committed Nov 8, 2024
1 parent d1e4a89 commit ffce7f0
Show file tree
Hide file tree
Showing 132 changed files with 794 additions and 794 deletions.
File renamed without changes.
68 changes: 34 additions & 34 deletions bempp/api/__init__.py → bempp_cl/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

# def compile_with_log(*args, **kwargs):
# """Numba compilation with log messages."""
# import bempp.api
# import bempp_cl.api

# fun_name = args[0].py_func.__name__
# bempp.api.log(f"Compiling {fun_name} for signature {args[1]}.", level="debug")
# bempp_cl.api.log(f"Compiling {fun_name} for signature {args[1]}.", level="debug")
# res = oldcompile(*args, **kwargs)
# bempp.api.log(f"Compilation finished.", level="debug")
# bempp_cl.api.log(f"Compilation finished.", level="debug")
# return res


Expand All @@ -26,35 +26,35 @@
import time as _time
import platform as _platform

from bempp.api.utils import DefaultParameters
from bempp.api.utils.helpers import MemProfiler
from bempp_cl.api.utils import DefaultParameters
from bempp_cl.api.utils.helpers import MemProfiler

from bempp.api.utils.helpers import assign_parameters
from bempp.api.grid.io import import_grid
from bempp.api.grid.io import export
from bempp.api.grid.grid import Grid
from bempp.api.assembly.grid_function import GridFunction
from bempp.api.assembly.grid_function import real_callable
from bempp.api.assembly.grid_function import complex_callable
from bempp.api.assembly.grid_function import callable
from bempp_cl.api.utils.helpers import assign_parameters
from bempp_cl.api.grid.io import import_grid
from bempp_cl.api.grid.io import export
from bempp_cl.api.grid.grid import Grid
from bempp_cl.api.assembly.grid_function import GridFunction
from bempp_cl.api.assembly.grid_function import real_callable
from bempp_cl.api.assembly.grid_function import complex_callable
from bempp_cl.api.assembly.grid_function import callable

from bempp.api.space import function_space
from bempp_cl.api.space import function_space

from bempp.api import shapes
from bempp.api import integration
from bempp.api import operators
from bempp.api.linalg.direct_solvers import lu, compute_lu_factors
from bempp.api.linalg.iterative_solvers import gmres, cg
from bempp.api.assembly.discrete_boundary_operator import as_matrix
from bempp.api.assembly.boundary_operator import ZeroBoundaryOperator
from bempp.api.assembly.boundary_operator import MultiplicationOperator
from bempp.api.assembly.blocked_operator import BlockedOperator
from bempp.api.assembly.blocked_operator import GeneralizedBlockedOperator
from bempp_cl.api import shapes
from bempp_cl.api import integration
from bempp_cl.api import operators
from bempp_cl.api.linalg.direct_solvers import lu, compute_lu_factors
from bempp_cl.api.linalg.iterative_solvers import gmres, cg
from bempp_cl.api.assembly.discrete_boundary_operator import as_matrix
from bempp_cl.api.assembly.boundary_operator import ZeroBoundaryOperator
from bempp_cl.api.assembly.boundary_operator import MultiplicationOperator
from bempp_cl.api.assembly.blocked_operator import BlockedOperator
from bempp_cl.api.assembly.blocked_operator import GeneralizedBlockedOperator

from bempp.api.fmm.fmm_assembler import clear_fmm_cache
from bempp_cl.api.fmm.fmm_assembler import clear_fmm_cache

from bempp.api.utils import pool
from bempp.api.utils.pool import create_device_pool
from bempp_cl.api.utils import pool
from bempp_cl.api.utils.pool import create_device_pool

from numba.core.errors import (
NumbaDeprecationWarning,
Expand All @@ -72,10 +72,10 @@
# Try importing OpenCL routines

try:
from bempp.core.opencl_kernels import set_default_cpu_device
from bempp.core.opencl_kernels import set_default_cpu_device_by_name
from bempp.core.opencl_kernels import set_default_gpu_device_by_name
from bempp.core.opencl_kernels import set_default_gpu_device
from bempp_cl.core.opencl_kernels import set_default_cpu_device
from bempp_cl.core.opencl_kernels import set_default_cpu_device_by_name
from bempp_cl.core.opencl_kernels import set_default_gpu_device_by_name
from bempp_cl.core.opencl_kernels import set_default_gpu_device
except ImportError:
pass

Expand Down Expand Up @@ -213,7 +213,7 @@ def __exit__(self, *args):

def _gmsh_path():
"""Find Gmsh."""
from bempp.api.utils import which
from bempp_cl.api.utils import which

if _os.name == "nt":
gmp = which("gmsh.exe")
Expand Down Expand Up @@ -271,14 +271,14 @@ def _get_version():
DEFAULT_DEVICE_INTERFACE = "numba"
else:
try:
from bempp.core.opencl_kernels import find_cpu_driver
from bempp_cl.core.opencl_kernels import find_cpu_driver

CPU_OPENCL_DRIVER_FOUND = find_cpu_driver()
except: # noqa: E722
pass

try:
from bempp.core.opencl_kernels import find_gpu_driver
from bempp_cl.core.opencl_kernels import find_gpu_driver

GPU_OPENCL_DRIVER_FOUND = find_gpu_driver()
except: # noqa: E722
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ def _create_assembler(
domain, dual_to_range, identifier, parameters, device_interface=None
):
"""Create assembler based on string."""
from bempp.core.singular_assembler import SingularAssembler
from bempp.core.dense_assembler import DenseAssembler
from bempp.core.diagonal_assembler import DiagonalAssembler
from bempp.api.fmm.fmm_assembler import FmmAssembler
from bempp.api import check_for_fmm
from bempp_cl.core.singular_assembler import SingularAssembler
from bempp_cl.core.dense_assembler import DenseAssembler
from bempp_cl.core.diagonal_assembler import DiagonalAssembler
from bempp_cl.api.fmm.fmm_assembler import FmmAssembler
from bempp_cl.api import check_for_fmm

# from bempp.core.numba.dense_assembler import DenseAssembler
from bempp.core.sparse_assembler import SparseAssembler
# from bempp_cl.core.numba.dense_assembler import DenseAssembler
from bempp_cl.core.sparse_assembler import SparseAssembler

# from bempp.core.dense_assembler import DenseAssembler
# from bempp.core.sparse_assembler import SparseAssembler
# from bempp.core.dense_evaluator import DenseEvaluatorAssembler
# from bempp.core.dense_multitrace_evaluator import DenseMultitraceEvaluatorAssembler
# from bempp_cl.core.dense_assembler import DenseAssembler
# from bempp_cl.core.sparse_assembler import SparseAssembler
# from bempp_cl.core.dense_evaluator import DenseEvaluatorAssembler
# from bempp_cl.core.dense_multitrace_evaluator import DenseMultitraceEvaluatorAssembler

if identifier == "only_singular_part":
return SingularAssembler(domain, dual_to_range, parameters)
Expand Down Expand Up @@ -56,8 +56,8 @@ def __init__(
parameters=None,
):
"""Initialize assembler based on assembler_type string."""
import bempp.api
import bempp.api as _api
import bempp_cl.api
import bempp_cl.api as _api

self._domain = domain
self._dual_to_range = dual_to_range
Expand All @@ -66,7 +66,7 @@ def __init__(
self._precision = precision

if self._device_interface is None:
self._device_interface = bempp.api.DEFAULT_DEVICE_INTERFACE
self._device_interface = bempp_cl.api.DEFAULT_DEVICE_INTERFACE

if not isinstance(assembler, str):
self._implementation = assembler
Expand Down Expand Up @@ -106,7 +106,7 @@ class AssemblerBase(object):

def __init__(self, domain, dual_to_range, parameters=None):
"""Instantiate the base class."""
import bempp.api as api
import bempp_cl.api as api

self._domain = domain
self._dual_to_range = dual_to_range
Expand Down Expand Up @@ -173,22 +173,22 @@ def select_potential_implementation(
space, points, operator_descriptor, device_interface, assembler, parameters
):
"""Select a potential operator implementation."""
import bempp.api
import bempp_cl.api

parameters = bempp.api.assign_parameters(parameters)
parameters = bempp_cl.api.assign_parameters(parameters)
if device_interface is None:
device_interface = bempp.api.DEFAULT_DEVICE_INTERFACE
device_interface = bempp_cl.api.DEFAULT_DEVICE_INTERFACE

if assembler == "dense":
from bempp.core.dense_potential_assembler import DensePotentialAssembler
from bempp_cl.core.dense_potential_assembler import DensePotentialAssembler

return DensePotentialAssembler(
space, operator_descriptor, points, device_interface, parameters
)
elif assembler == "fmm":
from bempp.api.fmm.fmm_assembler import FmmPotentialAssembler
from bempp_cl.api.fmm.fmm_assembler import FmmPotentialAssembler

if not bempp.api.check_for_fmm():
if not bempp_cl.api.check_for_fmm():
raise ValueError(
"No compatible FMM library found. Please install Exafmm from github.com/exafmm/exafmm-t."
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Definition of blocked operator structures."""

import numpy as _np
from bempp.api.assembly.discrete_boundary_operator import _DiscreteOperatorBase
from bempp_cl.api.assembly.discrete_boundary_operator import _DiscreteOperatorBase


def _sum(op1, op2):
Expand Down Expand Up @@ -46,7 +46,7 @@ def strong_form(self):
Usually the strong form is cached. If this parameter is set to
`true` the strong form is recomputed.
"""
from bempp.api.utils.helpers import get_inverse_mass_matrix
from bempp_cl.api.utils.helpers import get_inverse_mass_matrix

if self._range_map is None:

Expand Down Expand Up @@ -110,7 +110,7 @@ def __mul__(self, other):
return ProductBlockedOperator(self, other)
elif isinstance(other, Iterable):
# Multiplication with a list of grid functions.
from bempp.api.assembly.grid_function import GridFunction
from bempp_cl.api.assembly.grid_function import GridFunction

list_input = list(other)
if len(list_input) != self.ndims[1]:
Expand Down Expand Up @@ -168,10 +168,10 @@ def __init__(self, m, n):

def __getitem__(self, key):
"""Return a component operator with a key of the form (i, j)."""
import bempp.api
import bempp_cl.api

if self._operators[key] is None:
return bempp.api.ZeroBoundaryOperator(
return bempp_cl.api.ZeroBoundaryOperator(
self.domain_spaces[key[1]],
self.range_spaces[key[0]],
self.dual_to_range_spaces[key[0]],
Expand Down Expand Up @@ -269,7 +269,7 @@ def __init__(self, array):
accepted.
"""
from bempp.api.assembly.boundary_operator import BoundaryOperator
from bempp_cl.api.assembly.boundary_operator import BoundaryOperator
from collections.abc import Iterable

def make_blocked(operator):
Expand Down Expand Up @@ -502,7 +502,7 @@ class GeneralizedDiscreteBlockedOperator(_DiscreteOperatorBase):

def __init__(self, operators):
"""Initialize a generalized blocked operator."""
from bempp.api.utils.data_types import combined_type
from bempp_cl.api.utils.data_types import combined_type

self._operators = operators

Expand Down Expand Up @@ -546,7 +546,7 @@ def to_dense(self):

def _matmat(self, other):
"""Implement the matrix/vector product."""
from bempp.api.utils.data_types import combined_type
from bempp_cl.api.utils.data_types import combined_type

row_count = 0
output = _np.zeros(
Expand Down Expand Up @@ -579,8 +579,8 @@ def __init__(self, ops):
"""
# pylint: disable=too-many-branches
from bempp.api.utils.data_types import combined_type
from bempp.api.assembly.discrete_boundary_operator import (
from bempp_cl.api.utils.data_types import combined_type
from bempp_cl.api.assembly.discrete_boundary_operator import (
ZeroDiscreteBoundaryOperator,
)

Expand Down Expand Up @@ -648,7 +648,7 @@ def _fill_complete(self):
return True

def _matvec(self, x):
from bempp.api.utils.data_types import combined_type
from bempp_cl.api.utils.data_types import combined_type

if not self._fill_complete():
raise ValueError("Not all rows or columns contain operators.")
Expand Down Expand Up @@ -677,7 +677,7 @@ def _matvec(self, x):
return res

def _matmat(self, x):
from bempp.api.utils.data_types import combined_type
from bempp_cl.api.utils.data_types import combined_type

if not self._fill_complete():
raise ValueError("Not all rows or columns contain operators.")
Expand Down Expand Up @@ -804,7 +804,7 @@ def grid_function_list_from_coefficients(coefficients, spaces):
The sum of the global dofs of the spaces must be equal to the
length of the coefficients vector.
"""
from bempp.api import GridFunction
from bempp_cl.api import GridFunction

pos = 0
res_list = []
Expand Down Expand Up @@ -832,7 +832,7 @@ def grid_function_list_from_projections(projections, spaces, dual_spaces=None):
dual_spaces : list of Space objects
The associated dual spaces. If None use the spaces as dual spaces.
"""
from bempp.api import GridFunction
from bempp_cl.api import GridFunction

pos = 0
res_list = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def weak_form(self):

def strong_form(self):
"""Return a discrete operator that maps into the range space."""
from bempp.api.utils.helpers import get_inverse_mass_matrix
from bempp_cl.api.utils.helpers import get_inverse_mass_matrix

if self._range_map is None:

Expand All @@ -55,7 +55,7 @@ def strong_form(self):
def __mul__(self, other):
"""Return product with a scalar, grid function or other operator."""
import numpy as np
from bempp.api import GridFunction
from bempp_cl.api import GridFunction

if np.isscalar(other):
return _ScaledBoundaryOperator(self, other)
Expand Down Expand Up @@ -203,25 +203,25 @@ class ZeroBoundaryOperator(BoundaryOperator):
Parameters
----------
domain : bempp.api.space.Space
domain : bempp_cl.api.space.Space
Domain space of the operator.
range_ : bempp.api.space.Space
range_ : bempp_cl.api.space.Space
Range space of the operator.
dual_to_range : bempp.api.space.Space
dual_to_range : bempp_cl.api.space.Space
Dual space to the range space.
"""

def __init__(self, domain, range_, dual_to_range):
import bempp.api
import bempp_cl.api

super(ZeroBoundaryOperator, self).__init__(
domain, range_, dual_to_range, bempp.api.GLOBAL_PARAMETERS
domain, range_, dual_to_range, bempp_cl.api.GLOBAL_PARAMETERS
)

def _assemble(self):

from bempp.api.assembly.discrete_boundary_operator import (
from bempp_cl.api.assembly.discrete_boundary_operator import (
ZeroDiscreteBoundaryOperator,
)

Expand Down Expand Up @@ -307,7 +307,7 @@ def __init__(
quadrature points.
"""
from bempp.api.utils.helpers import assign_parameters
from bempp_cl.api.utils.helpers import assign_parameters

self._mode = mode
self._grid_fun = grid_function
Expand All @@ -330,11 +330,11 @@ def __init__(

def _assemble(self):
"""Assemble the operator."""
from bempp.api.space.space import return_compatible_representation
from bempp.api.assembly.discrete_boundary_operator import (
from bempp_cl.api.space.space import return_compatible_representation
from bempp_cl.api.assembly.discrete_boundary_operator import (
SparseDiscreteBoundaryOperator,
)
from bempp.api.integration.triangle_gauss import rule
from bempp_cl.api.integration.triangle_gauss import rule
from scipy.sparse import coo_matrix

import numpy as _np
Expand Down
Loading

0 comments on commit ffce7f0

Please sign in to comment.