Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix locate_cell changing coordinates dat version #2780

Merged
merged 1 commit into from
Feb 22, 2023

Conversation

ReubenHill
Copy link
Contributor

At present, running this

m = UnitSquareMesh(10, 10)
print(m.coordinates.dat.dat_version)
m.locate_cell([0.5, 0.5])
print(m.coordinates.dat.dat_version)

prints

0
2

This incrementation by two happens in MeshGeometry.locate_cell_and_reference_coordinate when accessing self.coordinates._ctypes

cell = self._c_locator(tolerance=tolerance)(self.coordinates._ctypes,

The root cause of this is at this line

c_function.coords = coordinates.dat.data.ctypes.data_as(c_void_p)

and this line
c_function.coords = coordinates.dat.data.ctypes.data_as(c_void_p)

This PR fixes this by switching to accessing data_ro instead of data.

This incremented dat.dat_version unnecessarily when calling locate_cell.
@dham dham merged commit 70454a6 into master Feb 22, 2023
@dham dham deleted the ReubenHill/fix-locate-cell-dat-version branch February 22, 2023 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants