Skip to content
Snippets Groups Projects

Capture geometry Jacobians by value, not by reference

Closed Oliver Sander requested to merge capture-jacobian-by-value into master
1 unresolved thread

The methods of the geometry interface that return Jacobians have been changed from returning references to returning values a long time ago.

Merge request reports

Pipeline #61100 passed

Pipeline passed for 39b5deda on capture-jacobian-by-value

Approval is optional

Closed by Oliver SanderOliver Sander 2 years ago (Mar 22, 2023 10:52am UTC)

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
    • IMO the change is okay but not needed, due to life time prolongation when binding to const references. Also notices that return by value was only made mandatory for geometries of grid entities (that use the interface class in dune-grid). In contrast "free" Geometry implementations may very well return references to stored values. This is e.g. the case for AffineGeometry::jacobian(Inverse)Transposed.

      But I have no idea whether or not saving this copy has any performance impact (probably not).

    • I do need it in a very particular case. In laplaceassembler.hh:89 the expression jacobianInverseTransposed.rows is used to get the number of rows of a FieldMatrix at compile-time. The fails with clang if jacobianInverseTransposed is a const reference, but it works if it is a value.

    • I see, that's indeed an error. But I doubt that this is allowed with a copy (and may eventually fail if compilers get more strict). The clean way would be to either use std::decay_t<decltype(jacobianInverseTransposed)>::rows or define an alias to the geometry and then use Geometry::JacobianInverseTransposed::rows.

    • Please register or sign in to reply
  • closed

Please register or sign in to reply
Loading