16#ifndef dealii_portable_matrix_free_h
17#define dealii_portable_matrix_free_h
41#include <Kokkos_Array.hpp>
42#include <Kokkos_Core.hpp>
51 namespace MatrixFreeFunctions
63 template <
int dim,
typename Number>
66 template <
int dim,
typename Number>
85 template <
typename Number>
87 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>;
95 template <
typename Number>
124 template <
typename MemorySpace>
130 ExcMessage(
"Portable::MatrixFree is configured with " +
132 " but you are passing a BlockVector with " +
135 for (
int b = 0; b < src.
n_blocks(); ++b)
137 src.
block(b).locally_owned_size());
197 template <
int dim,
typename Number =
double>
223#ifndef DEAL_II_MPI_WITH_DEVICE_SUPPORT
227 "Overlapping communication and computation requires device-aware MPI."));
233 "Overlapping communication and coloring are incompatible options. Only one of them can be enabled."));
270 Kokkos::View<point_type **, MemorySpace::Default::kokkos_space>
q_points;
283 Kokkos::View<Number **[dim][dim], MemorySpace::Default::kokkos_space>
289 Kokkos::View<Number **, MemorySpace::Default::kokkos_space>
JxW;
301 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
shape_values;
306 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
312 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
318 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
371 MemorySpace::Default::kokkos_space::execution_space>::member_type;
389 const unsigned int n_q_points,
390 const unsigned int q_point)
const
405 const unsigned int q_point)
const
432 template <
typename IteratorFiltersType>
438 const IteratorFiltersType &iterator_filter,
482 template <
typename Functor,
typename VectorType>
485 const VectorType &src,
486 VectorType &dst)
const;
501 template <
typename Functor>
509 template <
typename VectorType>
518 template <
typename VectorType>
527 template <
typename MemorySpaceType>
535 const std::vector<std::vector<CellFilter>> &
548 const std::shared_ptr<const Utilities::MPI::Partitioner> &
567 template <
typename IteratorFiltersType>
573 const IteratorFiltersType &iterator_filter,
574 const std::shared_ptr<const MPI_Comm> &
comm,
581 template <
typename Functor,
typename VectorType>
584 const VectorType &src,
585 VectorType &dst)
const;
591 template <
typename Functor>
603 template <
typename Functor>
692 std::vector<Kokkos::View<point_type **, MemorySpace::Default::kokkos_space>>
708 Kokkos::View<Number **[dim][dim], MemorySpace::Default::kokkos_space>>
715 std::vector<Kokkos::View<Number **, MemorySpace::Default::kokkos_space>>
721 Kokkos::View<types::global_dof_index *, MemorySpace::Default::kokkos_space>
735 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
shape_values;
745 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
751 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
780 std::vector<std::vector<CellFilter>>
graph;
782 friend class internal::ReinitHelper<dim, Number>;
787 template <
int dim,
typename Number>
792 MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space,
793 Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
796 MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space,
797 Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
800 MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space,
801 Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
834 template <
int dim,
typename Number>
840 typename Kokkos::View<Point<dim, Number> **,
855 typename Kokkos::View<Number **[dim][dim],
862 typename Kokkos::View<Number **,
883 typename Kokkos::View<
900 const unsigned int n_q_points,
901 const unsigned int q_point)
const
913 const unsigned int q_point)
const
927 template <
int dim,
typename Number>
928 DataHost<dim, Number>
930 const typename ::Portable::MatrixFree<dim, Number>::PrecomputedData
943 data_host.
q_points = Kokkos::create_mirror(
data.q_points);
958 data_host.
JxW = Kokkos::create_mirror(
data.JxW);
959 Kokkos::deep_copy(data_host.
JxW,
data.JxW);
973 template <
int dim,
typename Number>
974 inline const std::vector<std::vector<
983 template <
int dim,
typename Number>
984 inline const std::shared_ptr<const Utilities::MPI::Partitioner> &
992 template <
int dim,
typename Number>
unsigned int n_blocks() const
BlockType & block(const unsigned int i)
Abstract base class for mapping classes.
DeviceBlockVector(const DeviceBlockVector &other)=default
Kokkos::Array< DeviceVector< Number >, n_max_dof_handlers > blocks
const DeviceVector< Number > & block(unsigned int index) const
DeviceBlockVector(const DeviceVector< Number > &src)
DeviceVector< Number > & block(unsigned int index)
DeviceBlockVector(const LinearAlgebra::distributed::BlockVector< Number, MemorySpace > &src)
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 distributed_cell_loop(const Functor &func, const LinearAlgebra::distributed::BlockVector< Number, MemorySpace::Default > &src, LinearAlgebra::distributed::BlockVector< Number, MemorySpace::Default > &dst) const
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)
#define AssertIndexRange(index, range)
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
constexpr unsigned int n_max_dof_handlers
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > DeviceVector
std::string to_string(const number value, const unsigned int digits=numbers::invalid_unsigned_int)
::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
const unsigned int n_dofhandler
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