Skip to content

Commit

Permalink
Merge pull request #60 from bempp/small_release_patches
Browse files Browse the repository at this point in the history
Small release patches
  • Loading branch information
tbetcke authored Sep 14, 2020
2 parents 0a5be04 + 90ce125 commit 1b52176
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 378 deletions.
13 changes: 13 additions & 0 deletions bempp/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,19 @@ def _gmsh_path():
return gmp


def check_for_fmm():
"""Return true of compatible FMM found."""
exafmm_found = False
try:
import exafmm
except:
exafmm_found = False
else:
exafmm_found = True

return exafmm_found


def _get_version():
"""Get version string."""
from bempp import version
Expand Down
10 changes: 10 additions & 0 deletions bempp/api/assembly/assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def _create_assembler(
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.core.numba.dense_assembler import DenseAssembler
from bempp.core.sparse_assembler import SparseAssembler
Expand All @@ -29,6 +30,10 @@ def _create_assembler(
if identifier == "sparse":
return SparseAssembler(domain, dual_to_range, parameters)
if identifier == "fmm":
if not check_for_fmm():
raise ValueError(
"No compatible FMM library found. Please install Exafmm from github.com/exafmm/exafmm-t."
)
return FmmAssembler(domain, dual_to_range, parameters)
else:
raise ValueError("Unknown assembler type.")
Expand Down Expand Up @@ -184,6 +189,11 @@ def select_potential_implementation(
elif assembler == "fmm":
from bempp.api.fmm.fmm_assembler import FmmPotentialAssembler

if not bempp.api.check_for_fmm():
raise ValueError(
"No compatible FMM library found. Please install Exafmm from github.com/exafmm/exafmm-t."
)

return FmmPotentialAssembler(
space, operator_descriptor, points, device_interface, parameters
)
Expand Down
8 changes: 1 addition & 7 deletions bempp/api/grid/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ def export(
else:
gmsh = False

if extension == ".vtk":
if write_binary:
file_format = "vtk-binary"
else:
file_format = "vtk-ascii"

if grid is not None and grid_function is not None:
raise ValueError("Exactly one of 'grid' and 'grid_function' must be supplied.")

Expand Down Expand Up @@ -144,7 +138,7 @@ def export(
)
cell_data["gmsh:geometrical"] = geom_indices.reshape((1, -1))
else:
cell_data["domain_index"] = grid.domain_indices.astype("int32").reshape((-1, 1))
cell_data["domain_index"] = grid.domain_indices.astype("int32").reshape((1, -1))

_meshio.write_points_cells(
filename,
Expand Down
12 changes: 9 additions & 3 deletions bempp/core/numba_assemblers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ def singular_assembler(
operator_descriptor, mode="singular"
)

precision = operator_descriptor.precision
# Perform Numba assembly always in double precision
# precision = operator_descriptor.precision
precision = "double"
dtype = get_type(precision).real

numba_assembly_function(
Expand Down Expand Up @@ -70,7 +72,9 @@ def dense_assembler(
order = parameters.quadrature.regular
quad_points, quad_weights = rule(order)

precision = operator_descriptor.precision
# Perform Numba assembly always in double precision
# precision = operator_descriptor.precision
precision = "double"

data_type = get_type(precision).real

Expand Down Expand Up @@ -129,7 +133,9 @@ def potential_assembler(

quad_points, quad_weights = rule(parameters.quadrature.regular)

precision = operator_descriptor.precision
# Perform Numba assembly always in double precision
# precision = operator_descriptor.precision
precision = "double"

dtype = _np.dtype(get_type(precision).real)

Expand Down
10 changes: 6 additions & 4 deletions bempp/core/opencl_assemblers.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ def singular_assembler(
ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=domain.normal_multipliers
)
test_points_buffer = _cl.Buffer(
ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=test_points
ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=test_points.astype(dtype)
)
trial_points_buffer = _cl.Buffer(
ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=trial_points
ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=trial_points.astype(dtype)
)
quad_weights_buffer = _cl.Buffer(
ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=quad_weights
ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=quad_weights.astype(dtype)
)
test_elements_buffer = _cl.Buffer(
ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=test_elements
Expand Down Expand Up @@ -399,7 +399,9 @@ def potential_assembler(
)

points_buffer = _cl.Buffer(
ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=points.ravel(order="F")
ctx,
mf.READ_ONLY | mf.COPY_HOST_PTR,
hostbuf=points.ravel(order="F").astype(dtype),
)

grid_buffer = _cl.Buffer(
Expand Down
13 changes: 5 additions & 8 deletions bempp/core/singular_assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def assemble_singular_part(
trial_offsets,
weights_offsets,
number_of_quad_points,
] = rule.get_arrays(precision)
] = rule.get_arrays()

if is_complex:
result_type = get_type(precision).complex
Expand Down Expand Up @@ -282,11 +282,8 @@ def number_of_points(self, adjacency):
"""Return the number of quadrature points for given adjacency."""
return _duffy_galerkin.number_of_quadrature_points(self.order, adjacency)

def get_arrays(self, precision):
def get_arrays(self):
"""Return the arrays."""
from bempp.api.utils.helpers import get_type

types = get_type(precision)

test_indices, trial_indices = self._vectorize_indices()
test_points, trial_points = self._vectorize_points()
Expand All @@ -298,9 +295,9 @@ def get_arrays(self, precision):
self._trial_indices = trial_indices

arrays = [
test_points.astype(types.real),
trial_points.astype(types.real),
weights.astype(types.real),
test_points,
trial_points,
weights,
test_indices,
trial_indices,
test_offsets,
Expand Down
5 changes: 4 additions & 1 deletion bempp/core/sparse_assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ def assemble_sparse(
nshape_test = dual_to_range.number_of_shape_functions
nshape_trial = domain.number_of_shape_functions

precision = operator_descriptor.precision
# Always assemble in double precision for sparse ops
# precision = operator_descriptor.precision

precision = "double"

if operator_descriptor.is_complex:
result_type = get_type(precision).complex
Expand Down
2 changes: 1 addition & 1 deletion bempp/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.0"
__version__ = "0.2.1"
Loading

0 comments on commit 1b52176

Please sign in to comment.