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
Why does FEPointEvaluation::EvaluatorTypeTraits use Number and not Tensor<0, dim, Number>? #13517
Comments
I've run into a similar problem and I had to write my own conversion stubs: std::vector<Tensor<1, 1>>
convert(std::vector<double> &input)
{
std::vector<Tensor<1, 1>> result(input.size());
for (std::size_t i = 0; i < input.size(); ++i)
result[i][0] = input[i];
return result;
}
template <int dim>
std::vector<Tensor<1, dim>>
convert(std::vector<Tensor<1, dim>> &input)
{
return std::move(input);
}
} // namespace
// ...
{
using VectorType = LinearAlgebra::distributed::Vector<double>;
auto result =
VectorTools::point_values<n_components, dim, spacedim, VectorType>(
*mapping,
*dof_handler,
vector,
evaluation_points,
remote_point_evaluation);
return convert(result);
} which is not ideal. If we didn't have the specialization, though, it would be That being said - we should try to work out if there is a way to make this generic or at least publish a workaround in the documentation. |
I am not the main author of |
Indeed, the original reason is that this infrastructure imitates what gets done in
FEValues for the scalar case dealii/include/deal.II/fe/fe_values.h Line 154 in 5d4eff2
dealii/include/deal.II/fe/fe_values.h Line 682 in 5d4eff2
The reason behind these different choices is that it is more natural to work with scalar types (e.g. a double variable) than with tensors, especially when doing somewhat more complicated mathematical formulas. Performance is not the biggest concern, as most compilers optimize |
If one does not want to switch to Tensor inside the calculations for performance reasons, would it be an option to partially specialize |
When using
VectorTools::point_values()
, it would be nice to write application code with the return typestd::vector<Tensor<rank, dim, Number>>
, whererank
is a parameter of the application code. However, this does not seem to be possible. I think the reason behind is line 131 in https://www.dealii.org/developer/doxygen/deal.II/fe__point__evaluation_8h_source.html, which readsusing value_type = Number;
and not
using value_type = Tensor<0, dim, Number>;
Wouldn't it be more consistent to write everything with
Tensor
?The text was updated successfully, but these errors were encountered: