Skip to content

Commit

Permalink
Merge pull request #539 from firedrakeproject/coriolis_linear_solver
Browse files Browse the repository at this point in the history
Coriolis linear solver
  • Loading branch information
jshipton authored Aug 19, 2024
2 parents 7f446e2 + 8e56dad commit b434a1f
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions gusto/solvers/linear_solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
split, LinearVariationalProblem, Constant, LinearVariationalSolver,
TestFunctions, TrialFunctions, TestFunction, TrialFunction, lhs,
rhs, FacetNormal, div, dx, jump, avg, dS, dS_v, dS_h, ds_v, ds_t, ds_b,
ds_tb, inner, action, dot, grad, Function, VectorSpaceBasis,
BrokenElement, FunctionSpace, MixedFunctionSpace, DirichletBC
ds_tb, inner, action, dot, grad, Function, VectorSpaceBasis, cross,
BrokenElement, FunctionSpace, MixedFunctionSpace, DirichletBC, as_vector
)
from firedrake.fml import Term, drop
from firedrake.petsc import flatten_parameters
Expand Down Expand Up @@ -318,12 +318,15 @@ def L_tr(f):
+ dl('+')*jump(u, n=n)*(dS_vp + dS_hp)
+ dl*dot(u, n)*(ds_tbp + ds_vp)
)

# TODO: can we get this term using FML?
# contribution of the sponge term
if hasattr(self.equations, "mu"):
eqn += dt*self.equations.mu*inner(w, k)*inner(u, k)*dx

if equations.parameters.Omega is not None:
Omega = as_vector([0, 0, equations.parameters.Omega])
eqn += inner(w, cross(2*Omega, u))*dx

aeqn = lhs(eqn)
Leqn = rhs(eqn)

Expand Down Expand Up @@ -506,6 +509,11 @@ def V(u):

if hasattr(self.equations, "mu"):
eqn += dt*self.equations.mu*inner(w, k)*inner(u, k)*dx

if equation.parameters.Omega is not None:
Omega = as_vector((0, 0, equation.parameter.Omega))
eqn += inner(w, cross(2*Omega, u))*dx

aeqn = lhs(eqn)
Leqn = rhs(eqn)

Expand Down Expand Up @@ -655,6 +663,10 @@ def _setup_solver(self):
+ beta_d * phi * Dbar * div(u) * dx
)

if 'coriolis' in equation.prescribed_fields._field_names:
f = equation.prescribed_fields('coriolis')
eqn += beta_u_ * f * inner(w, equation.domain.perp(u)) * dx

aeqn = lhs(eqn)
Leqn = rhs(eqn)

Expand Down Expand Up @@ -867,6 +879,10 @@ def _setup_solver(self):
+ beta_d * phi * Dbar * div(u) * dx
)

if 'coriolis' in equation.prescribed_fields._field_names:
f = equation.prescribed_fields('coriolis')
eqn += beta_u_ * f * inner(w, equation.domain.perp(u)) * dx

aeqn = lhs(eqn)
Leqn = rhs(eqn)

Expand Down

0 comments on commit b434a1f

Please sign in to comment.