16#ifndef dealii_portable_matrix_free_h
17#define dealii_portable_matrix_free_h
40#include <Kokkos_Core.hpp>
49 namespace MatrixFreeFunctions
61 template <
int dim,
typename Number>
64 template <
int dim,
typename Number>
92 template <
int dim,
typename Number =
double>
118#ifndef DEAL_II_MPI_WITH_DEVICE_SUPPORT
122 "Overlapping communication and computation requires device-aware MPI."));
128 "Overlapping communication and coloring are incompatible options. Only one of them can be enabled."));
165 Kokkos::View<point_type **, MemorySpace::Default::kokkos_space>
q_points;
178 Kokkos::View<Number **[dim][dim], MemorySpace::Default::kokkos_space>
184 Kokkos::View<Number **, MemorySpace::Default::kokkos_space>
JxW;
196 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
shape_values;
201 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
207 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
213 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
266 MemorySpace::Default::kokkos_space::execution_space>::member_type;
283 const unsigned int n_q_points,
284 const unsigned int q_point)
const
299 const unsigned int q_point)
const
326 template <
typename IteratorFiltersType>
332 const IteratorFiltersType &iterator_filter,
376 template <
typename Functor,
typename VectorType>
379 const VectorType &src,
380 VectorType &dst)
const;
395 template <
typename Functor>
403 template <
typename VectorType>
412 template <
typename VectorType>
421 template <
typename MemorySpaceType>
429 const std::vector<std::vector<CellFilter>> &
442 const std::shared_ptr<const Utilities::MPI::Partitioner> &
461 template <
typename IteratorFiltersType>
467 const IteratorFiltersType &iterator_filter,
468 const std::shared_ptr<const MPI_Comm> &
comm,
475 template <
typename Functor,
typename VectorType>
478 const VectorType &src,
479 VectorType &dst)
const;
485 template <
typename Functor>
573 std::vector<Kokkos::View<point_type **, MemorySpace::Default::kokkos_space>>
589 Kokkos::View<Number **[dim][dim], MemorySpace::Default::kokkos_space>>
596 std::vector<Kokkos::View<Number **, MemorySpace::Default::kokkos_space>>
602 Kokkos::View<types::global_dof_index *, MemorySpace::Default::kokkos_space>
616 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
shape_values;
626 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
632 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
661 std::vector<std::vector<CellFilter>>
graph;
663 friend class internal::ReinitHelper<dim, Number>;
668 template <
int dim,
typename Number>
673 MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space,
674 Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
677 MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space,
678 Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
681 MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space,
682 Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
715 template <
int dim,
typename Number>
721 typename Kokkos::View<Point<dim, Number> **,
736 typename Kokkos::View<Number **[dim][dim],
743 typename Kokkos::View<Number **,
764 typename Kokkos::View<
781 const unsigned int n_q_points,
782 const unsigned int q_point)
const
794 const unsigned int q_point)
const
808 template <
int dim,
typename Number>
809 DataHost<dim, Number>
811 const typename ::Portable::MatrixFree<dim, Number>::PrecomputedData
824 data_host.
q_points = Kokkos::create_mirror(
data.q_points);
839 data_host.
JxW = Kokkos::create_mirror(
data.JxW);
840 Kokkos::deep_copy(data_host.
JxW,
data.JxW);
854 template <
int dim,
typename Number>
855 inline const std::vector<std::vector<
864 template <
int dim,
typename Number>
865 inline const std::shared_ptr<const Utilities::MPI::Partitioner> &
873 template <
int dim,
typename Number>
Abstract base class for mapping classes.
const std::vector< std::vector< CellFilter > > & get_colored_graph() const
std::vector< std::vector< CellFilter > > graph
void reinit(const DoFHandler< dim > &dof_handler, const AffineConstraints< Number > &constraints, const Quadrature< 1 > &quad, const AdditionalData &additional_data=AdditionalData())
void internal_reinit(const Mapping< dim > &mapping, const DoFHandler< dim > &dof_handler, const AffineConstraints< Number > &constraints, const Quadrature< 1 > &quad, const IteratorFiltersType &iterator_filter, const std::shared_ptr< const MPI_Comm > &comm, const AdditionalData additional_data)
unsigned int n_components
std::vector< Kokkos::View<::internal::MatrixFreeFunctions::ConstraintKinds *, MemorySpace::Default::kokkos_space > > constraint_mask
unsigned int padding_length
unsigned int get_padding_length() const
unsigned int dofs_per_cell
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > constraint_weights
const DoFHandler< dim > * dof_handler
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > shape_gradients
void initialize_dof_vector(LinearAlgebra::distributed::Vector< Number, MemorySpaceType > &vec) const
void reinit(const Mapping< dim > &mapping, const DoFHandler< dim > &dof_handler, const AffineConstraints< Number > &constraints, const Quadrature< 1 > &quad, const IteratorFiltersType &iterator_filter, const AdditionalData &additional_data=AdditionalData())
std::vector< Kokkos::View< Number **[dim][dim], MemorySpace::Default::kokkos_space > > inv_jacobian
PrecomputedData get_data(unsigned int color) const
Kokkos::View< types::global_dof_index *, MemorySpace::Default::kokkos_space > constrained_dofs
std::vector< Kokkos::View< point_type **, MemorySpace::Default::kokkos_space > > q_points
types::global_dof_index n_dofs
unsigned int q_points_per_cell
void distributed_cell_loop(const Functor &func, const LinearAlgebra::distributed::Vector< Number, MemorySpace::Default > &src, LinearAlgebra::distributed::Vector< Number, MemorySpace::Default > &dst) const
std::vector< unsigned int > row_start
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > co_shape_gradients
std::vector< Kokkos::View< types::global_dof_index **, MemorySpace::Default::kokkos_space > > local_to_global
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > shape_values
std::size_t memory_consumption() const
void set_constrained_values(const Number val, VectorType &dst) const
unsigned int scalar_dofs_per_cell
unsigned int n_constrained_dofs
void copy_constrained_values(const VectorType &src, VectorType &dst) const
std::vector< Kokkos::View< Number **, MemorySpace::Default::kokkos_space > > JxW
bool overlap_communication_computation
const DoFHandler< dim > & get_dof_handler() const
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner
void serial_cell_loop(const Functor &func, const VectorType &src, VectorType &dst) const
void evaluate_coefficients(Functor func) const
unsigned int scratch_pad_size
DataHost< dim, Number > copy_mf_data_to_host(const typename::Portable::MatrixFree< dim, Number >::PrecomputedData &data, const UpdateFlags &update_flags)
::internal::MatrixFreeFunctions::ElementType element_type
void reinit(const Mapping< dim > &mapping, const DoFHandler< dim > &dof_handler, const AffineConstraints< Number > &constraints, const Quadrature< 1 > &quad, const AdditionalData &additional_data=AdditionalData())
const std::shared_ptr< const Utilities::MPI::Partitioner > & get_vector_partitioner() const
std::vector< unsigned int > n_cells
void cell_loop(const Functor &func, const VectorType &src, VectorType &dst) const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_HOST_DEVICE
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcNotInitialized()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
@ update_JxW_values
Transformed quadrature weights.
@ update_gradients
Shape function gradients.
@ update_quadrature_points
Transformed quadrature points.
std::vector< index_type > data
::Kokkos::DefaultExecutionSpace::memory_space kokkos_space
Kokkos::View< types::global_dof_index **, MemorySpace::Default::kokkos_space >::HostMirror local_to_global
Kokkos::View< Number **, MemorySpace::Default::kokkos_space >::HostMirror JxW
Point< dim, Number > get_quadrature_point(const unsigned int cell, const unsigned int q_point) const
unsigned int padding_length
Kokkos::View<::internal::MatrixFreeFunctions::ConstraintKinds *, MemorySpace::Default::kokkos_space >::HostMirror constraint_mask
Kokkos::View< Number **[dim][dim], MemorySpace::Default::kokkos_space >::HostMirror inv_jacobian
Kokkos::View< Point< dim, Number > **, MemorySpace::Default::kokkos_space >::HostMirror q_points
unsigned int local_q_point_id(const unsigned int cell, const unsigned int n_q_points, const unsigned int q_point) const
AdditionalData(const UpdateFlags mapping_update_flags=update_gradients|update_JxW_values|update_quadrature_points, const bool use_coloring=false, const bool overlap_communication_computation=false)
bool overlap_communication_computation
UpdateFlags mapping_update_flags
unsigned int local_q_point_id(const unsigned int cell, const unsigned int n_q_points, const unsigned int q_point) const
SharedData< dim, Number > * shared_data
Kokkos::TeamPolicy< MemorySpace::Default::kokkos_space::execution_space >::member_type TeamHandle
const PrecomputedData * precomputed_data
Portable::MatrixFree< dim, Number >::point_type & get_quadrature_point(const unsigned int cell, const unsigned int q_point) const
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > shape_gradients
Kokkos::View< point_type **, MemorySpace::Default::kokkos_space > q_points
unsigned int n_components
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > shape_values
unsigned int padding_length
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > constraint_weights
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > co_shape_gradients
Kokkos::View< Number **[dim][dim], MemorySpace::Default::kokkos_space > inv_jacobian
::internal::MatrixFreeFunctions::ElementType element_type
Kokkos::View< Number **, MemorySpace::Default::kokkos_space > JxW
Kokkos::View<::internal::MatrixFreeFunctions::ConstraintKinds *, MemorySpace::Default::kokkos_space > constraint_mask
Kokkos::View< types::global_dof_index **, MemorySpace::Default::kokkos_space > local_to_global
unsigned int scratch_pad_size
Kokkos::View< Number ***, MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space, Kokkos::MemoryTraits< Kokkos::Unmanaged > > SharedViewGradients
SharedViewScratchPad scratch_pad
Kokkos::View< Number *, MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space, Kokkos::MemoryTraits< Kokkos::Unmanaged > > SharedViewScratchPad
SharedData(const SharedViewValues &values, const SharedViewGradients &gradients, const SharedViewScratchPad &scratch_pad)
Kokkos::View< Number **, MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space, Kokkos::MemoryTraits< Kokkos::Unmanaged > > SharedViewValues
SharedViewGradients gradients