Skip to content

Commit 0caafbf

Browse files
committed
Tidy up of options ready in using JHC suggestions
1 parent e29a439 commit 0caafbf

File tree

2 files changed

+15
-29
lines changed

2 files changed

+15
-29
lines changed

gusto/solvers/preconditioners.py

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -479,14 +479,9 @@ def initialize(self, pc):
479479

480480
self._process_context(pc)
481481
prefix = pc.getOptionsPrefix()
482-
opts = PETSc.Options()
483482

484483
# Unpack sub-solver parameters from the options prefix
485-
self.theta_solver_parameters = self._get_sub_params(opts, prefix + "theta_backsub")
486-
self.exner_avg_solver_parameters = self._get_sub_params(opts, prefix + "exner_ave")
487-
self.rho_avg_solver_parameters = self._get_sub_params(opts, prefix + "rho_ave")
488-
self.riesz_map_parameters = self._get_sub_params(opts, prefix + "riesz_map")
489-
self.scpc_solve_parameters = self._get_sub_params(opts, prefix + "scpc_solve")
484+
self.riesz_map_parameters = PETSc.Options(prefix + "riesz_map_").getAll()
490485

491486
if logger.isEnabledFor(DEBUG):
492487
self.scpc_solve_parameters['ksp_monitor_true_residual'] = None
@@ -612,12 +607,12 @@ def L_tr(f):
612607
constant_jacobian=True)
613608

614609
self.rho_avg_solver = LinearVariationalSolver(
615-
rho_avg_prb, solver_parameters=self.rho_avg_solver_parameters,
616-
options_prefix=pc.getOptionsPrefix()+'rhobar_avg_solver'
610+
rho_avg_prb,
611+
options_prefix=pc.getOptionsPrefix()+'rhobar_avg'
617612
)
618613
self.exner_avg_solver = LinearVariationalSolver(
619-
exner_avg_prb, solver_parameters=self.exner_avg_solver_parameters,
620-
options_prefix=pc.getOptionsPrefix()+'exnerbar_avg_solver'
614+
exner_avg_prb,
615+
options_prefix=pc.getOptionsPrefix()+'exnerbar_avg'
621616
)
622617

623618
# "broken" u, rho, and trace system
@@ -671,8 +666,9 @@ def L_tr(f):
671666
aeqn, Leqn, self.y_hybrid, constant_jacobian=True
672667
)
673668
self.hybridized_solver = LinearVariationalSolver(
674-
hybridized_prb, solver_parameters=self.scpc_solve_parameters,
675-
options_prefix=pc.getOptionsPrefix()+self._prefix, appctx=appctx
669+
hybridized_prb,
670+
options_prefix=pc.getOptionsPrefix()+self._prefix,
671+
appctx=appctx
676672
)
677673

678674
if logger.isEnabledFor(DEBUG):
@@ -705,8 +701,8 @@ def L_tr(f):
705701
)
706702

707703
self.theta_solver = LinearVariationalSolver(
708-
theta_problem, solver_parameters=self.theta_solver_parameters,
709-
options_prefix=pc.getOptionsPrefix()+'thetabacksubstitution'
704+
theta_problem,
705+
options_prefix=pc.getOptionsPrefix()+'theta_backsub'
710706
)
711707

712708
if logger.isEnabledFor(DEBUG):
@@ -793,13 +789,3 @@ def applyTranspose(self, pc, x, y):
793789
"""
794790

795791
raise NotImplementedError("The transpose application of the PC is not implemented.")
796-
797-
def _get_sub_params(self, opts, prefix):
798-
result = {}
799-
for key, val in opts.getAll().items():
800-
if key.startswith(prefix):
801-
stripped = key[len(prefix):]
802-
# Remove leading underscore
803-
stripped = stripped.lstrip('_')
804-
result[stripped] = val if val != "" else None
805-
return result

gusto/solvers/solver_presets.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ def trace_nullsp(T):
7878
'ksp_atol': a_tol,
7979
}
8080

81-
exner_ave_settings = {
81+
exnerbar_avg_settings = {
8282
'ksp_type': 'cg',
8383
'pc_type': 'bjacobi',
8484
'sub_pc_type': 'ilu',
8585
'ksp_rtol': r_tol,
8686
'ksp_atol': a_tol,
8787
}
8888

89-
rho_ave_settings = {
89+
rhobar_avg_settings = {
9090
'ksp_type': 'cg',
9191
'pc_type': 'bjacobi',
9292
'sub_pc_type': 'ilu',
@@ -132,10 +132,10 @@ def trace_nullsp(T):
132132
'pc_type': 'python',
133133
'pc_python_type': 'gusto.CompressibleHybridisedSCPC',
134134
'theta_backsub': theta_backsub_settings,
135-
'exner_ave': exner_ave_settings,
136-
'rho_ave': rho_ave_settings,
135+
'exnerbar_avg': exnerbar_avg_settings,
136+
'rhobar_avg': rhobar_avg_settings,
137137
'riesz_map': riesz_map_settings,
138-
'scpc_solve': scpc_solve_settings,
138+
'compressible_hybrid_scpc': scpc_solve_settings,
139139
}
140140

141141
# We pass the implicit weighting parameter (alpha) and tau_values to the

0 commit comments

Comments
 (0)