Skip to content

Draft constness write functions#348

Merged
BenjaminRodenberg merged 1 commit intoprecice:developfrom
Dominanz:PR_draft_constness_write_functions
Apr 12, 2019
Merged

Draft constness write functions#348
BenjaminRodenberg merged 1 commit intoprecice:developfrom
Dominanz:PR_draft_constness_write_functions

Conversation

@Dominanz
Copy link
Copy Markdown
Contributor

As discussed in this issue, the value arguments of the write functions in were changed into const pointers in this branch, since access to them is read-only inside this functions. This allows for safer code and better optimizations in programs that use preCICE, because they are now guaranteed that values are accessed read-only in the write functions.

@fsimonis
Copy link
Copy Markdown
Member

@Dominanz Thank you for your contribution!

Could you please also adjust the C bindings in src/precice/bindings/c/?

@Dominanz
Copy link
Copy Markdown
Contributor Author

@fsimonis I have done and commited this.

@fsimonis
Copy link
Copy Markdown
Member

I just looked over this PR again.
The pointers to the index arrays should really be const too. Would you like to add this change to this PR?

@Dominanz
Copy link
Copy Markdown
Contributor Author

You're totally right, I oversaw that. Thanks, I'm doing this tonight!

@Dominanz
Copy link
Copy Markdown
Contributor Author

@fsimonis Done. I realized that the same thing can be done for set/get mesh vertex functions, so I updated them too

@BenjaminRodenberg BenjaminRodenberg self-requested a review April 12, 2019 04:59
Copy link
Copy Markdown
Contributor

@BenjaminRodenberg BenjaminRodenberg left a comment

Choose a reason for hiding this comment

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

As soon as #348 (comment) is resolved, we can merge.

@BenjaminRodenberg BenjaminRodenberg changed the title Pr draft constness write functions Draft constness write functions Apr 12, 2019
@fsimonis fsimonis force-pushed the PR_draft_constness_write_functions branch 2 times, most recently from b31217b to ec5425c Compare April 12, 2019 10:21
Refactor data write functions to take const pointer arguments.
Change the write functions in SolverInterface (and the functions called by them) to take a const double* (resp. const double&) instead of a double* (resp. double) for the value argument. The purpose of these functions is to copy the contents of the buffer provided as value argument to the other solver. Hence, the access to the write buffer is read-only, consequently it can be const.
Add const to the C bindings
Add const in the set/get mesh vertex functions and for the valueIndices in Block functions
@fsimonis fsimonis force-pushed the PR_draft_constness_write_functions branch from ec5425c to 269fd94 Compare April 12, 2019 10:24
@BenjaminRodenberg BenjaminRodenberg merged commit a0c7a32 into precice:develop Apr 12, 2019
@Dominanz Dominanz deleted the PR_draft_constness_write_functions branch April 12, 2019 15:33
@Dominanz Dominanz restored the PR_draft_constness_write_functions branch April 12, 2019 17:10
@Dominanz
Copy link
Copy Markdown
Contributor Author

Well... I am embarrassed that I didn't notice this earlier, but I just realized that only the implementation (/src/precice/impl/SolverInterfaceImpl.), the request manager (/src/precice/impl/RequestManager.) and the c bindings were changed in the merge. The /src/precice/SolverInterface itself remained unchanged, rendering the changes useless.

I am pretty confused because I had thought of these files and was convinced that I had modified them too, but I might well have simply forgotten that.

Whatever... should I open a new pull request for that? Or is it, somehow, possible to reuse this one?

@BenjaminRodenberg
Copy link
Copy Markdown
Contributor

Well... I am embarrassed that I didn't notice this earlier, but I just realized that only the implementation (/src/precice/impl/SolverInterfaceImpl.), the request manager (/src/precice/impl/RequestManager.) and the c bindings were changed in the merge. The /src/precice/SolverInterface itself remained unchanged, rendering the changes useless.

No reason to be embarrassed. We also didn't notice it in the review of your PR ;)

I am pretty confused because I had thought of these files and was convinced that I had modified them too, but I might well have simply forgotten that.

I am not sure whether this change was already missing in your original PR or whether @fsimonis and I removed the changes in src/precice/SolverInterface in the rebase before merging the merge. In case we deleted the changes in src/precice/SolverInterface, I am sorry for the confusion.

Whatever... should I open a new pull request for that? Or is it, somehow, possible to reuse this one?

As far as I know, we cannot reuse this PR. Just open a new one. You can link to this PR by referring to #348 and possibly your comment #348 (comment) in the body of the new PR.

@BenjaminRodenberg
Copy link
Copy Markdown
Contributor

See #357

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.

3 participants