-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify creating and unrolling symmetric tensors #5640
Simplify creating and unrolling symmetric tensors #5640
Conversation
fbc07cc
to
cb65ed1
Compare
I think it is great to simplify and clean up the code based like this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is good. In an ideal world, the two new functions would live inside dealii::SymmetricTensor
. I would gladly accept a patch.
include/aspect/utilities.h
Outdated
for (unsigned int i=0; i < SymmetricTensor<2,dim>::n_independent_components; ++i) | ||
values[i] = tensor[SymmetricTensor<2,dim>::unrolled_to_component_indices(i)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add
Assert (values.size() == ...n_indep_comp, ...)
?
Same for the other function.
5ada0f2
to
b3b9c59
Compare
Ok, I think I addressed all comments. The new versions have more expressive names and use iterators instead of an ArrayView, which makes them more flexible to use with different data containers. Feel free to take a look and when this is merged I can prepare a similar path for deal.II. |
b3b9c59
to
5999d1c
Compare
Something I noticed while reviewing #4370. We have quite a number of places in the code where we create Tensors from arrays or vectors, or unroll Tensors into arrays or vectors. We could simplify this using Tensor constructors, and appropriate
unroll
functions. Such functions are already provided by deal.II for theTensor
class, but they dont exist forSymmetricTensor
. I here created small utility functions forSymmetricTensor
, but of course it would be nice to use a version inside deal.II. Would that be of interest?I can extend this PR to simplify a lot of places in ASPECT with the utility functions, but I first wanted to ask for feedback if the current interface is correct and if this is useful overall.