15#ifndef dealii_portable_fe_evaluation_h
16#define dealii_portable_fe_evaluation_h
27#include <deal.II/matrix_free/portable_matrix_free.templates.h>
30#include <Kokkos_Core.hpp>
64 int n_q_points_1d = fe_degree + 1,
65 int n_components_ = 1,
66 typename Number =
double>
73 using value_type = std::conditional_t<(n_components_ == 1),
83 std::conditional_t<n_components_ == dim,
160 evaluate(const
bool evaluate_val, const
bool evaluate_grad);
181 integrate(const
bool integrate_val, const
bool integrate_grad);
237 template <typename Functor>
274 Kokkos::parallel_for(
277 for (unsigned int c = 0; c < n_components_; ++c)
278 shared_data->values(i, c) =
279 src[data->local_to_global(cell_id, i + tensor_dofs_per_cell * c)];
283 for (
unsigned int c = 0; c < n_components_; ++c)
285 internal::resolve_hanging_nodes<dim, fe_degree, false, Number>(
287 data->constraint_weights,
289 Kokkos::subview(
shared_data->values, Kokkos::ALL, c));
304 for (
unsigned int c = 0; c < n_components_; ++c)
306 internal::resolve_hanging_nodes<dim, fe_degree, true, Number>(
308 data->constraint_weights,
310 Kokkos::subview(
shared_data->values, Kokkos::ALL, c));
313 if (
data->use_coloring)
315 Kokkos::parallel_for(
318 for (unsigned int c = 0; c < n_components_; ++c)
319 dst[data->local_to_global(cell_id,
320 i + tensor_dofs_per_cell * c)] +=
321 shared_data->values(i, c);
326 Kokkos::parallel_for(
329 for (unsigned int c = 0; c < n_components_; ++c)
330 Kokkos::atomic_add(&dst[data->local_to_global(
331 cell_id, i + tensor_dofs_per_cell * c)],
332 shared_data->values(i, c));
358 data->shape_gradients,
359 data->co_shape_gradients);
361 for (
unsigned int c = 0; c < n_components_; ++c)
366 evaluator_tensor_product.evaluate_values_and_gradients(
367 Kokkos::subview(
shared_data->values, Kokkos::ALL, c),
369 shared_data->gradients, Kokkos::ALL, Kokkos::ALL, c));
374 evaluator_tensor_product.evaluate_gradients(
375 Kokkos::subview(
shared_data->values, Kokkos::ALL, c),
377 shared_data->gradients, Kokkos::ALL, Kokkos::ALL, c));
382 evaluator_tensor_product.evaluate_values(
383 Kokkos::subview(
shared_data->values, Kokkos::ALL, c));
398 const bool evaluate_val,
399 const bool evaluate_grad)
425 data->shape_gradients,
426 data->co_shape_gradients);
429 for (
unsigned int c = 0; c < n_components_; ++c)
434 evaluator_tensor_product.integrate_values_and_gradients(
435 Kokkos::subview(
shared_data->values, Kokkos::ALL, c),
437 shared_data->gradients, Kokkos::ALL, Kokkos::ALL, c));
441 evaluator_tensor_product.integrate_values(
442 Kokkos::subview(
shared_data->values, Kokkos::ALL, c));
447 evaluator_tensor_product.template integrate_gradients<false>(
448 Kokkos::subview(
shared_data->values, Kokkos::ALL, c),
450 shared_data->gradients, Kokkos::ALL, Kokkos::ALL, c));
465 const bool integrate_val,
466 const bool integrate_grad)
488 if constexpr (n_components_ == 1)
516 if constexpr (n_components_ == 1)
540 if constexpr (n_components_ == 1)
563 if constexpr (n_components_ == 1)
591 if constexpr (n_components_ == 1)
593 for (
unsigned int d_1 = 0; d_1 < dim; ++d_1)
596 for (
unsigned int d_2 = 0; d_2 < dim; ++d_2)
597 tmp +=
data->inv_jacobian(
cell_id, q_point, d_2, d_1) *
605 for (
unsigned int d_1 = 0; d_1 < dim; ++d_1)
608 for (
unsigned int d_2 = 0; d_2 < dim; ++d_2)
609 tmp +=
data->inv_jacobian(
cell_id, q_point, d_2, d_1) *
629 if constexpr (n_components_ == 1)
631 for (
unsigned int d_1 = 0; d_1 < dim; ++d_1)
634 for (
unsigned int d_2 = 0; d_2 < dim; ++d_2)
636 data->inv_jacobian(
cell_id, q_point, d_1, d_2) * grad_in[d_2];
644 for (
unsigned int d_1 = 0; d_1 < dim; ++d_1)
647 for (
unsigned int d_2 = 0; d_2 < dim; ++d_2)
648 tmp +=
data->inv_jacobian(
cell_id, q_point, d_1, d_2) *
663 template <
typename Functor>
668 Kokkos::parallel_for(Kokkos::TeamThreadRange(
shared_data->team_member,
670 [&](
const int &i) { func(this, i); });
682 constexpr unsigned int
static constexpr unsigned int n_q_points
SharedData< dim, Number > * shared_data
void integrate(const EvaluationFlags::EvaluationFlags integration_flag)
static constexpr unsigned int dimension
static constexpr unsigned int n_components
value_type get_value(int q_point) const
static constexpr unsigned int tensor_dofs_per_cell
value_type get_dof_value(int q_point) const
std::conditional_t< n_components_==1, Tensor< 1, dim, Number >, std::conditional_t< n_components_==dim, Tensor< 2, dim, Number >, Tensor< 1, n_components_, Tensor< 1, dim, Number > > > > gradient_type
std::conditional_t<(n_components_==1), Number, Tensor< 1, n_components_, Number > > value_type
void evaluate(const EvaluationFlags::EvaluationFlags evaluate_flag)
void distribute_local_to_global(Number *dst) const
gradient_type get_gradient(int q_point) const
typename MatrixFree< dim, Number >::Data data_type
void read_dof_values(const Number *src)
void submit_dof_value(const value_type &val_in, int q_point)
void submit_value(const value_type &val_in, int q_point)
void submit_gradient(const gradient_type &grad_in, int q_point)
void apply_for_each_quad_point(const Functor &func)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_DEPRECATED_WITH_COMMENT(comment)
#define DEAL_II_NAMESPACE_CLOSE
The namespace for the EvaluationFlags enum.
EvaluationFlags
The EvaluationFlags enum.
constexpr T pow(const T base, const int iexp)
#define DEAL_II_HOST_DEVICE