Skip to content

Why not const for Coefficient member functions? #4171

Answered by v-dobrev
j-signorelli asked this question in Q&A
Discussion options

You must be logged in to vote

One perspective: using a Coefficient may require calling its SetTime() method which does alter the Coefficient state, so time-dependent Coefficients need to be passed as non-const.

That said, I think that this interface dates back to the first MFEM release when the const-ness of methods was not considered thoroughly.

It is probably possible to change these methods to be const -- I'm not sure if this is a simple change local to the coefficient classes or if it needs to propagate to other classes too. If you feel strongly about it and you want to explore the implication of a such change, feel free to try it, and propose a PR if the changes are not too pervasive. The main thing will be to en…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@j-signorelli
Comment options

j-signorelli Mar 5, 2024
Collaborator Author

@paul-hilscher
Comment options

@j-signorelli
Comment options

j-signorelli Mar 15, 2024
Collaborator Author

Answer selected by j-signorelli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants