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>
92 template <
int dim,
typename Number =
double>
118#ifndef DEAL_II_MPI_WITH_DEVICE_SUPPORT
122 "Overlapping communication and computation requires CUDA-aware MPI."));
128 "Overlapping communication and coloring are incompatible options. Only one of them can be enabled."));
164 Kokkos::View<point_type **, MemorySpace::Default::kokkos_space>
q_points;
177 Kokkos::View<Number **[dim][dim], MemorySpace::Default::kokkos_space>
183 Kokkos::View<Number **, MemorySpace::Default::kokkos_space>
JxW;
195 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
shape_values;
200 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
206 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
212 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
242 const unsigned int n_q_points,
243 const unsigned int q_point)
const
255 const unsigned int q_point)
const
282 template <
typename IteratorFiltersType>
288 const IteratorFiltersType &iterator_filter,
335 template <
typename Functor,
typename VectorType>
338 const VectorType &src,
339 VectorType &dst)
const;
356 template <
typename Functor>
364 template <
typename VectorType>
373 template <
typename VectorType>
377#ifdef DEAL_II_WITH_CUDA
400 const std::vector<std::vector<CellFilter>> &
413 const std::shared_ptr<const Utilities::MPI::Partitioner> &
432 template <
typename IteratorFiltersType>
438 const IteratorFiltersType &iterator_filter,
439 const std::shared_ptr<const MPI_Comm> &
comm,
446 template <
typename Functor,
typename VectorType>
449 const VectorType &src,
450 VectorType &dst)
const;
456 template <
typename Functor>
465#ifdef DEAL_II_WITH_CUDA
471 template <
typename Functor>
536 std::vector<Kokkos::View<point_type **, MemorySpace::Default::kokkos_space>>
552 Kokkos::View<Number **[dim][dim], MemorySpace::Default::kokkos_space>>
559 std::vector<Kokkos::View<Number **, MemorySpace::Default::kokkos_space>>
565 Kokkos::View<types::global_dof_index *, MemorySpace::Default::kokkos_space>
579 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
shape_values;
589 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
595 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
624 std::vector<std::vector<CellFilter>>
graph;
626 friend class internal::ReinitHelper<dim, Number>;
631 template <
int dim,
typename Number>
635 MemorySpace::Default::kokkos_space::execution_space>::member_type;
639 MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space,
640 Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
643 MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space,
644 Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
677 template <
int dim,
typename Number>
683 typename Kokkos::View<Point<dim, Number> **,
698 typename Kokkos::View<Number **[dim][dim],
705 typename Kokkos::View<Number **,
726 typename Kokkos::View<
743 const unsigned int n_q_points,
744 const unsigned int q_point)
const
756 const unsigned int q_point)
const
770 template <
int dim,
typename Number>
771 DataHost<dim, Number>
773 const typename ::Portable::MatrixFree<dim, Number>::Data &data,
778 data_host.
n_cells = data.n_cells;
785 data_host.
q_points = Kokkos::create_mirror(data.q_points);
786 Kokkos::deep_copy(data_host.
q_points, data.q_points);
789 data_host.
local_to_global = Kokkos::create_mirror(data.local_to_global);
794 data_host.
inv_jacobian = Kokkos::create_mirror(data.inv_jacobian);
795 Kokkos::deep_copy(data_host.
inv_jacobian, data.inv_jacobian);
800 data_host.
JxW = Kokkos::create_mirror(data.JxW);
801 Kokkos::deep_copy(data_host.
JxW, data.JxW);
804 data_host.
constraint_mask = Kokkos::create_mirror(data.constraint_mask);
815 template <
int dim,
typename Number>
816 inline const std::vector<std::vector<
825 template <
int dim,
typename Number>
826 inline const std::shared_ptr<const Utilities::MPI::Partitioner> &
834 template <
int dim,
typename Number>
Abstract base class for mapping classes.
const std::vector< std::vector< CellFilter > > & get_colored_graph() const
void initialize_dof_vector(LinearAlgebra::CUDAWrappers::Vector< Number > &vec) const
void distributed_cell_loop(const Functor &func, const LinearAlgebra::CUDAWrappers::Vector< Number > &src, LinearAlgebra::CUDAWrappers::Vector< Number > &dst) 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)
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 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
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
void initialize_dof_vector(LinearAlgebra::distributed::Vector< Number, MemorySpace::Default > &vec) const
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
Data get_data(unsigned int color) const
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
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
DataHost< dim, Number > copy_mf_data_to_host(const typename::Portable::MatrixFree< dim, Number >::Data &data, const UpdateFlags &update_flags)
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_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.
#define DEAL_II_HOST_DEVICE
*braid_SplitCommworld & comm
::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
Kokkos::View< Number **, MemorySpace::Default::kokkos_space > JxW
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > constraint_weights
unsigned int local_q_point_id(const unsigned int cell, const unsigned int n_q_points, const unsigned int q_point) const
Kokkos::View<::internal::MatrixFreeFunctions::ConstraintKinds *, MemorySpace::Default::kokkos_space > constraint_mask
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > shape_values
unsigned int padding_length
Kokkos::View< Number **[dim][dim], MemorySpace::Default::kokkos_space > inv_jacobian
Kokkos::View< point_type **, MemorySpace::Default::kokkos_space > q_points
Kokkos::View< types::global_dof_index **, MemorySpace::Default::kokkos_space > local_to_global
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > shape_gradients
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > co_shape_gradients
Portable::MatrixFree< dim, Number >::point_type & get_quadrature_point(const unsigned int cell, const unsigned int q_point) const
Kokkos::View< Number *[dim], MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space, Kokkos::MemoryTraits< Kokkos::Unmanaged > > SharedView2D
Kokkos::View< Number *, MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space, Kokkos::MemoryTraits< Kokkos::Unmanaged > > SharedView1D
Kokkos::TeamPolicy< MemorySpace::Default::kokkos_space::execution_space >::member_type TeamHandle
SharedData(const TeamHandle &team_member, const SharedView1D &values, const SharedView2D &gradients)