-
Notifications
You must be signed in to change notification settings - Fork 241
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
Use constructor and unroll function for tensors #5641
Conversation
const ArrayView<double> strain_increment_values(&out.reaction_terms[q][0], | ||
Tensor<2,dim>::n_independent_components); | ||
strain_increment.unroll(strain_increment_values.begin(), strain_increment_values.end()); |
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.
wouldn't be simpler to do
const ArrayView<double> strain_increment_values(&out.reaction_terms[q][0], | |
Tensor<2,dim>::n_independent_components); | |
strain_increment.unroll(strain_increment_values.begin(), strain_increment_values.end()); | |
strain_increment.unroll(strain_increment.unroll(&out.reaction_terms[q][0], &out.reaction_terms[q][0]+Tensor<2,dim>::n_independent_components); |
?
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.
I am also not sure why unroll
actually needs an end iterator. The interface would be nicer if it would take a single iterator...
for (unsigned int i = 0; i < Tensor<2,dim>::n_independent_components ; ++i) | ||
out.reaction_terms[q][i] = strain_increment[Tensor<2,dim>::unrolled_to_component_indices(i)]; | ||
const ArrayView<double> strain_increment_values(&out.reaction_terms[q][0], | ||
Tensor<2,dim>::n_independent_components); | ||
strain_increment.unroll(strain_increment_values.begin(), strain_increment_values.end()); |
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.
I don't think this is easier to read. The issue with unroll()
is that it isn't clear which direction the operation goes. Is the tensor putting itself into an array, or is it reading new values from the array? This was clear in the original code.
1bf14cc
to
56597dc
Compare
I updated the PR according to the discussions in #5640. I cannot change the name of |
Something is still broken -- the only thing that works is the spell checker :-) |
56597dc
to
c171057
Compare
I guess that shows how much I tested this after the change :-). Fixed by deleting an unnecessary closing parenthesis. |
It's still not quite right:
|
c171057
to
b4e9f78
Compare
Ok, third time's the charm. Seems to be working now. |
This PR is similar to #5640, except it only uses the existing unroll functions and constructors of the
Tensor
class to simplify the creation and unrolling of tensors from and into compositional fields.