Skip to content

Commit

Permalink
Merge pull request #196 from firedrakeproject/upstream_fixes
Browse files Browse the repository at this point in the history
Upstream fixes
  • Loading branch information
JHopeCollins authored Jul 16, 2024
2 parents 1c9192d + 2030d42 commit fd86815
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
22 changes: 7 additions & 15 deletions asQ/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,23 @@ def get_option_from_list(prefix, option_name, option_list,
return option


class MissingOption:
pass


missing_option = MissingOption()


def get_deprecated_option(getOption, prefix, deprecated_prefix,
option_name, default=None):
deprecated_name = deprecated_prefix + option_name
option_name = prefix + option_name

deprecated_option = getOption(deprecated_name,
default=missing_option)
default=default)
option = getOption(option_name,
default=missing_option)
default=default)

if deprecated_option is not missing_option:
if deprecated_option != default:
msg = f"Prefix {deprecated_prefix} is deprecated and will be removed in the future. Use {prefix} instead."
warn(msg)

if option is not missing_option:
if option != default:
msg = f"{deprecated_name} ignored in favour of {option_name}"
warn(msg)
else:
option = deprecated_option

for opt in (option, deprecated_option, default):
if opt is not missing_option:
return opt
return option
8 changes: 4 additions & 4 deletions asQ/preconditioners/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,18 @@ def initialize(self, pc, final_initialize=True):
# Problem parameter options
if self.deprecated_prefix is None:
self.dt = PETSc.Options().getReal(
f"{self.full_prefix}dt", default=self.aaoform.dt)
f"{self.full_prefix}dt", default=self.aaoform.dt.values()[0])

self.theta = PETSc.Options().getReal(
f"{self.full_prefix}theta", default=self.aaoform.theta)
f"{self.full_prefix}theta", default=self.aaoform.theta.values()[0])
else:
self.dt = get_deprecated_option(
PETSc.Options().getReal, self.full_prefix,
self.deprecated_prefix, "dt", default=self.aaoform.dt)
self.deprecated_prefix, "dt", default=self.aaoform.dt.values()[0])

self.theta = get_deprecated_option(
PETSc.Options().getReal, self.full_prefix,
self.deprecated_prefix, "theta", default=self.aaoform.theta)
self.deprecated_prefix, "theta", default=self.aaoform.theta.values()[0])

self.time = tuple(fd.Constant(0) for _ in range(self.nlocal_timesteps))

Expand Down
2 changes: 1 addition & 1 deletion case_studies/shallow_water/blockpc/swe_cpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def aux_form_function(u, h, v, q, t=None):
solver.invalidate_jacobian()

if verbosity > 0:
PETSc.Sys.Print(f"Eigenvalues {str(k).rjust(3)}:\n d1 = {np.round(d1,4)}, d2 = {np.round(d2,4)}, dhat = {np.round(dhat,4)}")
PETSc.Sys.Print(f"Eigenvalues {str(k).rjust(3)}:\n d1 = {np.round(d1, 4)}, d2 = {np.round(d2, 4)}, dhat = {np.round(dhat, 4)}")

np.random.seed(args.seed)
for j in range(args.nrhs):
Expand Down
4 changes: 3 additions & 1 deletion utils/hybridisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def project(self, src, dst):
"dst": (dst, INC)})


def _break_function_space(V, appctx):
def _break_function_space(V, appctx=None):
if appctx is None:
appctx = {}
cpx = appctx.get('cpx', None)
mesh = V.mesh()

Expand Down

0 comments on commit fd86815

Please sign in to comment.