Skip to content

Commit b434a1f

Browse files
authored
Merge pull request #539 from firedrakeproject/coriolis_linear_solver
Coriolis linear solver
2 parents 7f446e2 + 8e56dad commit b434a1f

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

gusto/solvers/linear_solvers.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
split, LinearVariationalProblem, Constant, LinearVariationalSolver,
1010
TestFunctions, TrialFunctions, TestFunction, TrialFunction, lhs,
1111
rhs, FacetNormal, div, dx, jump, avg, dS, dS_v, dS_h, ds_v, ds_t, ds_b,
12-
ds_tb, inner, action, dot, grad, Function, VectorSpaceBasis,
13-
BrokenElement, FunctionSpace, MixedFunctionSpace, DirichletBC
12+
ds_tb, inner, action, dot, grad, Function, VectorSpaceBasis, cross,
13+
BrokenElement, FunctionSpace, MixedFunctionSpace, DirichletBC, as_vector
1414
)
1515
from firedrake.fml import Term, drop
1616
from firedrake.petsc import flatten_parameters
@@ -318,12 +318,15 @@ def L_tr(f):
318318
+ dl('+')*jump(u, n=n)*(dS_vp + dS_hp)
319319
+ dl*dot(u, n)*(ds_tbp + ds_vp)
320320
)
321-
322321
# TODO: can we get this term using FML?
323322
# contribution of the sponge term
324323
if hasattr(self.equations, "mu"):
325324
eqn += dt*self.equations.mu*inner(w, k)*inner(u, k)*dx
326325

326+
if equations.parameters.Omega is not None:
327+
Omega = as_vector([0, 0, equations.parameters.Omega])
328+
eqn += inner(w, cross(2*Omega, u))*dx
329+
327330
aeqn = lhs(eqn)
328331
Leqn = rhs(eqn)
329332

@@ -506,6 +509,11 @@ def V(u):
506509

507510
if hasattr(self.equations, "mu"):
508511
eqn += dt*self.equations.mu*inner(w, k)*inner(u, k)*dx
512+
513+
if equation.parameters.Omega is not None:
514+
Omega = as_vector((0, 0, equation.parameter.Omega))
515+
eqn += inner(w, cross(2*Omega, u))*dx
516+
509517
aeqn = lhs(eqn)
510518
Leqn = rhs(eqn)
511519

@@ -655,6 +663,10 @@ def _setup_solver(self):
655663
+ beta_d * phi * Dbar * div(u) * dx
656664
)
657665

666+
if 'coriolis' in equation.prescribed_fields._field_names:
667+
f = equation.prescribed_fields('coriolis')
668+
eqn += beta_u_ * f * inner(w, equation.domain.perp(u)) * dx
669+
658670
aeqn = lhs(eqn)
659671
Leqn = rhs(eqn)
660672

@@ -867,6 +879,10 @@ def _setup_solver(self):
867879
+ beta_d * phi * Dbar * div(u) * dx
868880
)
869881

882+
if 'coriolis' in equation.prescribed_fields._field_names:
883+
f = equation.prescribed_fields('coriolis')
884+
eqn += beta_u_ * f * inner(w, equation.domain.perp(u)) * dx
885+
870886
aeqn = lhs(eqn)
871887
Leqn = rhs(eqn)
872888

0 commit comments

Comments
 (0)