4#ifndef lethe_tensors_and_points_dimension_manipulation_h
5#define lethe_tensors_and_points_dimension_manipulation_h
7#include <deal.II/base/point.h>
8#include <deal.II/base/tensor.h>
26 Tensor<1, 3> tensor_3d;
27 tensor_3d[0] = tensor[0];
28 tensor_3d[1] = tensor[1];
29 if constexpr (dim > 2)
30 tensor_3d[2] = tensor[2];
32 if constexpr (dim == 2)
52 Tensor<1, 2> tensor_2d;
53 tensor_2d[0] = tensor[0];
54 tensor_2d[1] = tensor[1];
72 point_3d[0] = point[0];
73 point_3d[1] = point[1];
74 if constexpr (dim > 2)
75 point_3d[2] = point[2];
76 if constexpr (dim == 2)
97 point_2d[0] = point[0];
98 point_2d[1] = point[1];
129template <
int dim,
typename Number>
130DEAL_II_ALWAYS_INLINE
inline Tensor<1, dim, Number>
132 const Tensor<1, dim> &normal)
134 static_assert(dim == 2 || dim == 3,
135 "The tangential component is only defined in 2D and 3D.");
136 if constexpr (dim == 2)
139 const Tensor<1, dim> tangent = cross_product_2d(normal);
140 return (tensor * tangent) * tangent;
143 return cross_product_3d(normal, cross_product_3d(tensor, normal));
DEAL_II_ALWAYS_INLINE Tensor< 1, dim, Number > tangential_component(const Tensor< 1, dim, Number > &tensor, const Tensor< 1, dim > &normal)
Compute the tangential component of a vector on a surface defined by its unit normal vector,...
Tensor< 1, 3 > tensor_nd_to_3d(const Tensor< 1, dim > &tensor)
Point< 2 > point_nd_to_2d(const Point< dim > &point)
Tensor< 1, 2 > tensor_nd_to_2d(const Tensor< 1, dim > &tensor)
Point< 3 > point_nd_to_3d(const Point< dim > &point)