16#ifndef dealii_cuda_fe_evaluation_h
17#define dealii_cuda_fe_evaluation_h
30#include <deal.II/matrix_free/cuda_matrix_free.templates.h>
33#include <Kokkos_Core.hpp>
69 int n_q_points_1d = fe_degree + 1,
70 int n_components_ = 1,
71 typename Number =
double>
146 evaluate(
const bool evaluate_val,
const bool evaluate_grad);
156 integrate(
const bool integrate_val,
const bool integrate_grad);
212 template <
typename Functor>
233 , shared_data(shdata)
234 , cell_id(shared_data->team_member.league_rank())
248 static_assert(n_components_ == 1,
"This function only supports FE with one \
251 Kokkos::parallel_for(Kokkos::TeamThreadRange(shared_data->team_member,
254 shared_data->values(i) =
255 src[data->local_to_global(cell_id, i)];
257 shared_data->team_member.team_barrier();
259 internal::resolve_hanging_nodes<dim, fe_degree, false>(
260 shared_data->team_member,
261 data->constraint_weights,
262 data->constraint_mask(cell_id),
263 shared_data->values);
277 static_assert(n_components_ == 1,
"This function only supports FE with one \
280 internal::resolve_hanging_nodes<dim, fe_degree, true>(
281 shared_data->team_member,
282 data->constraint_weights,
283 data->constraint_mask(cell_id),
284 shared_data->values);
286 if (data->use_coloring)
288 Kokkos::parallel_for(Kokkos::TeamThreadRange(shared_data->team_member,
291 dst[data->local_to_global(cell_id, i)] +=
292 shared_data->values(i);
297 Kokkos::parallel_for(
298 Kokkos::TeamThreadRange(shared_data->team_member, n_q_points),
300 Kokkos::atomic_add(&dst[data->local_to_global(cell_id, i)],
301 shared_data->values(i));
315 const bool evaluate_val,
316 const bool evaluate_grad)
326 evaluator_tensor_product(shared_data->team_member,
328 data->shape_gradients,
329 data->co_shape_gradients);
330 if (evaluate_val ==
true && evaluate_grad ==
true)
332 evaluator_tensor_product.value_and_gradient_at_quad_pts(
333 shared_data->values, shared_data->gradients);
334 shared_data->team_member.team_barrier();
336 else if (evaluate_grad ==
true)
338 evaluator_tensor_product.gradient_at_quad_pts(shared_data->values,
339 shared_data->gradients);
340 shared_data->team_member.team_barrier();
342 else if (evaluate_val ==
true)
344 evaluator_tensor_product.value_at_quad_pts(shared_data->values);
345 shared_data->team_member.team_barrier();
358 const bool integrate_val,
359 const bool integrate_grad)
367 evaluator_tensor_product(shared_data->team_member,
369 data->shape_gradients,
370 data->co_shape_gradients);
371 if (integrate_val ==
true && integrate_grad ==
true)
373 evaluator_tensor_product.integrate_value_and_gradient(
374 shared_data->values, shared_data->gradients);
376 else if (integrate_val ==
true)
378 evaluator_tensor_product.integrate_value(shared_data->values);
379 shared_data->team_member.team_barrier();
381 else if (integrate_grad ==
true)
383 evaluator_tensor_product.template integrate_gradient<false>(
384 shared_data->values, shared_data->gradients);
385 shared_data->team_member.team_barrier();
404 return shared_data->values(q_point);
422 return shared_data->values(q_point);
436 shared_data->values(q_point) = val_in * data->JxW(cell_id, q_point);
450 shared_data->values(q_point) = val_in;
464 Number>::gradient_type
468 static_assert(n_components_ == 1,
"This function only supports FE with one \
472 for (
unsigned int d_1 = 0; d_1 < dim; ++d_1)
475 for (
unsigned int d_2 = 0; d_2 < dim; ++d_2)
476 tmp += data->inv_jacobian(cell_id, q_point, d_2, d_1) *
477 shared_data->gradients(q_point, d_2);
495 for (
unsigned int d_1 = 0; d_1 < dim; ++d_1)
498 for (
unsigned int d_2 = 0; d_2 < dim; ++d_2)
499 tmp += data->inv_jacobian(cell_id, q_point, d_1, d_2) * grad_in[d_2];
500 shared_data->gradients(q_point, d_1) =
501 tmp * data->JxW(cell_id, q_point);
512 template <
typename Functor>
517 Kokkos::parallel_for(Kokkos::TeamThreadRange(shared_data->team_member,
519 [&](
const int &i) { func(this, i); });
520 shared_data->team_member.team_barrier();
531 constexpr unsigned int
static constexpr unsigned int tensor_dofs_per_cell
void integrate(const bool integrate_val, const bool integrate_grad)
value_type get_value(int q_point) const
value_type get_dof_value(int q_point) const
SharedData< dim, Number > * shared_data
void distribute_local_to_global(Number *dst) const
static constexpr unsigned int dimension
void evaluate(const bool evaluate_val, const bool evaluate_grad)
static constexpr unsigned int n_q_points
gradient_type get_gradient(int q_point) const
static constexpr unsigned int n_components
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)
friend class FEEvaluation
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
constexpr T pow(const T base, const int iexp)
#define DEAL_II_HOST_DEVICE