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

Introduce ParticleAccessor::set_properties() taking a Tensor. #12684

Merged
merged 3 commits into from
Aug 25, 2021

Conversation

bangerth
Copy link
Member

The resolution in #12624 was that we don't want to allow ArrayView pointing to a Tensor object. This removes one of two uses of this by providing a different overload when setting tensors as properties for particles.

/rebuild

@bangerth
Copy link
Member Author

@gassmoeller -- FYI. But there are no places in ASPECT where we use the ArrayView version of set_properties().

Copy link
Member

@masterleinad masterleinad left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Comment on lines +713 to +720
// A Tensor object is not an array, so we cannot just create an
// ArrayView object for it. Rather, copy the data into a true
// array and make the ArrayView from that.
double array[dim];
for (unsigned int d = 0; d < dim; ++d)
array[d] = new_properties[d];

set_properties(make_array_view(array));
Copy link
Member

@drwells drwells Aug 20, 2021

Choose a reason for hiding this comment

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

This is where I would like to do

Suggested change
// A Tensor object is not an array, so we cannot just create an
// ArrayView object for it. Rather, copy the data into a true
// array and make the ArrayView from that.
double array[dim];
for (unsigned int d = 0; d < dim; ++d)
array[d] = new_properties[d];
set_properties(make_array_view(array));
set_properties(make_array_view(new_properties.to_array()));

as mentioned in the issue.

In fact, if the ArrayView constructor is not explicit, we can even skip make_array_view().

Copy link
Member

Choose a reason for hiding this comment

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

Come to think of it - if we do implement to_array() then we don't need this extra function at all, so we should just implement to_array() :)

Copy link
Member Author

Choose a reason for hiding this comment

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

The constructor is not explicit:

  template <std::size_t N>
  ArrayView(value_type (&array)[N]);

I can't quite figure out from your comments where you are asking me to make changes?

Copy link
Member

Choose a reason for hiding this comment

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

I'll put up a PR with what I want in it.

Copy link
Member Author

Choose a reason for hiding this comment

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

How about we merge this now and then do what you suggest as a follow-up? It doesn't become easier/less work for anyone when we try to interleave patches from different people :-)

Copy link
Member

Choose a reason for hiding this comment

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

I meant to respond to this, sorry!

Yes, lets just merge this as-is and I'll deal with what I would like to happen next in my own PR.

@drwells
Copy link
Member

drwells commented Aug 25, 2021

@bangerth can you rebase?

@bangerth
Copy link
Member Author

Rebased.

@drwells drwells merged commit db4a021 into dealii:master Aug 25, 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