Skip to content
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

Make Tensor::unroll() work with iterators. #12692

Merged
merged 2 commits into from Sep 9, 2021
Merged

Conversation

drwells
Copy link
Member

@drwells drwells commented Aug 20, 2021

Alternative to #12684 and #12685. Conflicts with #12685 and #12691.

If we want to get rid of make_array_view(Tensor) then we should offer a different way to convert the Tensor into a contiguous array. This PR adds a new function Tensor::to_array() that does exactly that so that we do not need to do it manually whenever the need arises. This PR adds Tensor::unroll(begin, end) which populates some output structure with tensor values.

A related change is that Tensor has a constructor which takes an ArrayView as an argument, but we can only forward-declare ArrayView in that file due to the opposite-order dependency in array_view.h (in make_array_view(Tensor &)). I addressed that by moving the make_array_view() functions into the other headers.

Copy link
Member

@bangerth bangerth left a comment

Choose a reason for hiding this comment

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

This is fine by me, but I would prefer if you didn't move the make_array_view() functions that related to tensors -- these need to be deprecated anyway, so they might as well stay where they currently are.

include/deal.II/base/array_view.h Outdated Show resolved Hide resolved
include/deal.II/base/mpi.templates.h Outdated Show resolved Hide resolved
include/deal.II/base/tensor.h Outdated Show resolved Hide resolved
include/deal.II/base/tensor.h Outdated Show resolved Hide resolved
include/deal.II/base/tensor.h Outdated Show resolved Hide resolved
@drwells
Copy link
Member Author

drwells commented Aug 26, 2021

Returning an array isn't going to work - MSVC cannot handle n_independent_components being used as a class member.

Instead I implemented a new version of unroll() that works with iterators instead of just Vector - the old function is now deprecated.

@drwells drwells changed the title Add Tensor::to_array(). Make Tensor::unroll() work with iterators. Aug 26, 2021
Copy link
Member

@bangerth bangerth left a comment

Choose a reason for hiding this comment

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

Are you still missing the ArrayView constructor for tensors with rank>1?

include/deal.II/base/tensor.h Outdated Show resolved Hide resolved
include/deal.II/base/tensor.h Show resolved Hide resolved
include/deal.II/base/tensor.h Show resolved Hide resolved
include/deal.II/base/tensor.h Outdated Show resolved Hide resolved
include/deal.II/base/tensor.h Outdated Show resolved Hide resolved
include/deal.II/base/tensor.h Outdated Show resolved Hide resolved
@drwells
Copy link
Member Author

drwells commented Aug 28, 2021

Are you still missing the ArrayView constructor for tensors with rank>1?

Do you mean rank > 0? That was already there - I added the rank = 0 version. I don't need it any more for this PR so I think I will drop the commit anyway.

@bangerth
Copy link
Member

bangerth commented Sep 7, 2021

OK with me. The naming is not important.

/rebuild

@bangerth
Copy link
Member

bangerth commented Sep 7, 2021

The CI check failed with an internal compiler error. I suspect it has nothing to do with your patch, but just to be on the safe side, could you rebase and push to start the check again?

This makes the code applicable for more linear data structures than just Vector.
@kronbichler kronbichler merged commit 70d0001 into dealii:master Sep 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants