Skip to content

Commit

Permalink
tidy up swe hybridscpc examples
Browse files Browse the repository at this point in the history
  • Loading branch information
JHopeCollins committed Apr 8, 2024
1 parent 16cdfe2 commit 7fca31b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 25 deletions.
11 changes: 0 additions & 11 deletions case_studies/shallow_water/blockpc/lswe_cpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,6 @@
V = swe.default_function_space(mesh)
W = cpx.FunctionSpace(V)

Wu, Wh = W.subfunctions

Vu, Vh = V.subfunctions
Vub = fd.FunctionSpace(mesh, fd.BrokenElement(Vu.ufl_element()))
Vt = fd.FunctionSpace(mesh, "HDivT", Vu.ufl_element().degree())
Vtr = Vub*Vh*Vt

Wtr = cpx.FunctionSpace(Vtr)

Wub, _, Wt = Wtr.subfunctions


# shallow water equation forms
def form_mass(u, h, v, q):
Expand Down
2 changes: 1 addition & 1 deletion case_studies/shallow_water/blockpc/lswe_rblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# get command arguments
import argparse
parser = argparse.ArgumentParser(
description='Test preconditioners for the complex linear shallow water equations.',
description='Test preconditioners for the real-valued linear shallow water equations.',
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)

Expand Down
18 changes: 11 additions & 7 deletions case_studies/shallow_water/linear_gravity_bumps.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,24 @@
dt = args.dt*units.hour

# parameters for the implicit diagonal solve in step-(b)
lu_params = {
'ksp_type': 'preonly',
'pc_type': 'lu',
'pc_factor_mat_solver_type': 'mumps'
}


from utils.hybridisation import HybridisedSCPC # noqa: F401
hybridscpc_parameters = {
"ksp_type": 'preonly',
"mat_type": "matfree",
"pc_type": "python",
"pc_python_type": f"{__name__}.HybridisedSCPC",
"hybridscpc_condensed_field": lu_params,
"hybridscpc_condensed_field": {
'ksp_type': 'preonly',
'pc_type': 'lu',
'pc_factor_mat_solver_type': 'mumps',
'snes': { # reuse factorisation
'lag_jacobian': -2,
'lag_jacobian_persists': None,
'lag_preconditioner': -2,
'lag_preconditioner_persists': None,
}
}
}

rtol = 1e-10
Expand Down
4 changes: 2 additions & 2 deletions case_studies/shallow_water/serial/galewsky_serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def aux_form_function(u, h, v, q, t):
'mat_type': 'matfree',
'pc_type': 'python',
'pc_python_type': 'asQ.AuxiliaryRealBlockPC',
'aux': lu_params,
'aux': hybridscpc_sparameters,
'aux_snes': linear_snes_params
}

Expand All @@ -189,7 +189,7 @@ def aux_form_function(u, h, v, q, t):
'rtol': 1e-5,
},
}
sparameters.update(hybridscpc_sparameters)
sparameters.update(aux_sparameters)

# set up nonlinear solver
miniapp = SerialMiniApp(dt, args.theta, w_initial,
Expand Down
5 changes: 1 addition & 4 deletions case_studies/shallow_water/serial/linear_swe_serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def form_function(u, h, v, q, t):
}
}

from utils.mg import ManifoldTransferManager # noqa: F401
mg_parameters = {
'transfer_manager': f'{__name__}.ManifoldTransferManager',
'levels': {
Expand All @@ -131,7 +132,6 @@ def form_function(u, h, v, q, t):
},
}

from utils.mg import ManifoldTransferManager # noqa: F401
mg_sparams = {
'mat_type': 'matfree',
'pc_type': 'mg',
Expand Down Expand Up @@ -161,7 +161,6 @@ def form_function(u, h, v, q, t):
"pc_type": "python",
"pc_python_type": "firedrake.HybridizationPC",
"hybridization": lu_params
# "hybridization": gamg_sparams
}

condensed_params = gamg_sparams
Expand Down Expand Up @@ -191,8 +190,6 @@ def form_function(u, h, v, q, t):
}
sparameters['snes'].update(linear_snes_params)

# sparameters.update(lu_params)
# sparameters.update(mg_sparams)
sparameters.update(scpc_sparams)

# set up nonlinear solver
Expand Down

0 comments on commit 7fca31b

Please sign in to comment.