Skip to content

Commit

Permalink
Misc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jwallwork23 committed Jan 12, 2024
1 parent b92f884 commit 8fa8789
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
1 change: 1 addition & 0 deletions demos/monge_ampere1.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
# We can plot the initial mesh using Matplotlib as follows.

import matplotlib.pyplot as plt
from firedrake.pyplot import triplot

fig, axes = plt.subplots()
triplot(mesh, axes=axes)
Expand Down
4 changes: 2 additions & 2 deletions movement/monge_ampere.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ def __init__(self, mesh, monitor_function, **kwargs):
# Create functions to hold solution data
self.V = self.P1*self.P1_ten
self.phisigma = firedrake.Function(self.V)
self.phi, self.sigma = self.phisigma.split()
self.phi, self.sigma = self.phisigma.subfunctions
self.phisigma_old = firedrake.Function(self.V)
self.phi_old, self.sigma_old = self.phisigma_old.split()
self.phi_old, self.sigma_old = self.phisigma_old.subfunctions

# Initialise phi and sigma
self.apply_initial_guess(**kwargs)
Expand Down
1 change: 0 additions & 1 deletion test/test_smoothing.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def update_forcings(t):
pwd = os.path.dirname(__file__)
fname = os.path.join(pwd, "data", "forced_mesh_laplacian.npy")
assert np.allclose(new_coords, np.load(fname))
return mover


if __name__ == "__main__":
Expand Down
25 changes: 9 additions & 16 deletions test/test_spring.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_angles():
assert np.allclose(angles, expected)


def test_forced(method, time, plot=False, test=True):
def test_forced(method, time, plot=False)
"""
Test that a uniform mesh is moved as expected
when only one of its boundaries is forced.
Expand Down Expand Up @@ -88,29 +88,22 @@ def update_forcings(t):
# Plotting
if plot:
import matplotlib.pyplot as plt
from firedrake.pyplot import triplot

fig, axes = plt.subplots()
firedrake.triplot(mover.mesh, axes=axes)
triplot(mover.mesh, axes=axes)
axes.axis(False)
plt.tight_layout()
plt.savefig(f"plots/mesh_{method}_{it}.png")

# Check as expected
if test:
pwd = os.path.dirname(__file__)
fname = os.path.join(pwd, "data", f"forced_mesh_lineal_{it}.npy")
expected = coords if np.isclose(time, 0.0) else np.load(fname)
assert np.allclose(new_coords, expected)
return mover
pwd = os.path.dirname(__file__)
fname = os.path.join(pwd, "data", f"forced_mesh_lineal_{it}.npy")
expected = coords if np.isclose(time, 0.0) else np.load(fname)
assert np.allclose(new_coords, expected)


def test_plex_consistency(method, time):
"""
Test that the Firedrake mesh coordinates and the
underlying DMPlex's coordinates are consistent
after mesh movement.
"""
mover = test_forced(method, time, test=False)
# Test that the Firedrake mesh coordinates and the underlying DMPlex's
# coordinates are consistent after mesh movement.
plex_coords = mover.plex.getCoordinatesLocal().array
mesh_coords = mover.mesh.coordinates.dat.data_with_halos
assert np.allclose(plex_coords.reshape(*mesh_coords.shape), mesh_coords)
Expand Down

0 comments on commit 8fa8789

Please sign in to comment.