Skip to content

Align Functionspace.dofmap(s) interface#4231

Merged
jhale merged 8 commits into
mainfrom
schnellerhase/funtionspace-dofmaps
Jun 4, 2026
Merged

Align Functionspace.dofmap(s) interface#4231
jhale merged 8 commits into
mainfrom
schnellerhase/funtionspace-dofmaps

Conversation

@schnellerhase
Copy link
Copy Markdown
Contributor

@schnellerhase schnellerhase commented Jun 3, 2026

Aligns Functionspace.dofmaps interface to geometry access patter, ref #4227. Otherwise current access patterns of mesh.geometry.dofmaps and functionspace.dofmaps do confusingly not align anymore.

  • does not deprecate (python) FunctionSpace.dofmap, since also c++ layer still relies on it.

@schnellerhase schnellerhase force-pushed the schnellerhase/funtionspace-dofmaps branch 3 times, most recently from 16b4726 to a620cce Compare June 3, 2026 19:08
@schnellerhase schnellerhase force-pushed the schnellerhase/funtionspace-dofmaps branch from a620cce to e4721b4 Compare June 3, 2026 19:10
@schnellerhase schnellerhase added the housekeeping Tidying and style improvements label Jun 3, 2026
@schnellerhase schnellerhase self-assigned this Jun 3, 2026
@schnellerhase schnellerhase marked this pull request as ready for review June 3, 2026 19:16
Copy link
Copy Markdown
Contributor

@chrisrichardson chrisrichardson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use .front and .at instead of []...

@schnellerhase
Copy link
Copy Markdown
Contributor Author

schnellerhase commented Jun 4, 2026

I understand the .at. Why .front over .at(0)?

@jhale
Copy link
Copy Markdown
Member

jhale commented Jun 4, 2026

.front() is semantically correct from an STL perspective, works across all container types, and is cheaper (no bounds check), although this latter point is of course marginal in this non-hot loop setting.

@schnellerhase
Copy link
Copy Markdown
Contributor Author

schnellerhase commented Jun 4, 2026

The question is whether we want to use .at(0) (bound-checked) or .front (not bound checked). Since every other access (and current usage) is bound checked through .at for consistency I think we should then stick to .at(0) unless there is another concern here?

@chrisrichardson
Copy link
Copy Markdown
Contributor

We have used front elsewhere, so to be consistent I guess we should stick with that. It's not likely (or possible?) to have no dofmap.

@jhale jhale added this pull request to the merge queue Jun 4, 2026
@jhale
Copy link
Copy Markdown
Member

jhale commented Jun 4, 2026

As an aside, it's better/idiomatic to guard v.front() with !v.empty(), if needed.

Merged via the queue into main with commit 5183252 Jun 4, 2026
20 checks passed
@jhale jhale deleted the schnellerhase/funtionspace-dofmaps branch June 4, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

housekeeping Tidying and style improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants