Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions src/underworld3/function/_function.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,9 @@ def _project_to_work_variable(expr, mesh, smoothing=1e-6):
)
projector.uw_function = flat_source
projector.smoothing = smoothing
projector.solve(zero_init_guess=False)
# _force_setup=True: rebuild solver state to avoid stale cached
# projector after Stokes/DM modifications (issue #215, Bug 2).
projector.solve(zero_init_guess=False, _force_setup=True)

# Fan flat result back to the tensor work variable
for idx in range(n_components):
Expand All @@ -637,7 +639,9 @@ def _project_to_work_variable(expr, mesh, smoothing=1e-6):

projector.uw_function = scalar_expr
projector.smoothing = smoothing
projector.solve(zero_init_guess=False)
# _force_setup=True: rebuild solver state to avoid stale cached
# projector after Stokes/DM modifications (issue #215, Bug 2).
projector.solve(zero_init_guess=False, _force_setup=True)

return work_var

Expand Down
7 changes: 7 additions & 0 deletions src/underworld3/swarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,12 @@ def _update(self):

return

# TODO(BUG): Stale proxy DM after swarm data write
# _update() marks proxy as stale, but _update_proxy_if_stale() (lazy
# re-interpolation) only fires when material.sym is accessed. Code that
# reads the proxy MeshVariable DM directly (e.g. a Projection solver
# evaluating its uw_function at quadrature points) gets stale data.
# See GitHub issue #215 (Bug 3).
def _update_proxy_if_stale(self):
"""
Actually update the proxy mesh variable if it's marked as stale.
Expand Down Expand Up @@ -3572,6 +3578,7 @@ def add_particles_with_coordinates(self, coordinatesArray) -> int:

# Invalidate cached data — particle count changed after addNPoints + migrate
self._particle_coordinates._canonical_data = None
self._kdtree = None # issue #215, Bug 1: stale kd-tree after add_particles_with_coordinates
for var in self._vars.values():
if hasattr(var, "_canonical_data"):
var._canonical_data = None
Expand Down
Loading
Loading