Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions simpeg_drivers/components/factories/misfit_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
from typing import TYPE_CHECKING

import numpy as np
from dask.distributed import wait
from dask.distributed import Future, wait
from simpeg import objective_function
from simpeg.dask import objective_function as dask_objective_function
from simpeg.electromagnetics.base_1d import BaseEM1DSimulation
from simpeg.objective_function import ComboObjectiveFunction

from simpeg_drivers.components.factories.simpeg_factory import SimPEGFactory
Expand Down Expand Up @@ -56,7 +57,7 @@ def assemble_arguments( # pylint: disable=arguments-differ
else:
channels = [None]

use_futures = self.client
use_futures = self.client and isinstance(self.simulation, BaseEM1DSimulation)

# Pickle the simulation to the temporary file
with open(
Expand Down Expand Up @@ -143,12 +144,12 @@ def collect_ordering_from_misfits(self, misfits):
"""
attributes = []
for misfit in misfits:
if self.client:
if isinstance(misfit, Future):
attributes.append(self.client.submit(_get_ordering, misfit))
else:
attributes += _get_ordering(misfit)

if self.client:
if isinstance(attributes[0], Future):
ordering = []
for future in self.client.gather(attributes):
ordering += future
Expand Down
12 changes: 6 additions & 6 deletions simpeg_drivers/components/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ def lower_bound(self) -> np.ndarray | None:
bound_model = -self._upper_bound.model

if bound_model is None:
return -np.inf

lbound = bound_model.copy()
lbound = np.full(self.n_active, -np.inf)
else:
lbound = bound_model.copy()

if self.is_sigma:
is_finite = np.isfinite(lbound)
Expand All @@ -304,9 +304,9 @@ def upper_bound(self) -> np.ndarray | None:
bound_model = self._upper_bound.model

if bound_model is None:
return np.inf

ubound = bound_model.copy()
ubound = np.full(self.n_active, np.inf)
else:
ubound = bound_model.copy()

if self.is_sigma:
is_finite = np.isfinite(ubound)
Expand Down
8 changes: 6 additions & 2 deletions simpeg_drivers/utils/regularization.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,13 @@ def set_rotated_operators(
)

grad_op_active = mesh.Pac.T @ (unit_grad_op @ mesh.Pac)

# Remove extra partial volume from missing neighbors
row_sum = np.asarray(grad_op_active.sum(axis=1)).ravel()
grad_op_active -= sdiag(row_sum)

vol_avg_op = mesh.Pac.T @ (vol_avg_op @ mesh.Pac)
active_faces = np.isclose(grad_op_active @ np.ones(mesh.n_cells), 0)
active_faces &= grad_op_active.max(axis=1).toarray().ravel() != 0
active_faces = grad_op_active.max(axis=1).toarray().ravel() != 0

vol_avg_op = vol_avg_op[active_faces, :]
vol_avg_op = sdiag(np.asarray(vol_avg_op.sum(axis=1)).ravel() ** -1) @ vol_avg_op
Expand Down
Loading