22
33from firedrake import (dot , jump , dS_h , ds_b , ds_t , ds ,
44 FacetNormal , Tensor , AssembledVector ,
5- AuxiliaryOperatorPC , PETSc )
5+ AuxiliaryOperatorPC , PETSc , RieszMap )
66
77from firedrake .preconditioners import PCBase
88from firedrake .matrix_free .operators import ImplicitMatrixContext
@@ -460,35 +460,6 @@ class CompressibleHybridisedSCPC(PCBase):
460460
461461 _prefix = "compressible_hybrid_scpc"
462462
463- scpc_parameters = {
464- 'mat_type' : 'matfree' ,
465- 'ksp_type' : 'preonly' ,
466- 'pc_type' : 'python' ,
467- 'pc_python_type' : 'firedrake.SCPC' ,
468- 'pc_sc_eliminate_fields' : '0, 1' ,
469- # The reduced operator is not symmetric
470- 'condensed_field' : {
471- 'ksp_type' : 'fgmres' ,
472- 'ksp_rtol' : 1.0e-8 ,
473- 'ksp_atol' : 1.0e-8 ,
474- 'ksp_max_it' : 100 ,
475- 'pc_type' : 'gamg' ,
476- 'pc_gamg_sym_graph' : None ,
477- 'mg_levels' : {
478- 'ksp_type' : 'gmres' ,
479- 'ksp_max_it' : 5 ,
480- 'pc_type' : 'bjacobi' ,
481- 'sub_pc_type' : 'ilu'
482- }
483- }
484- }
485-
486- cg_ilu_parameters = {
487- 'ksp_type' : 'cg' ,
488- 'pc_type' : 'bjacobi' ,
489- 'sub_pc_type' : 'ilu'
490- }
491-
492463 def initialize (self , pc ):
493464 """
494465 Set up problem and solver
@@ -507,15 +478,14 @@ def initialize(self, pc):
507478 raise ValueError ("Expecting PC type python" )
508479
509480 self ._process_context (pc )
481+ prefix = pc .getOptionsPrefix ()
510482
511- self .hybridised_scpc_parameters = self .scpc_parameters
512- self .rho_avg_solver_parameters = self .cg_ilu_parameters
513- self .theta_solver_parameters = self .cg_ilu_parameters
514- self .exner_avg_solver_parameters = self .cg_ilu_parameters
483+ # Unpack sub-solver parameters from the options prefix
484+ self .riesz_map_parameters = PETSc .Options (prefix + "riesz_map_" ).getAll ()
515485
516486 if logger .isEnabledFor (DEBUG ):
517- self .hybridised_scpc_parameters ['ksp_monitor_true_residual' ] = None
518- self .hybridised_scpc_parameters ['ksp_converged_reason' ] = None
487+ self .scpc_solve_parameters ['ksp_monitor_true_residual' ] = None
488+ self .scpc_solve_parameters ['ksp_converged_reason' ] = None
519489
520490 # Equations and parameters
521491 equations = self .equations
@@ -548,6 +518,11 @@ def initialize(self, pc):
548518 self .xrhs = Function (self .W )
549519 self .y = Function (self .W )
550520
521+ # Riesz map for the dual of the original function space
522+ self .riesz_map = RieszMap (self .W .dual (),
523+ solver_parameters = self .riesz_map_parameters ,
524+ constant_jacobian = True )
525+
551526 self .y_hybrid = Function (self .W_hyb )
552527
553528 # Split input functions
@@ -632,12 +607,12 @@ def L_tr(f):
632607 constant_jacobian = True )
633608
634609 self .rho_avg_solver = LinearVariationalSolver (
635- rho_avg_prb , solver_parameters = self . rho_avg_solver_parameters ,
636- options_prefix = pc .getOptionsPrefix ()+ 'rhobar_avg_solver '
610+ rho_avg_prb ,
611+ options_prefix = pc .getOptionsPrefix ()+ 'rhobar_avg '
637612 )
638613 self .exner_avg_solver = LinearVariationalSolver (
639- exner_avg_prb , solver_parameters = self . exner_avg_solver_parameters ,
640- options_prefix = pc .getOptionsPrefix ()+ 'exnerbar_avg_solver '
614+ exner_avg_prb ,
615+ options_prefix = pc .getOptionsPrefix ()+ 'exnerbar_avg '
641616 )
642617
643618 # "broken" u, rho, and trace system
@@ -691,8 +666,9 @@ def L_tr(f):
691666 aeqn , Leqn , self .y_hybrid , constant_jacobian = True
692667 )
693668 self .hybridized_solver = LinearVariationalSolver (
694- hybridized_prb , solver_parameters = self .hybridised_scpc_parameters ,
695- options_prefix = pc .getOptionsPrefix ()+ self ._prefix , appctx = appctx
669+ hybridized_prb ,
670+ options_prefix = pc .getOptionsPrefix ()+ self ._prefix ,
671+ appctx = appctx
696672 )
697673
698674 if logger .isEnabledFor (DEBUG ):
@@ -725,8 +701,8 @@ def L_tr(f):
725701 )
726702
727703 self .theta_solver = LinearVariationalSolver (
728- theta_problem , solver_parameters = self . theta_solver_parameters ,
729- options_prefix = pc .getOptionsPrefix ()+ 'thetabacksubstitution '
704+ theta_problem ,
705+ options_prefix = pc .getOptionsPrefix ()+ 'theta_backsub '
730706 )
731707
732708 if logger .isEnabledFor (DEBUG ):
@@ -753,7 +729,7 @@ def apply(self, pc, x, y):
753729 with self .xstar .dat .vec_wo as xv :
754730 x .copy (xv )
755731
756- self .xrhs .assign (self .xstar . riesz_representation ( ))
732+ self .xrhs .assign (self .riesz_map ( self . xstar ))
757733 # Solve hybridized system
758734 self .hybridized_solver .solve ()
759735
0 commit comments