Skip to content

Commit

Permalink
Fix indexing error in BDF with k=1
Browse files Browse the repository at this point in the history
  • Loading branch information
jcallaham committed Sep 11, 2024
1 parent 7462583 commit 22b6d16
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hydrogym/firedrake/solvers/bdf_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def step(self, iter, control=None):
self.flow.set_control(bc_scale)

# Solve the linear problem
if iter > self.k - 1:
if (self.k == 1) or (iter > self.k - 1):
self.petsc_solver.solve()
else:
self.startup_solvers[iter - 1].solve()
Expand Down
6 changes: 4 additions & 2 deletions test/test_cyl.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pytest
import firedrake as fd
import numpy as np

Expand Down Expand Up @@ -41,10 +42,11 @@ def test_steady_rotation(tol=1e-3):
assert abs(CD - 1.49) < tol # Re = 100


def test_integrate():
@pytest.mark.parametrize("k", [1, 3])
def test_integrate(k):
flow = hgym.Cylinder(mesh="medium")
dt = 1e-2
hgym.integrate(flow, t_span=(0, 10 * dt), dt=dt)
hgym.integrate(flow, t_span=(0, 10 * dt), dt=dt, order=k)


# Simple opposition control on lift
Expand Down

0 comments on commit 22b6d16

Please sign in to comment.