Thanks for the fast reply, Wolfgang!

I have done some preliminary benchmarking of the code and indeed this 
operation is not anywhere close to a bottleneck--I was asking primarily out 
of curiosity, as I'm refactoring the code and was considering what return 
type of an abstract representation of the flux makes sense in terms of 
class design. In light of your answer it seems that a view-based design 
doesn't make a lot of sense, and I might as well return a Tensor object 
directly, as that's the easiest for user code to work with.

Best,
Corbin

On Monday, May 1, 2023 at 7:20:05 PM UTC-4 Wolfgang Bangerth wrote:

> On 5/1/23 16:15, Corbin Foucart wrote:
> > 
> > Is there an developer-intended way to view a Vector<double> object with 
> > dim entries as a Tensor<1, dim> object for ease of multiplication with 
> > other Tensor<1, dim> instances such as normal vectors?
> > I can do something like:
> > 
> > // dim = 3
> > Vector<double> vec({4,5,6});
> > ArrayView<double> view(&a[0], 3);
> > Tensor<1, 3, double> tensor(view);
> > 
> > but from the documentation this seems to make a copy, and I wondered if 
> > there was a deal.ii way to "view" the Vector<double> as a Tensor object. 
> > This operation is the result of a numerical flux computation and is 
> > called many times during assembly.
>
> Correct, this makes a copy. There really isn't a different way (in 
> deal.II): Tensor objects own their data, they are not "views", and so 
> they cannot avoid the copy. Of course, if you don't want to do the copy, 
> then you can always write out the tensor operation you are interested in 
> from the original vector elements by hand.
>
> That said: It would greatly surprise me if the copying of elements is 
> limiting the speed of your program. Have you benchmarked this? Are you 
> sure that you aren't trying to optimize a part of the program that 
> doesn't actually need to be optimized?
>
> Best
> W.
>
>
> -- 
> ------------------------------------------------------------------------
> Wolfgang Bangerth email: [email protected]
> www: http://www.math.colostate.edu/~bangerth/
>

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/f0ef3b0e-34c0-45bf-aaff-0f0b0692266fn%40googlegroups.com.

Reply via email to