Skip to content

Commit 94c21e5

Browse files
committed
Remove field locks in NLBVP linearization
1 parent 6a377c8 commit 94c21e5

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

dedalus/core/field.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,3 +1022,10 @@ def lock_to_layouts(self, *layouts):
10221022
def lock_axis_to_grid(self, axis):
10231023
self.allowed_layouts = tuple(l for l in self.dist.layouts if l.grid_space[axis])
10241024

1025+
def unlock(self):
1026+
"""Return regular Field object with same data and no layout locking."""
1027+
field = Field(self.dist, bases=self.domain.bases, name=self.name, tensorsig=self.tensorsig, dtype=self.dtype)
1028+
field.preset_scales(self.scales)
1029+
field[self.layout] = self.data
1030+
return field
1031+

dedalus/core/problems.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44
from collections import ChainMap
55

6-
from .field import Operand, Field
6+
from .field import Operand, Field, LockedField
77
from . import arithmetic
88
from . import operators
99
from . import solvers
@@ -244,6 +244,10 @@ def _build_matrix_expressions(self, eqn):
244244
# Extract matrix expressions
245245
F = eqn['LHS'] - eqn['RHS']
246246
dF = F.frechet_differential(vars, perts)
247+
# Remove any field locks
248+
dF = dF.replace(operators.Lock, lambda x: x)
249+
for field in dF.atoms(LockedField):
250+
dF = dF.replace(field, field.unlock())
247251
# Reinitialize and prep NCCs
248252
dF = dF.reinitialize(ncc=True, ncc_vars=perts)
249253
dF.prep_nccs(vars=perts)

0 commit comments

Comments
 (0)