Why not const
for Coefficient
member functions?
#4171
-
Hello, There have been many times while using MFEM that I have wanted to pass a However, I have noticed that all of the member functions of those three base classes (minus some additional ones in I was just wondering if there was any particular reason for this that I am missing? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
One perspective: using a 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 ensure that the changes are backward-compatible. |
Beta Was this translation helpful? Give feedback.
One perspective: using a
Coefficient
may require calling itsSetTime()
method which does alter theCoefficient
state, so time-dependentCoefficient
s 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…