Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions firedrake/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2410,6 +2410,8 @@ def coordinates(self) -> "Function":

@coordinates.setter
def coordinates(self, value):
if value is self.coordinates:
return
message = """Cannot re-assign the coordinates.

You are free to change the coordinate values, but if you need a
Expand Down
21 changes: 21 additions & 0 deletions tests/firedrake/meshes/test_modify_coordinates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from firedrake import *
import numpy as np


def test_scale_coordinates():

m = UnitSquareMesh(4, 4)
m.coordinates *= 2

assert np.allclose(assemble(Constant(1)*dx(domain=m)), 4.0)


def test_addto_coordinates():

m = UnitSquareMesh(4, 4)
X = SpatialCoordinate(m)
xf = Function(m.coordinates.function_space())
xf.interpolate(X)
m.coordinates += xf

assert np.allclose(assemble(Constant(1)*dx(domain=m)), 4.0)
Loading