Skip to content

Commit

Permalink
Transfer of elliptic solvers is no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmaddison committed Dec 3, 2024
1 parent 39ef57f commit e3ee9d6
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions bt_ocean/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,6 @@ def new(self, *, copy_prescribed=False):
if copy_prescribed:
for key in self.prescribed_field_keys:
model.fields[key] = self.fields[key]
model.poisson_solver = self.poisson_solver
return model

def update(self, model):
Expand All @@ -811,18 +810,17 @@ def flatten(self):
"""

return ((dict(self.fields), self.n),
(self.parameters, self.grid.idtype, self.grid.fdtype, self.poisson_solver))
(self.parameters, self.grid.idtype, self.grid.fdtype))

@classmethod
def unflatten(cls, aux_data, children):
"""Unpack a JAX flattened representation.
"""

parameters, idtype, fdtype, poisson_solver = aux_data
parameters, idtype, fdtype = aux_data
fields, n = children

model = cls(parameters, idtype=idtype, fdtype=fdtype)
model.poisson_solver = poisson_solver
model.fields.update({key: value for key, value in fields.items() if type(value) is not object})
if type(n) is not object:
model.n = n
Expand Down Expand Up @@ -938,18 +936,3 @@ def step(self):

def steady_state_solve(self, *args, update=lambda model, *args: None, tol, max_it=10000):
return super().steady_state_solve(*args, update=update, tol=tol, max_it=max_it, _min_n=1)

def new(self, copy_prescribed=False):
model = super().new(copy_prescribed=copy_prescribed)
model.modified_helmholtz_solver = self.modified_helmholtz_solver
return model

def flatten(self):
children, aux_data = super().flatten()
return children, aux_data + (self.modified_helmholtz_solver,)

@classmethod
def unflatten(cls, aux_data, children):
model = super().unflatten(aux_data[:-1], children)
model.modified_helmholtz_solver = aux_data[-1]
return model

0 comments on commit e3ee9d6

Please sign in to comment.