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
Specialized binary functions for Tensor<1, 1, Number> and Number #11956
Comments
I don't particularly like this kind of change. My objection is that these things represent different concepts. A So, in summary, I'm not in favor. |
@bangerth I agree with your comments. But, I am afraid the current interface of Let me quickly show the some specializations of the functions
and
Now lets assume that want to compute There are other instances where this might happen. Together with @mschreter, we used to have a free function that converts a double to a tensor:
which had to be called explicitly (and made dimension-independent matrix-free code hard to read). This is why we introduced the specializations (proposed in the description of this PR) in our user code; since we like it there, we would like to make part of the library. |
Now lets assume that want to compute |scalar_product(FEEvaluation<dim,
fe_degree, n_q_points_1d, dim>::get_value(), FEEvaluation<dim, fe_degree,
n_q_points_1d, 1>::get_gradient())| (as in the context of scalar transport
problems). This will work for 2D and 3D, since the return type of both
functions is |Tensor<1, dim>|. But for 1D, we get the case that one is
returning a |double| and the other function a |Tensor<1, 1>|.
There lies your problem. Let the 1d function return |Tensor<1,1>|.
I continue to think that softening semantic notions for the purpose of
convenience is the wrong approach. I get that the code you have to write for
dimension-independent programming is cumbersome, but I think you are
addressing the problem at the wrong end. If the MatrixFree framework is giving
you the wrong/inconvenient types, then change things at that end rather than
in the downstream places. If that happens to require incompatible changes,
then so be it -- better an incompatibility now than inconsistent semantics
forever.
|
Let's close this PR. 10 years ago, decisions were made to make |
@mschreter and I would like to propose following binary function specializations to be able operate on
dealii::Tensor<1, 1, dealii::VectorizedArray<Number, N>>
anddealii::VectorizedArray<Number, N>
easily:We use such specializations in the context of dim-independent
MatrixFree
programming when we also want to enable algorithms in 1D without needing to write the specializations (see: https://github.com/MeltPoolDG/MeltPoolDG/pull/98). We are not sure if this should be part of deal.II and if yes what the appropriate place is:vectoriazation.h
ortensor.h
or somewhere else!Note: I guess the above discussion is also true for
dealii::Tensor<1, 1, Number>
andNumber
withNumber
beingdouble/float
.The text was updated successfully, but these errors were encountered: