Reference documentation for deal.II version 9.3.3
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Classes | Public Types | Static Public Attributes | List of all members
MatrixFree< dim, Number, VectorizedArrayType > Class Template Reference

#include <deal.II/matrix_free/matrix_free.h>

Inheritance diagram for MatrixFree< dim, Number, VectorizedArrayType >:
[legend]

Classes

struct  AdditionalData
 

Public Types

using value_type = Number
 
using vectorized_value_type = VectorizedArrayType
 

Public Member Functions

2: Matrix-free loops
template<typename OutVector , typename InVector >
void cell_loop (const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &cell_operation, OutVector &dst, const InVector &src, const bool zero_dst_vector=false) const
 
template<typename CLASS , typename OutVector , typename InVector >
void cell_loop (void(CLASS::*cell_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const, const CLASS *owning_class, OutVector &dst, const InVector &src, const bool zero_dst_vector=false) const
 
template<typename CLASS , typename OutVector , typename InVector >
void cell_loop (void(CLASS::*cell_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &), CLASS *owning_class, OutVector &dst, const InVector &src, const bool zero_dst_vector=false) const
 
template<typename CLASS , typename OutVector , typename InVector >
void cell_loop (void(CLASS::*cell_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const, const CLASS *owning_class, OutVector &dst, const InVector &src, const std::function< void(const unsigned int, const unsigned int)> &operation_before_loop, const std::function< void(const unsigned int, const unsigned int)> &operation_after_loop, const unsigned int dof_handler_index_pre_post=0) const
 
template<typename CLASS , typename OutVector , typename InVector >
void cell_loop (void(CLASS::*cell_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &), CLASS *owning_class, OutVector &dst, const InVector &src, const std::function< void(const unsigned int, const unsigned int)> &operation_before_loop, const std::function< void(const unsigned int, const unsigned int)> &operation_after_loop, const unsigned int dof_handler_index_pre_post=0) const
 
template<typename OutVector , typename InVector >
void cell_loop (const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &cell_operation, OutVector &dst, const InVector &src, const std::function< void(const unsigned int, const unsigned int)> &operation_before_loop, const std::function< void(const unsigned int, const unsigned int)> &operation_after_loop, const unsigned int dof_handler_index_pre_post=0) const
 
template<typename OutVector , typename InVector >
void loop (const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &cell_operation, const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &face_operation, const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &boundary_operation, OutVector &dst, const InVector &src, const bool zero_dst_vector=false, const DataAccessOnFaces dst_vector_face_access=DataAccessOnFaces::unspecified, const DataAccessOnFaces src_vector_face_access=DataAccessOnFaces::unspecified) const
 
template<typename CLASS , typename OutVector , typename InVector >
void loop (void(CLASS::*cell_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const, void(CLASS::*face_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const, void(CLASS::*boundary_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const, const CLASS *owning_class, OutVector &dst, const InVector &src, const bool zero_dst_vector=false, const DataAccessOnFaces dst_vector_face_access=DataAccessOnFaces::unspecified, const DataAccessOnFaces src_vector_face_access=DataAccessOnFaces::unspecified) const
 
template<typename CLASS , typename OutVector , typename InVector >
void loop (void(CLASS::*cell_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &), void(CLASS::*face_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &), void(CLASS::*boundary_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &), CLASS *owning_class, OutVector &dst, const InVector &src, const bool zero_dst_vector=false, const DataAccessOnFaces dst_vector_face_access=DataAccessOnFaces::unspecified, const DataAccessOnFaces src_vector_face_access=DataAccessOnFaces::unspecified) const
 
template<typename CLASS , typename OutVector , typename InVector >
void loop_cell_centric (void(CLASS::*cell_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const, const CLASS *owning_class, OutVector &dst, const InVector &src, const bool zero_dst_vector=false, const DataAccessOnFaces src_vector_face_access=DataAccessOnFaces::unspecified) const
 
template<typename CLASS , typename OutVector , typename InVector >
void loop_cell_centric (void(CLASS::*cell_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &), CLASS *owning_class, OutVector &dst, const InVector &src, const bool zero_dst_vector=false, const DataAccessOnFaces src_vector_face_access=DataAccessOnFaces::unspecified) const
 
template<typename OutVector , typename InVector >
void loop_cell_centric (const std::function< void(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &cell_operation, OutVector &dst, const InVector &src, const bool zero_dst_vector=false, const DataAccessOnFaces src_vector_face_access=DataAccessOnFaces::unspecified) const
 
std::pair< unsigned int, unsigned intcreate_cell_subrange_hp (const std::pair< unsigned int, unsigned int > &range, const unsigned int fe_degree, const unsigned int dof_handler_index=0) const
 
std::pair< unsigned int, unsigned intcreate_cell_subrange_hp_by_index (const std::pair< unsigned int, unsigned int > &range, const unsigned int fe_index, const unsigned int dof_handler_index=0) const
 
unsigned int n_active_fe_indices () const
 
unsigned int get_cell_active_fe_index (const std::pair< unsigned int, unsigned int > range) const
 
unsigned int get_face_active_fe_index (const std::pair< unsigned int, unsigned int > range, const bool is_interior_face=true) const
 
3: Initialization of vectors
template<typename VectorType >
void initialize_dof_vector (VectorType &vec, const unsigned int dof_handler_index=0) const
 
template<typename Number2 >
void initialize_dof_vector (LinearAlgebra::distributed::Vector< Number2 > &vec, const unsigned int dof_handler_index=0) const
 
const std::shared_ptr< const Utilities::MPI::Partitioner > & get_vector_partitioner (const unsigned int dof_handler_index=0) const
 
const IndexSetget_locally_owned_set (const unsigned int dof_handler_index=0) const
 
const IndexSetget_ghost_set (const unsigned int dof_handler_index=0) const
 
const std::vector< unsigned int > & get_constrained_dofs (const unsigned int dof_handler_index=0) const
 
void renumber_dofs (std::vector< types::global_dof_index > &renumbering, const unsigned int dof_handler_index=0)
 

Static Public Attributes

static const unsigned int dimension = dim
 

1: Construction and initialization

enum class  DataAccessOnFaces {
  none , values , values_all_faces , gradients ,
  gradients_all_faces , unspecified
}
 
 MatrixFree ()
 
 MatrixFree (const MatrixFree< dim, Number, VectorizedArrayType > &other)
 
 ~MatrixFree () override=default
 
template<typename QuadratureType , typename number2 , typename MappingType >
void reinit (const MappingType &mapping, const DoFHandler< dim > &dof_handler, const AffineConstraints< number2 > &constraint, const QuadratureType &quad, const AdditionalData &additional_data=AdditionalData())
 
template<typename QuadratureType , typename number2 >
void reinit (const DoFHandler< dim > &dof_handler, const AffineConstraints< number2 > &constraint, const QuadratureType &quad, const AdditionalData &additional_data=AdditionalData())
 
template<typename QuadratureType , typename number2 , typename MappingType >
void reinit (const MappingType &mapping, const std::vector< const DoFHandler< dim > * > &dof_handler, const std::vector< const AffineConstraints< number2 > * > &constraint, const std::vector< QuadratureType > &quad, const AdditionalData &additional_data=AdditionalData())
 
template<typename QuadratureType , typename number2 , typename DoFHandlerType , typename MappingType >
void reinit (const MappingType &mapping, const std::vector< const DoFHandlerType * > &dof_handler, const std::vector< const AffineConstraints< number2 > * > &constraint, const std::vector< QuadratureType > &quad, const AdditionalData &additional_data=AdditionalData())
 
template<typename QuadratureType , typename number2 >
void reinit (const std::vector< const DoFHandler< dim > * > &dof_handler, const std::vector< const AffineConstraints< number2 > * > &constraint, const std::vector< QuadratureType > &quad, const AdditionalData &additional_data=AdditionalData())
 
template<typename QuadratureType , typename number2 , typename DoFHandlerType >
void reinit (const std::vector< const DoFHandlerType * > &dof_handler, const std::vector< const AffineConstraints< number2 > * > &constraint, const std::vector< QuadratureType > &quad, const AdditionalData &additional_data=AdditionalData())
 
template<typename QuadratureType , typename number2 , typename MappingType >
void reinit (const MappingType &mapping, const std::vector< const DoFHandler< dim > * > &dof_handler, const std::vector< const AffineConstraints< number2 > * > &constraint, const QuadratureType &quad, const AdditionalData &additional_data=AdditionalData())
 
template<typename QuadratureType , typename number2 , typename DoFHandlerType , typename MappingType >
void reinit (const MappingType &mapping, const std::vector< const DoFHandlerType * > &dof_handler, const std::vector< const AffineConstraints< number2 > * > &constraint, const QuadratureType &quad, const AdditionalData &additional_data=AdditionalData())
 
template<typename QuadratureType , typename number2 >
void reinit (const std::vector< const DoFHandler< dim > * > &dof_handler, const std::vector< const AffineConstraints< number2 > * > &constraint, const QuadratureType &quad, const AdditionalData &additional_data=AdditionalData())
 
template<typename QuadratureType , typename number2 , typename DoFHandlerType >
void reinit (const std::vector< const DoFHandlerType * > &dof_handler, const std::vector< const AffineConstraints< number2 > * > &constraint, const QuadratureType &quad, const AdditionalData &additional_data=AdditionalData())
 
void copy_from (const MatrixFree< dim, Number, VectorizedArrayType > &matrix_free_base)
 
void update_mapping (const Mapping< dim > &mapping)
 
void update_mapping (const std::shared_ptr< hp::MappingCollection< dim > > &mapping)
 
void clear ()
 

5: Access of internal data structure

Note: Expert mode, interface not stable between releases.

std::vector< SmartPointer< const DoFHandler< dim > > > dof_handlers
 
std::vector< internal::MatrixFreeFunctions::DoFInfodof_info
 
std::vector< Number > constraint_pool_data
 
std::vector< unsigned intconstraint_pool_row_index
 
internal::MatrixFreeFunctions::MappingInfo< dim, Number, VectorizedArrayType > mapping_info
 
Table< 4, internal::MatrixFreeFunctions::ShapeInfo< VectorizedArrayType > > shape_info
 
std::vector< std::pair< unsigned int, unsigned int > > cell_level_index
 
unsigned int cell_level_index_end_local
 
internal::MatrixFreeFunctions::TaskInfo task_info
 
internal::MatrixFreeFunctions::FaceInfo< VectorizedArrayType::size()> face_info
 
bool indices_are_initialized
 
bool mapping_is_initialized
 
Threads::ThreadLocalStorage< std::list< std::pair< bool, AlignedVector< VectorizedArrayType > > > > scratch_pad
 
std::list< std::pair< bool, AlignedVector< Number > > > scratch_pad_non_threadsafe
 
unsigned int mg_level
 
const internal::MatrixFreeFunctions::TaskInfoget_task_info () const
 
const internal::MatrixFreeFunctions::MappingInfo< dim, Number, VectorizedArrayType > & get_mapping_info () const
 
const internal::MatrixFreeFunctions::DoFInfoget_dof_info (const unsigned int dof_handler_index_component=0) const
 
unsigned int n_constraint_pool_entries () const
 
const Number * constraint_pool_begin (const unsigned int pool_index) const
 
const Number * constraint_pool_end (const unsigned int pool_index) const
 
const internal::MatrixFreeFunctions::ShapeInfo< VectorizedArrayType > & get_shape_info (const unsigned int dof_handler_index_component=0, const unsigned int quad_index=0, const unsigned int fe_base_element=0, const unsigned int hp_active_fe_index=0, const unsigned int hp_active_quad_index=0) const
 
const internal::MatrixFreeFunctions::FaceToCellTopology< VectorizedArrayType::size()> & get_face_info (const unsigned int face_batch_index) const
 
const Table< 3, unsigned int > & get_cell_and_face_to_plain_faces () const
 
AlignedVector< VectorizedArrayType > * acquire_scratch_data () const
 
void release_scratch_data (const AlignedVector< VectorizedArrayType > *memory) const
 
AlignedVector< Number > * acquire_scratch_data_non_threadsafe () const
 
void release_scratch_data_non_threadsafe (const AlignedVector< Number > *memory) const
 
template<typename number2 , int q_dim>
void internal_reinit (const std::shared_ptr< hp::MappingCollection< dim > > &mapping, const std::vector< const DoFHandler< dim, dim > * > &dof_handlers, const std::vector< const AffineConstraints< number2 > * > &constraint, const std::vector< IndexSet > &locally_owned_set, const std::vector< hp::QCollection< q_dim > > &quad, const AdditionalData &additional_data)
 
template<typename number2 >
void initialize_indices (const std::vector< const AffineConstraints< number2 > * > &constraint, const std::vector< IndexSet > &locally_owned_set, const AdditionalData &additional_data)
 
void initialize_dof_handlers (const std::vector< const DoFHandler< dim, dim > * > &dof_handlers, const AdditionalData &additional_data)
 

Subscriptor functionality

Classes derived from Subscriptor provide a facility to subscribe to this object. This is mostly used by the SmartPointer class.

std::atomic< unsigned intcounter
 
std::map< std::string, unsigned intcounter_map
 
std::vector< std::atomic< bool > * > validity_pointers
 
const std::type_info * object_info
 
void subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const
 
void unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const
 
unsigned int n_subscriptions () const
 
template<typename StreamType >
void list_subscribers (StreamType &stream) const
 
void list_subscribers () const
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 
static ::ExceptionBaseExcInUse (int arg1, std::string arg2, std::string arg3)
 
static ::ExceptionBaseExcNoSubscriber (std::string arg1, std::string arg2)
 
void check_no_subscribers () const noexcept
 
using map_value_type = decltype(counter_map)::value_type
 
using map_iterator = decltype(counter_map)::iterator
 
static std::mutex mutex
 

4: General information

unsigned int n_components () const
 
unsigned int n_base_elements (const unsigned int dof_handler_index) const
 
unsigned int n_physical_cells () const
 
unsigned int n_macro_cells () const
 
unsigned int n_cell_batches () const
 
unsigned int n_ghost_cell_batches () const
 
unsigned int n_inner_face_batches () const
 
unsigned int n_boundary_face_batches () const
 
unsigned int n_ghost_inner_face_batches () const
 
types::boundary_id get_boundary_id (const unsigned int macro_face) const
 
std::array< types::boundary_id, VectorizedArrayType::size()> get_faces_by_cells_boundary_id (const unsigned int cell_batch_index, const unsigned int face_number) const
 
const DoFHandler< dim > & get_dof_handler (const unsigned int dof_handler_index=0) const
 
template<typename DoFHandlerType >
const DoFHandlerType & get_dof_handler (const unsigned int dof_handler_index=0) const
 
DoFHandler< dim >::cell_iterator get_cell_iterator (const unsigned int cell_batch_index, const unsigned int lane_index, const unsigned int dof_handler_index=0) const
 
std::pair< int, intget_cell_level_and_index (const unsigned int cell_batch_index, const unsigned int lane_index) const
 
std::pair< typename DoFHandler< dim >::cell_iterator, unsigned intget_face_iterator (const unsigned int face_batch_index, const unsigned int lane_index, const bool interior=true, const unsigned int fe_component=0) const
 
DoFHandler< dim >::active_cell_iterator get_hp_cell_iterator (const unsigned int cell_batch_index, const unsigned int lane_index, const unsigned int dof_handler_index=0) const
 
bool at_irregular_cell (const unsigned int cell_batch_index) const
 
unsigned int n_components_filled (const unsigned int cell_batch_number) const
 
unsigned int n_active_entries_per_cell_batch (const unsigned int cell_batch_index) const
 
unsigned int n_active_entries_per_face_batch (const unsigned int face_batch_index) const
 
unsigned int get_dofs_per_cell (const unsigned int dof_handler_index=0, const unsigned int hp_active_fe_index=0) const
 
unsigned int get_n_q_points (const unsigned int quad_index=0, const unsigned int hp_active_fe_index=0) const
 
unsigned int get_dofs_per_face (const unsigned int dof_handler_index=0, const unsigned int hp_active_fe_index=0) const
 
unsigned int get_n_q_points_face (const unsigned int quad_index=0, const unsigned int hp_active_fe_index=0) const
 
const Quadrature< dim > & get_quadrature (const unsigned int quad_index=0, const unsigned int hp_active_fe_index=0) const
 
const Quadrature< dim - 1 > & get_face_quadrature (const unsigned int quad_index=0, const unsigned int hp_active_fe_index=0) const
 
unsigned int get_cell_category (const unsigned int cell_batch_index) const
 
std::pair< unsigned int, unsigned intget_face_category (const unsigned int macro_face) const
 
bool indices_initialized () const
 
bool mapping_initialized () const
 
unsigned int get_mg_level () const
 
std::size_t memory_consumption () const
 
template<typename StreamType >
void print_memory_consumption (StreamType &out) const
 
void print (std::ostream &out) const
 
template<int spacedim>
static bool is_supported (const FiniteElement< dim, spacedim > &fe)
 

Detailed Description

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
class MatrixFree< dim, Number, VectorizedArrayType >

This class collects all the data that is stored for the matrix free implementation. The storage scheme is tailored towards several loops performed with the same data, i.e., typically doing many matrix-vector products or residual computations on the same mesh. The class is used in step-37 and step-48.

This class does not implement any operations involving finite element basis functions, i.e., regarding the operation performed on the cells. For these operations, the class FEEvaluation is designed to use the data collected in this class.

The stored data can be subdivided into three main components:

Besides the initialization routines, this class implements only a single operation, namely a loop over all cells (cell_loop()). This loop is scheduled in such a way that cells that share degrees of freedom are not worked on simultaneously, which implies that it is possible to write to vectors (or matrices) in parallel without having to explicitly synchronize access to these vectors and matrices. This class does not implement any shape values, all it does is to cache the respective data. To implement finite element operations, use the class FEEvaluation (or some of the related classes).

This class traverses the cells in a different order than the usual Triangulation class in deal.II, in order to be flexible with respect to parallelization in shared memory and vectorization.

Vectorization is implemented by merging several topological cells into one so-called macro cell. This enables the application of all cell-related operations for several cells with one CPU instruction and is one of the main features of this framework.

For details on usage of this class, see the description of FEEvaluation or the matrix-free module.

Definition at line 116 of file matrix_free.h.

Member Typedef Documentation

◆ value_type

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
using MatrixFree< dim, Number, VectorizedArrayType >::value_type = Number

An alias for the underlying number type specified by the template argument.

Definition at line 127 of file matrix_free.h.

◆ vectorized_value_type

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
using MatrixFree< dim, Number, VectorizedArrayType >::vectorized_value_type = VectorizedArrayType

Definition at line 128 of file matrix_free.h.

Member Enumeration Documentation

◆ DataAccessOnFaces

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
enum class MatrixFree::DataAccessOnFaces
strong

This class defines the type of data access for face integrals in loop () that is passed on to the update_ghost_values and compress functions of the parallel vectors, with the purpose of being able to reduce the amount of data that must be exchanged. The data exchange is a real bottleneck in particular for high-degree DG methods, therefore a more restrictive way of exchange is clearly beneficial. Note that this selection applies to FEFaceEvaluation objects assigned to the exterior side of cells accessing FaceToCellTopology::exterior_cells only; all interior objects are available in any case.

Enumerator
none 

The loop does not involve any FEFaceEvaluation access into neighbors, as is the case with only boundary integrals (but no interior face integrals) or when doing mass matrices in a MatrixFree::cell_loop() like setup.

values 

The loop does only involve FEFaceEvaluation access into neighbors by function values, such as FEFaceEvaluation::gather_evaluate() with argument EvaluationFlags::values, but no access to shape function derivatives (which typically need to access more data). For FiniteElement types where only some of the shape functions have support on a face, such as an FE_DGQ element with Lagrange polynomials with nodes on the element surface, the data exchange is reduced from (k+1)^dim to (k+1)^(dim-1).

values_all_faces 

Same as above. To be used if data has to be accessed from exterior faces if FEFaceEvaluation was reinitialized by providing the cell batch number and a face number. This configuration is useful in the context of cell-centric loops.

Precondition
AdditionalData::hold_all_faces_to_owned_cells has to enabled.
gradients 

The loop does involve FEFaceEvaluation access into neighbors by function values and gradients, but no second derivatives, such as FEFaceEvaluation::gather_evaluate() with EvaluationFlags::values and EvaluationFlags::gradients set. For FiniteElement types where only some of the shape functions have non-zero value and first derivative on a face, such as an FE_DGQHermite element, the data exchange is reduced, e.g. from (k+1)^dim to 2(k+1)^(dim-1). Note that for bases that do not have this special property, the full neighboring data is sent anyway.

gradients_all_faces 

Same as above. To be used if data has to be accessed from exterior faces if FEFaceEvaluation was reinitialized by providing the cell batch number and a face number. This configuration is useful in the context of cell-centric loops.

Precondition
AdditionalData::hold_all_faces_to_owned_cells has to enabled.
unspecified 

General setup where the user does not want to make a restriction. This is typically more expensive than the other options, but also the most conservative one because the full data of elements behind the faces to be computed locally will be exchanged.

Definition at line 768 of file matrix_free.h.

Constructor & Destructor Documentation

◆ MatrixFree() [1/2]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
MatrixFree< dim, Number, VectorizedArrayType >::MatrixFree ( )

Default empty constructor. Does nothing.

◆ MatrixFree() [2/2]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
MatrixFree< dim, Number, VectorizedArrayType >::MatrixFree ( const MatrixFree< dim, Number, VectorizedArrayType > &  other)

Copy constructor, calls copy_from

◆ ~MatrixFree()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
MatrixFree< dim, Number, VectorizedArrayType >::~MatrixFree ( )
overridedefault

Destructor.

Member Function Documentation

◆ reinit() [1/10]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename QuadratureType , typename number2 , typename MappingType >
void MatrixFree< dim, Number, VectorizedArrayType >::reinit ( const MappingType &  mapping,
const DoFHandler< dim > &  dof_handler,
const AffineConstraints< number2 > &  constraint,
const QuadratureType &  quad,
const AdditionalData additional_data = AdditionalData() 
)

Extracts the information needed to perform loops over cells. The DoFHandler and AffineConstraints objects describe the layout of degrees of freedom, the DoFHandler and the mapping describe the transformations from unit to real cell, and the finite element underlying the DoFHandler together with the quadrature formula describe the local operations. Note that the finite element underlying the DoFHandler must either be scalar or contain several copies of the same element. Mixing several different elements into one FESystem is not allowed. In that case, use the initialization function with several DoFHandler arguments.

◆ reinit() [2/10]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename QuadratureType , typename number2 >
void MatrixFree< dim, Number, VectorizedArrayType >::reinit ( const DoFHandler< dim > &  dof_handler,
const AffineConstraints< number2 > &  constraint,
const QuadratureType &  quad,
const AdditionalData additional_data = AdditionalData() 
)

Initializes the data structures. Same as above, but using a \(Q_1\) mapping.

Deprecated:
Use the overload taking a Mapping object instead.

◆ reinit() [3/10]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename QuadratureType , typename number2 , typename MappingType >
void MatrixFree< dim, Number, VectorizedArrayType >::reinit ( const MappingType &  mapping,
const std::vector< const DoFHandler< dim > * > &  dof_handler,
const std::vector< const AffineConstraints< number2 > * > &  constraint,
const std::vector< QuadratureType > &  quad,
const AdditionalData additional_data = AdditionalData() 
)

Extracts the information needed to perform loops over cells. The DoFHandler and AffineConstraints objects describe the layout of degrees of freedom, the DoFHandler and the mapping describe the transformations from unit to real cell, and the finite element underlying the DoFHandler together with the quadrature formula describe the local operations. As opposed to the scalar case treated with the other initialization functions, this function allows for problems with two or more different finite elements. The DoFHandlers to each element must be passed as pointers to the initialization function. Alternatively, a system of several components may also be represented by a single DoFHandler with an FESystem element. The prerequisite for this case is that each base element of the FESystem must be compatible with the present class, such as the FE_Q or FE_DGQ classes.

This function also allows for using several quadrature formulas, e.g. when the description contains independent integrations of elements of different degrees. However, the number of different quadrature formulas can be sets independently from the number of DoFHandlers, when several elements are always integrated with the same quadrature formula.

◆ reinit() [4/10]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename QuadratureType , typename number2 , typename DoFHandlerType , typename MappingType >
void MatrixFree< dim, Number, VectorizedArrayType >::reinit ( const MappingType &  mapping,
const std::vector< const DoFHandlerType * > &  dof_handler,
const std::vector< const AffineConstraints< number2 > * > &  constraint,
const std::vector< QuadratureType > &  quad,
const AdditionalData additional_data = AdditionalData() 
)

Initializes the data structures. Same as above, but using DoFHandlerType.

Deprecated:
Use the overload taking a DoFHandler object instead.

◆ reinit() [5/10]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename QuadratureType , typename number2 >
void MatrixFree< dim, Number, VectorizedArrayType >::reinit ( const std::vector< const DoFHandler< dim > * > &  dof_handler,
const std::vector< const AffineConstraints< number2 > * > &  constraint,
const std::vector< QuadratureType > &  quad,
const AdditionalData additional_data = AdditionalData() 
)

Initializes the data structures. Same as above, but using a \(Q_1\) mapping.

Deprecated:
Use the overload taking a Mapping object instead.

◆ reinit() [6/10]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename QuadratureType , typename number2 , typename DoFHandlerType >
void MatrixFree< dim, Number, VectorizedArrayType >::reinit ( const std::vector< const DoFHandlerType * > &  dof_handler,
const std::vector< const AffineConstraints< number2 > * > &  constraint,
const std::vector< QuadratureType > &  quad,
const AdditionalData additional_data = AdditionalData() 
)

Initializes the data structures. Same as above, but using DoFHandlerType.

Deprecated:
Use the overload taking a DoFHandler object instead.

◆ reinit() [7/10]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename QuadratureType , typename number2 , typename MappingType >
void MatrixFree< dim, Number, VectorizedArrayType >::reinit ( const MappingType &  mapping,
const std::vector< const DoFHandler< dim > * > &  dof_handler,
const std::vector< const AffineConstraints< number2 > * > &  constraint,
const QuadratureType &  quad,
const AdditionalData additional_data = AdditionalData() 
)

Initializes the data structures. Same as before, but now the index set description of the locally owned range of degrees of freedom is taken from the DoFHandler. Moreover, only a single quadrature formula is used, as might be necessary when several components in a vector-valued problem are integrated together based on the same quadrature formula.

◆ reinit() [8/10]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename QuadratureType , typename number2 , typename DoFHandlerType , typename MappingType >
void MatrixFree< dim, Number, VectorizedArrayType >::reinit ( const MappingType &  mapping,
const std::vector< const DoFHandlerType * > &  dof_handler,
const std::vector< const AffineConstraints< number2 > * > &  constraint,
const QuadratureType &  quad,
const AdditionalData additional_data = AdditionalData() 
)

Initializes the data structures. Same as above, but using DoFHandlerType.

Deprecated:
Use the overload taking a DoFHandler object instead.

◆ reinit() [9/10]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename QuadratureType , typename number2 >
void MatrixFree< dim, Number, VectorizedArrayType >::reinit ( const std::vector< const DoFHandler< dim > * > &  dof_handler,
const std::vector< const AffineConstraints< number2 > * > &  constraint,
const QuadratureType &  quad,
const AdditionalData additional_data = AdditionalData() 
)

Initializes the data structures. Same as above, but using a \(Q_1\) mapping.

Deprecated:
Use the overload taking a Mapping object instead.

◆ reinit() [10/10]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename QuadratureType , typename number2 , typename DoFHandlerType >
void MatrixFree< dim, Number, VectorizedArrayType >::reinit ( const std::vector< const DoFHandlerType * > &  dof_handler,
const std::vector< const AffineConstraints< number2 > * > &  constraint,
const QuadratureType &  quad,
const AdditionalData additional_data = AdditionalData() 
)

Initializes the data structures. Same as above, but using DoFHandlerType.

Deprecated:
Use the overload taking a DoFHandler object instead.

◆ copy_from()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
void MatrixFree< dim, Number, VectorizedArrayType >::copy_from ( const MatrixFree< dim, Number, VectorizedArrayType > &  matrix_free_base)

Copy function. Creates a deep copy of all data structures. It is usually enough to keep the data for different operations once, so this function should not be needed very often.

◆ update_mapping() [1/2]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
void MatrixFree< dim, Number, VectorizedArrayType >::update_mapping ( const Mapping< dim > &  mapping)

Refreshes the geometry data stored in the MappingInfo fields when the underlying geometry has changed (e.g. by a mapping that can deform through a change in the spatial configuration like MappingFEField) whereas the topology of the mesh and unknowns have remained the same. Compared to reinit(), this operation only has to re-generate the geometry arrays and can thus be significantly cheaper (depending on the cost to evaluate the geometry).

◆ update_mapping() [2/2]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
void MatrixFree< dim, Number, VectorizedArrayType >::update_mapping ( const std::shared_ptr< hp::MappingCollection< dim > > &  mapping)

Same as above but with hp::MappingCollection.

◆ clear()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
void MatrixFree< dim, Number, VectorizedArrayType >::clear ( )

Clear all data fields and brings the class into a condition similar to after having called the default constructor.

◆ cell_loop() [1/6]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename OutVector , typename InVector >
void MatrixFree< dim, Number, VectorizedArrayType >::cell_loop ( const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &  cell_operation,
OutVector &  dst,
const InVector &  src,
const bool  zero_dst_vector = false 
) const

This method runs the loop over all cells (in parallel) and performs the MPI data exchange on the source vector and destination vector.

Parameters
cell_operationstd::function with the signature cell_operation (const MatrixFree<dim,Number> &, OutVector &, InVector &, std::pair<unsigned int,unsigned int> &) where the first argument passes the data of the calling class and the last argument defines the range of cells which should be worked on (typically more than one cell should be worked on in order to reduce overheads). One can pass a pointer to an object in this place if it has an operator() with the correct set of arguments since such a pointer can be converted to the function object.
dstDestination vector holding the result. If the vector is of type LinearAlgebra::distributed::Vector (or composite objects thereof such as LinearAlgebra::distributed::BlockVector), the loop calls LinearAlgebra::distributed::Vector::compress() at the end of the call internally. For other vectors, including parallel Trilinos or PETSc vectors, no such call is issued. Note that Trilinos/Epetra or PETSc vectors do currently not work in parallel because the present class uses MPI-local index addressing, as opposed to the global addressing implied by those external libraries.
srcInput vector. If the vector is of type LinearAlgebra::distributed::Vector (or composite objects thereof such as LinearAlgebra::distributed::BlockVector), the loop calls LinearAlgebra::distributed::Vector::update_ghost_values() at the start of the call internally to make sure all necessary data is locally available. Note, however, that the vector is reset to its original state at the end of the loop, i.e., if the vector was not ghosted upon entry of the loop, it will not be ghosted upon finishing the loop.
zero_dst_vectorIf this flag is set to true, the vector dst will be set to zero inside the loop. Use this case in case you perform a typical vmult() operation on a matrix object, as it will typically be faster than calling dst = 0; before the loop separately. This is because the vector entries are set to zero only on subranges of the vector, making sure that the vector entries stay in caches as much as possible.

◆ cell_loop() [2/6]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename CLASS , typename OutVector , typename InVector >
void MatrixFree< dim, Number, VectorizedArrayType >::cell_loop ( void(CLASS::*)(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const  cell_operation,
const CLASS *  owning_class,
OutVector &  dst,
const InVector &  src,
const bool  zero_dst_vector = false 
) const

This is the second variant to run the loop over all cells, now providing a function pointer to a member function of class CLASS. This method obviates the need to define a lambda function or to call std::bind to bind the class into the given function in case the local function needs to access data in the class (i.e., it is a non-static member function).

Parameters
cell_operationPointer to member function of CLASS with the signature cell_operation (const MatrixFree<dim,Number> &, OutVector &, InVector &, std::pair<unsigned int,unsigned int> &) where the first argument passes the data of the calling class and the last argument defines the range of cells which should be worked on (typically more than one cell should be worked on in order to reduce overheads).
owning_classThe object which provides the cell_operation call. To be compatible with this interface, the class must allow to call owning_class->cell_operation(...).
dstDestination vector holding the result. If the vector is of type LinearAlgebra::distributed::Vector (or composite objects thereof such as LinearAlgebra::distributed::BlockVector), the loop calls LinearAlgebra::distributed::Vector::compress() at the end of the call internally. For other vectors, including parallel Trilinos or PETSc vectors, no such call is issued. Note that Trilinos/Epetra or PETSc vectors do currently not work in parallel because the present class uses MPI-local index addressing, as opposed to the global addressing implied by those external libraries.
srcInput vector. If the vector is of type LinearAlgebra::distributed::Vector (or composite objects thereof such as LinearAlgebra::distributed::BlockVector), the loop calls LinearAlgebra::distributed::Vector::update_ghost_values() at the start of the call internally to make sure all necessary data is locally available. Note, however, that the vector is reset to its original state at the end of the loop, i.e., if the vector was not ghosted upon entry of the loop, it will not be ghosted upon finishing the loop.
zero_dst_vectorIf this flag is set to true, the vector dst will be set to zero inside the loop. Use this case in case you perform a typical vmult() operation on a matrix object, as it will typically be faster than calling dst = 0; before the loop separately. This is because the vector entries are set to zero only on subranges of the vector, making sure that the vector entries stay in caches as much as possible.

◆ cell_loop() [3/6]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename CLASS , typename OutVector , typename InVector >
void MatrixFree< dim, Number, VectorizedArrayType >::cell_loop ( void(CLASS::*)(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)  cell_operation,
CLASS *  owning_class,
OutVector &  dst,
const InVector &  src,
const bool  zero_dst_vector = false 
) const

Same as above, but for class member functions which are non-const.

◆ cell_loop() [4/6]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename CLASS , typename OutVector , typename InVector >
void MatrixFree< dim, Number, VectorizedArrayType >::cell_loop ( void(CLASS::*)(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const  cell_operation,
const CLASS *  owning_class,
OutVector &  dst,
const InVector &  src,
const std::function< void(const unsigned int, const unsigned int)> &  operation_before_loop,
const std::function< void(const unsigned int, const unsigned int)> &  operation_after_loop,
const unsigned int  dof_handler_index_pre_post = 0 
) const

This function is similar to the cell_loop with an std::function object to specify to operation to be performed on cells, but adds two additional functors to execute some additional work before and after the cell integrals are computed.

The two additional functors work on a range of degrees of freedom, expressed in terms of the degree-of-freedom numbering of the selected DoFHandler dof_handler_index_pre_post in MPI-local indices. The arguments to the functors represent a range of degrees of freedom at a granularity of internal::MatrixFreeFunctions::DoFInfo::chunk_size_zero_vector entries (except for the last chunk which is set to the number of locally owned entries) in the form [first, last). The idea of these functors is to bring operations on vectors closer to the point where they accessed in a matrix-free loop, with the goal to increase cache hits by temporal locality. This loop guarantees that the operation_before_loop hits all relevant unknowns before they are first touched in the cell_operation (including the MPI data exchange), allowing to execute some vector update that the src vector depends upon. The operation_after_loop is similar

  • it starts to execute on a range of DoFs once all DoFs in that range have been touched for the last time by the cell_operation (including the MPI data exchange), allowing e.g. to compute some vector operations that depend on the result of the current cell loop in dst or want to modify src. The efficiency of caching depends on the numbering of the degrees of freedom because of the granularity of the ranges.
Parameters
cell_operationPointer to member function of CLASS with the signature cell_operation (const MatrixFree<dim,Number> &, OutVector &, InVector &, std::pair<unsigned int,unsigned int> &) where the first argument passes the data of the calling class and the last argument defines the range of cells which should be worked on (typically more than one cell should be worked on in order to reduce overheads).
owning_classThe object which provides the cell_operation call. To be compatible with this interface, the class must allow to call owning_class->cell_operation(...).
dstDestination vector holding the result. If the vector is of type LinearAlgebra::distributed::Vector (or composite objects thereof such as LinearAlgebra::distributed::BlockVector), the loop calls LinearAlgebra::distributed::Vector::compress() at the end of the call internally. For other vectors, including parallel Trilinos or PETSc vectors, no such call is issued. Note that Trilinos/Epetra or PETSc vectors do currently not work in parallel because the present class uses MPI-local index addressing, as opposed to the global addressing implied by those external libraries.
srcInput vector. If the vector is of type LinearAlgebra::distributed::Vector (or composite objects thereof such as LinearAlgebra::distributed::BlockVector), the loop calls LinearAlgebra::distributed::Vector::update_ghost_values() at the start of the call internally to make sure all necessary data is locally available. Note, however, that the vector is reset to its original state at the end of the loop, i.e., if the vector was not ghosted upon entry of the loop, it will not be ghosted upon finishing the loop.
operation_before_loopThis functor can be used to perform an operation on entries of the src and dst vectors (or other vectors) before the operation on cells first touches a particular DoF according to the general description in the text above. This function is passed a range of the locally owned degrees of freedom on the selected dof_handler_index_pre_post (in MPI-local numbering).
operation_after_loopThis functor can be used to perform an operation on entries of the src and dst vectors (or other vectors) after the operation on cells last touches a particular DoF according to the general description in the text above. This function is passed a range of the locally owned degrees of freedom on the selected dof_handler_index_pre_post (in MPI-local numbering).
dof_handler_index_pre_postSince MatrixFree can be initialized with a vector of DoFHandler objects, each of them will in general have vector sizes and thus different ranges returned to operation_before_loop and operation_after_loop. Use this variable to specify which one of the DoFHandler objects the index range should be associated to. Defaults to the dof_handler_index 0.
Note
The close locality of the operation_before_loop and operation_after_loop is currently only implemented for the MPI-only case. In case threading is enabled, the complete operation_before_loop is scheduled before the parallel loop, and operation_after_loop is scheduled strictly afterwards, due to the complicated dependencies.

◆ cell_loop() [5/6]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename CLASS , typename OutVector , typename InVector >
void MatrixFree< dim, Number, VectorizedArrayType >::cell_loop ( void(CLASS::*)(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)  cell_operation,
CLASS *  owning_class,
OutVector &  dst,
const InVector &  src,
const std::function< void(const unsigned int, const unsigned int)> &  operation_before_loop,
const std::function< void(const unsigned int, const unsigned int)> &  operation_after_loop,
const unsigned int  dof_handler_index_pre_post = 0 
) const

Same as above, but for class member functions which are non-const.

◆ cell_loop() [6/6]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename OutVector , typename InVector >
void MatrixFree< dim, Number, VectorizedArrayType >::cell_loop ( const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &  cell_operation,
OutVector &  dst,
const InVector &  src,
const std::function< void(const unsigned int, const unsigned int)> &  operation_before_loop,
const std::function< void(const unsigned int, const unsigned int)> &  operation_after_loop,
const unsigned int  dof_handler_index_pre_post = 0 
) const

Same as above, but taking an std::function as the cell_operation rather than a class member function.

◆ loop() [1/3]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename OutVector , typename InVector >
void MatrixFree< dim, Number, VectorizedArrayType >::loop ( const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &  cell_operation,
const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &  face_operation,
const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &  boundary_operation,
OutVector &  dst,
const InVector &  src,
const bool  zero_dst_vector = false,
const DataAccessOnFaces  dst_vector_face_access = DataAccessOnFaces::unspecified,
const DataAccessOnFaces  src_vector_face_access = DataAccessOnFaces::unspecified 
) const

This method runs a loop over all cells (in parallel) and performs the MPI data exchange on the source vector and destination vector. As opposed to the other variants that only runs a function on cells, this method also takes as arguments a function for the interior faces and for the boundary faces, respectively.

Parameters
cell_operationstd::function with the signature cell_operation (const MatrixFree<dim,Number> &, OutVector &, InVector &, std::pair<unsigned int,unsigned int> &) where the first argument passes the data of the calling class and the last argument defines the range of cells which should be worked on (typically more than one cell should be worked on in order to reduce overheads). One can pass a pointer to an object in this place if it has an operator() with the correct set of arguments since such a pointer can be converted to the function object.
face_operationstd::function with the signature face_operation (const MatrixFree<dim,Number> &, OutVector &, InVector &, std::pair<unsigned int,unsigned int> &) in analogy to cell_operation, but now the part associated to the work on interior faces. Note that the MatrixFree framework treats periodic faces as interior ones, so they will be assigned their correct neighbor after applying periodicity constraints within the face_operation calls.
boundary_operationstd::function with the signature boundary_operation (const MatrixFree<dim,Number> &, OutVector &, InVector &, std::pair<unsigned int,unsigned int> &) in analogy to cell_operation and face_operation, but now the part associated to the work on boundary faces. Boundary faces are separated by their boundary_id and it is possible to query that id using MatrixFree::get_boundary_id(). Note that both interior and faces use the same numbering, and faces in the interior are assigned lower numbers than the boundary faces.
dstDestination vector holding the result. If the vector is of type LinearAlgebra::distributed::Vector (or composite objects thereof such as LinearAlgebra::distributed::BlockVector), the loop calls LinearAlgebra::distributed::Vector::compress() at the end of the call internally.
srcInput vector. If the vector is of type LinearAlgebra::distributed::Vector (or composite objects thereof such as LinearAlgebra::distributed::BlockVector), the loop calls LinearAlgebra::distributed::Vector::update_ghost_values() at the start of the call internally to make sure all necessary data is locally available. Note, however, that the vector is reset to its original state at the end of the loop, i.e., if the vector was not ghosted upon entry of the loop, it will not be ghosted upon finishing the loop.
zero_dst_vectorIf this flag is set to true, the vector dst will be set to zero inside the loop. Use this case in case you perform a typical vmult() operation on a matrix object, as it will typically be faster than calling dst = 0; before the loop separately. This is because the vector entries are set to zero only on subranges of the vector, making sure that the vector entries stay in caches as much as possible.
dst_vector_face_accessSet the type of access into the vector dst that will happen inside the body of the face_operation function. As explained in the description of the DataAccessOnFaces struct, the purpose of this selection is to reduce the amount of data that must be exchanged over the MPI network (or via memcpy if within the shared memory region of a node) to gain performance. Note that there is no way to communicate this setting with the FEFaceEvaluation class, therefore this selection must be made at this site in addition to what is implemented inside the face_operation function. As a consequence, there is also no way to check that the setting passed to this call is consistent with what is later done by FEFaceEvaluation, and it is the user's responsibility to ensure correctness of data.
src_vector_face_accessSet the type of access into the vector src that will happen inside the body of the face_operation function, in analogy to dst_vector_face_access.

◆ loop() [2/3]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename CLASS , typename OutVector , typename InVector >
void MatrixFree< dim, Number, VectorizedArrayType >::loop ( void(CLASS::*)(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const  cell_operation,
void(CLASS::*)(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const  face_operation,
void(CLASS::*)(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const  boundary_operation,
const CLASS *  owning_class,
OutVector &  dst,
const InVector &  src,
const bool  zero_dst_vector = false,
const DataAccessOnFaces  dst_vector_face_access = DataAccessOnFaces::unspecified,
const DataAccessOnFaces  src_vector_face_access = DataAccessOnFaces::unspecified 
) const

This is the second variant to run the loop over all cells, interior faces, and boundary faces, now providing three function pointers to member functions of class CLASS with the signature operation (const MatrixFree<dim,Number> &, OutVector &, InVector &, std::pair<unsigned int,unsigned int>&)const. This method obviates the need to define a lambda function or to call std::bind to bind the class into the given function in case the local function needs to access data in the class (i.e., it is a non-static member function).

Parameters
cell_operationPointer to member function of CLASS with the signature cell_operation (const MatrixFree<dim,Number> &, OutVector &, InVector &, std::pair<unsigned int,unsigned int> &) where the first argument passes the data of the calling class and the last argument defines the range of cells which should be worked on (typically more than one cell should be worked on in order to reduce overheads). Note that the loop will typically split the cell_range into smaller pieces and work on cell_operation, face_operation, and boundary_operation alternately, in order to increase the potential reuse of vector entries in caches.
face_operationPointer to member function of CLASS with the signature face_operation (const MatrixFree<dim,Number> &, OutVector &, InVector &, std::pair<unsigned int,unsigned int> &) in analogy to cell_operation, but now the part associated to the work on interior faces. Note that the MatrixFree framework treats periodic faces as interior ones, so they will be assigned their correct neighbor after applying periodicity constraints within the face_operation calls.
boundary_operationPointer to member function of CLASS with the signature boundary_operation (const MatrixFree<dim,Number> &, OutVector &, InVector &, std::pair<unsigned int,unsigned int> &) in analogy to cell_operation and face_operation, but now the part associated to the work on boundary faces. Boundary faces are separated by their boundary_id and it is possible to query that id using MatrixFree::get_boundary_id(). Note that both interior and faces use the same numbering, and faces in the interior are assigned lower numbers than the boundary faces.
owning_classThe object which provides the cell_operation call. To be compatible with this interface, the class must allow to call owning_class->cell_operation(...), owning_class->face_operation(...), and owning_class->boundary_operation(...).
dstDestination vector holding the result. If the vector is of type LinearAlgebra::distributed::Vector (or composite objects thereof such as LinearAlgebra::distributed::BlockVector), the loop calls LinearAlgebra::distributed::Vector::compress() at the end of the call internally.
srcInput vector. If the vector is of type LinearAlgebra::distributed::Vector (or composite objects thereof such as LinearAlgebra::distributed::BlockVector), the loop calls LinearAlgebra::distributed::Vector::update_ghost_values() at the start of the call internally to make sure all necessary data is locally available. Note, however, that the vector is reset to its original state at the end of the loop, i.e., if the vector was not ghosted upon entry of the loop, it will not be ghosted upon finishing the loop.
zero_dst_vectorIf this flag is set to true, the vector dst will be set to zero inside the loop. Use this case in case you perform a typical vmult() operation on a matrix object, as it will typically be faster than calling dst = 0; before the loop separately. This is because the vector entries are set to zero only on subranges of the vector, making sure that the vector entries stay in caches as much as possible.
dst_vector_face_accessSet the type of access into the vector dst that will happen inside the body of the face_operation function. As explained in the description of the DataAccessOnFaces struct, the purpose of this selection is to reduce the amount of data that must be exchanged over the MPI network (or via memcpy if within the shared memory region of a node) to gain performance. Note that there is no way to communicate this setting with the FEFaceEvaluation class, therefore this selection must be made at this site in addition to what is implemented inside the face_operation function. As a consequence, there is also no way to check that the setting passed to this call is consistent with what is later done by FEFaceEvaluation, and it is the user's responsibility to ensure correctness of data.
src_vector_face_accessSet the type of access into the vector src that will happen inside the body of the face_operation function, in analogy to dst_vector_face_access.

◆ loop() [3/3]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename CLASS , typename OutVector , typename InVector >
void MatrixFree< dim, Number, VectorizedArrayType >::loop ( void(CLASS::*)(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)  cell_operation,
void(CLASS::*)(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)  face_operation,
void(CLASS::*)(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)  boundary_operation,
CLASS *  owning_class,
OutVector &  dst,
const InVector &  src,
const bool  zero_dst_vector = false,
const DataAccessOnFaces  dst_vector_face_access = DataAccessOnFaces::unspecified,
const DataAccessOnFaces  src_vector_face_access = DataAccessOnFaces::unspecified 
) const

Same as above, but for class member functions which are non-const.

◆ loop_cell_centric() [1/3]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename CLASS , typename OutVector , typename InVector >
void MatrixFree< dim, Number, VectorizedArrayType >::loop_cell_centric ( void(CLASS::*)(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const  cell_operation,
const CLASS *  owning_class,
OutVector &  dst,
const InVector &  src,
const bool  zero_dst_vector = false,
const DataAccessOnFaces  src_vector_face_access = DataAccessOnFaces::unspecified 
) const

This method runs the loop over all cells (in parallel) similarly as cell_loop() does. However, this function is intended to be used for the case if face and boundary integrals should be also evaluated. In contrast to loop(), the user provides only a single function that should contain the cell integral over a cell (or batch of cells when vectorizing) and the face and boundary integrals over all its faces. This is referred to in the literature as element-centric loop or cell-centric loop.

To be able to evaluate all face integrals (with values or gradients from the neighboring cells), all ghost values from neighboring cells are updated. Use FEFaceEvalution::reinit(cell, face_no) to access quantities on arbitrary faces of a cell and the respective neighbors.

Parameters
cell_operationPointer to member function of CLASS with the signature cell_operation (const MatrixFree<dim,Number> &, OutVector &, InVector &, std::pair<unsigned int,unsigned int> &) where the first argument passes the data of the calling class and the last argument defines the range of cells which should be worked on (typically more than one cell is passed in from the loop in order to reduce overheads).
owning_classThe object which provides the cell_operation call. To be compatible with this interface, the class must allow to call owning_class->cell_operation(...).
dstDestination vector holding the result. If the vector is of type LinearAlgebra::distributed::Vector (or composite objects thereof such as LinearAlgebra::distributed::BlockVector), the loop calls LinearAlgebra::distributed::Vector::compress() at the end of the call internally.
srcInput vector. If the vector is of type LinearAlgebra::distributed::Vector (or composite objects thereof such as LinearAlgebra::distributed::BlockVector), the loop calls LinearAlgebra::distributed::Vector::update_ghost_values() at the start of the call internally to make sure all necessary data is locally available. Note, however, that the vector is reset to its original state at the end of the loop, i.e., if the vector was not ghosted upon entry of the loop, it will not be ghosted upon finishing the loop.
zero_dst_vectorIf this flag is set to true, the vector dst will be set to zero inside the loop. Use this case in case you perform a typical vmult() operation on a matrix object, as it will typically be faster than calling dst = 0; before the loop separately. This is because the vector entries are set to zero only on subranges of the vector, making sure that the vector entries stay in caches as much as possible.
src_vector_face_accessSet the type of access into the vector src that will happen inside the body of the cell_operation function during face integrals. As explained in the description of the DataAccessOnFaces struct, the purpose of this selection is to reduce the amount of data that must be exchanged over the MPI network (or via memcpy if within the shared memory region of a node) to gain performance. Note that there is no way to communicate this setting with the FEFaceEvaluation class, therefore this selection must be made at this site in addition to what is implemented inside the face_operation function. As a consequence, there is also no way to check that the setting passed to this call is consistent with what is later done by FEFaceEvaluation, and it is the user's responsibility to ensure correctness of data.

◆ loop_cell_centric() [2/3]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename CLASS , typename OutVector , typename InVector >
void MatrixFree< dim, Number, VectorizedArrayType >::loop_cell_centric ( void(CLASS::*)(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)  cell_operation,
CLASS *  owning_class,
OutVector &  dst,
const InVector &  src,
const bool  zero_dst_vector = false,
const DataAccessOnFaces  src_vector_face_access = DataAccessOnFaces::unspecified 
) const

Same as above, but for the class member function which is non-const.

◆ loop_cell_centric() [3/3]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename OutVector , typename InVector >
void MatrixFree< dim, Number, VectorizedArrayType >::loop_cell_centric ( const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &  cell_operation,
OutVector &  dst,
const InVector &  src,
const bool  zero_dst_vector = false,
const DataAccessOnFaces  src_vector_face_access = DataAccessOnFaces::unspecified 
) const

Same as above, but with std::function.

◆ create_cell_subrange_hp()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
std::pair< unsigned int, unsigned int > MatrixFree< dim, Number, VectorizedArrayType >::create_cell_subrange_hp ( const std::pair< unsigned int, unsigned int > &  range,
const unsigned int  fe_degree,
const unsigned int  dof_handler_index = 0 
) const

In the hp-adaptive case, a subrange of cells as computed during the cell loop might contain elements of different degrees. Use this function to compute what the subrange for an individual finite element degree is. The finite element degree is associated to the vector component given in the function call.

◆ create_cell_subrange_hp_by_index()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
std::pair< unsigned int, unsigned int > MatrixFree< dim, Number, VectorizedArrayType >::create_cell_subrange_hp_by_index ( const std::pair< unsigned int, unsigned int > &  range,
const unsigned int  fe_index,
const unsigned int  dof_handler_index = 0 
) const

In the hp-adaptive case, a subrange of cells as computed during the cell loop might contain elements of different degrees. Use this function to compute what the subrange for a given index the hp-finite element, as opposed to the finite element degree in the other function.

◆ n_active_fe_indices()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::n_active_fe_indices ( ) const

In the hp adaptive case, return number of active_fe_indices.

◆ get_cell_active_fe_index()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::get_cell_active_fe_index ( const std::pair< unsigned int, unsigned int range) const

In the hp-adaptive case, return the active_fe_index of a cell range.

◆ get_face_active_fe_index()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::get_face_active_fe_index ( const std::pair< unsigned int, unsigned int range,
const bool  is_interior_face = true 
) const

In the hp-adaptive case, return the active_fe_index of a face range.

◆ initialize_dof_vector() [1/2]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename VectorType >
void MatrixFree< dim, Number, VectorizedArrayType >::initialize_dof_vector ( VectorType &  vec,
const unsigned int  dof_handler_index = 0 
) const

Initialize function for a general vector. The length of the vector is equal to the total number of degrees in the DoFHandler. If the vector is of class LinearAlgebra::distributed::Vector<Number>, the ghost entries are set accordingly. For vector-valued problems with several DoFHandlers underlying this class, the parameter vector_component defines which component is to be used.

For the vectors used with MatrixFree and in FEEvaluation, a vector needs to hold all locally active DoFs and also some of the locally relevant DoFs. The selection of DoFs is such that one can read all degrees of freedom on all locally relevant elements (locally active) plus the degrees of freedom that constraints expand into from the locally owned cells. However, not all locally relevant DoFs are stored because most of them would never be accessed in matrix-vector products and result in too much data sent around which impacts the performance.

◆ initialize_dof_vector() [2/2]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename Number2 >
void MatrixFree< dim, Number, VectorizedArrayType >::initialize_dof_vector ( LinearAlgebra::distributed::Vector< Number2 > &  vec,
const unsigned int  dof_handler_index = 0 
) const

Initialize function for a distributed vector. The length of the vector is equal to the total number of degrees in the DoFHandler. If the vector is of class LinearAlgebra::distributed::Vector<Number>, the ghost entries are set accordingly. For vector-valued problems with several DoFHandlers underlying this class, the parameter vector_component defines which component is to be used.

For the vectors used with MatrixFree and in FEEvaluation, a vector needs to hold all locally active DoFs and also some of the locally relevant DoFs. The selection of DoFs is such that one can read all degrees of freedom on all locally relevant elements (locally active) plus the degrees of freedom that constraints expand into from the locally owned cells. However, not all locally relevant DoFs are stored because most of them would never be accessed in matrix-vector products and result in too much data sent around which impacts the performance.

◆ get_vector_partitioner()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
const std::shared_ptr< const Utilities::MPI::Partitioner > & MatrixFree< dim, Number, VectorizedArrayType >::get_vector_partitioner ( const unsigned int  dof_handler_index = 0) const

Return the partitioner that represents the locally owned data and the ghost indices where access is needed to for the cell loop. The partitioner is constructed from the locally owned dofs and ghost dofs given by the respective fields. If you want to have specific information about these objects, you can query them with the respective access functions. If you just want to initialize a (parallel) vector, you should usually prefer this data structure as the data exchange information can be reused from one vector to another.

◆ get_locally_owned_set()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
const IndexSet & MatrixFree< dim, Number, VectorizedArrayType >::get_locally_owned_set ( const unsigned int  dof_handler_index = 0) const

Return the set of cells that are owned by the processor.

◆ get_ghost_set()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
const IndexSet & MatrixFree< dim, Number, VectorizedArrayType >::get_ghost_set ( const unsigned int  dof_handler_index = 0) const

Return the set of ghost cells needed but not owned by the processor.

◆ get_constrained_dofs()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
const std::vector< unsigned int > & MatrixFree< dim, Number, VectorizedArrayType >::get_constrained_dofs ( const unsigned int  dof_handler_index = 0) const

Return a list of all degrees of freedom that are constrained. The list is returned in MPI-local index space for the locally owned range of the vector, not in global MPI index space that spans all MPI processors. To get numbers in global index space, call get_vector_partitioner()->local_to_global on an entry of the vector. In addition, it only returns the indices for degrees of freedom that are owned locally, not for ghosts.

◆ renumber_dofs()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
void MatrixFree< dim, Number, VectorizedArrayType >::renumber_dofs ( std::vector< types::global_dof_index > &  renumbering,
const unsigned int  dof_handler_index = 0 
)

Computes a renumbering of degrees of freedom that better fits with the data layout in MatrixFree according to the given layout of data. Note that this function does not re-arrange the information stored in this class, but rather creates a renumbering for consumption of DoFHandler::renumber_dofs. To have any effect a MatrixFree object must be set up again using the renumbered DoFHandler and AffineConstraints. Note that if a DoFHandler calls DoFHandler::renumber_dofs, all information in MatrixFree becomes invalid.

◆ is_supported()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<int spacedim>
static bool MatrixFree< dim, Number, VectorizedArrayType >::is_supported ( const FiniteElement< dim, spacedim > &  fe)
static

Return whether a given FiniteElement fe is supported by this class.

◆ n_components()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::n_components ( ) const

Return the number of different DoFHandlers specified at initialization.

◆ n_base_elements()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::n_base_elements ( const unsigned int  dof_handler_index) const

For the finite element underlying the DoFHandler specified by dof_handler_index, return the number of base elements.

◆ n_physical_cells()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::n_physical_cells ( ) const

Return the number of cells this structure is based on. If you are using a usual DoFHandler, it corresponds to the number of (locally owned) active cells. Note that most data structures in this class do not directly act on this number but rather on n_cell_batches() which gives the number of cells as seen when lumping several cells together with vectorization.

◆ n_macro_cells()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::n_macro_cells ( ) const

◆ n_cell_batches()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::n_cell_batches ( ) const

Return the number of cell batches that this structure works on. The batches are formed by application of vectorization over several cells in general. The cell range in cell_loop runs from zero to n_cell_batches() (exclusive), so this is the appropriate size if you want to store arrays of data for all cells to be worked on. This number is approximately n_physical_cells()/VectorizedArray::size() (depending on how many cell batches that do not get filled up completely).

◆ n_ghost_cell_batches()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::n_ghost_cell_batches ( ) const

Return the number of additional cell batches that this structure keeps for face integration. Note that not all cells that are ghosted in the triangulation are kept in this data structure, but only the ones which are necessary for evaluating face integrals from both sides.

◆ n_inner_face_batches()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::n_inner_face_batches ( ) const

Return the number of interior face batches that this structure works on. The batches are formed by application of vectorization over several faces in general. The face range in loop runs from zero to n_inner_face_batches() (exclusive), so this is the appropriate size if you want to store arrays of data for all interior faces to be worked on.

◆ n_boundary_face_batches()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::n_boundary_face_batches ( ) const

Return the number of boundary face batches that this structure works on. The batches are formed by application of vectorization over several faces in general. The face range in loop runs from n_inner_face_batches() to n_inner_face_batches()+n_boundary_face_batches() (exclusive), so if you need to store arrays that hold data for all boundary faces but not the interior ones, this number gives the appropriate size.

◆ n_ghost_inner_face_batches()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::n_ghost_inner_face_batches ( ) const

Return the number of faces that are not processed locally but belong to locally owned faces.

◆ get_boundary_id()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
types::boundary_id MatrixFree< dim, Number, VectorizedArrayType >::get_boundary_id ( const unsigned int  macro_face) const

In order to apply different operators to different parts of the boundary, this method can be used to query the boundary id of a given face in the faces' own sorting by lanes in a VectorizedArray. Only valid for an index indicating a boundary face.

◆ get_faces_by_cells_boundary_id()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
std::array< types::boundary_id, VectorizedArrayType::size()> MatrixFree< dim, Number, VectorizedArrayType >::get_faces_by_cells_boundary_id ( const unsigned int  cell_batch_index,
const unsigned int  face_number 
) const

Return the boundary ids for the faces within a cell, using the cells' sorting by lanes in the VectorizedArray.

◆ get_dof_handler() [1/2]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
const DoFHandler< dim > & MatrixFree< dim, Number, VectorizedArrayType >::get_dof_handler ( const unsigned int  dof_handler_index = 0) const

Return the DoFHandler with the index as given to the respective std::vector argument in the reinit() function.

◆ get_dof_handler() [2/2]

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename DoFHandlerType >
const DoFHandlerType & MatrixFree< dim, Number, VectorizedArrayType >::get_dof_handler ( const unsigned int  dof_handler_index = 0) const

Return the DoFHandler with the index as given to the respective std::vector argument in the reinit() function. Note that if you want to call this function with a template parameter different than the default one, you will need to use the template before the function call, i.e., you will have something like matrix_free.template get_dof_handler<hp::DoFHandler<dim>>().

Deprecated:
Use the non-templated equivalent of this function.

◆ get_cell_iterator()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
DoFHandler< dim >::cell_iterator MatrixFree< dim, Number, VectorizedArrayType >::get_cell_iterator ( const unsigned int  cell_batch_index,
const unsigned int  lane_index,
const unsigned int  dof_handler_index = 0 
) const

Return the cell iterator in deal.II speak to a given cell batch (populating several lanes in a VectorizedArray) and the lane index within the vectorization across cells in the renumbering of this structure.

Note that the cell iterators in deal.II go through cells differently to what the cell loop of this class does. This is because several cells are processed together (vectorization across cells), and since cells with neighbors on different MPI processors need to be accessed at a certain time when accessing remote data and overlapping communication with computation.

◆ get_cell_level_and_index()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
std::pair< int, int > MatrixFree< dim, Number, VectorizedArrayType >::get_cell_level_and_index ( const unsigned int  cell_batch_index,
const unsigned int  lane_index 
) const

This returns the level and index for the cell that would be returned by get_cell_iterator() for the same arguments cell_batch_index and lane_index.

◆ get_face_iterator()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
std::pair< typename DoFHandler< dim >::cell_iterator, unsigned int > MatrixFree< dim, Number, VectorizedArrayType >::get_face_iterator ( const unsigned int  face_batch_index,
const unsigned int  lane_index,
const bool  interior = true,
const unsigned int  fe_component = 0 
) const

Return the cell iterator in deal.II speak to an interior/exterior cell of a face in a pair of a face batch and lane index. The second element of the pair is the face number so that the face iterator can be accessed: pair.first()->face(pair.second());

Note that the face iterators in deal.II go through cells differently to what the face/boundary loop of this class does. This is because several faces are worked on together (vectorization), and since faces with neighbor cells on different MPI processors need to be accessed at a certain time when accessing remote data and overlapping communication with computation.

◆ get_hp_cell_iterator()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
DoFHandler< dim >::active_cell_iterator MatrixFree< dim, Number, VectorizedArrayType >::get_hp_cell_iterator ( const unsigned int  cell_batch_index,
const unsigned int  lane_index,
const unsigned int  dof_handler_index = 0 
) const

Return the cell iterator in deal.II speak to a given cell batch (populating several lanes in a VectorizedArray) and the lane index within the vectorization across cells in the renumbering of this structure.

Note that the cell iterators in deal.II go through cells differently to what the cell loop of this class does. This is because several cells are processed together (vectorization across cells), and since cells with neighbors on different MPI processors need to be accessed at a certain time when accessing remote data and overlapping communication with computation.

Deprecated:
Use get_cell_iterator() instead.

◆ at_irregular_cell()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
bool MatrixFree< dim, Number, VectorizedArrayType >::at_irregular_cell ( const unsigned int  cell_batch_index) const

Since this class uses vectorized data types with usually more than one value in the data field, a situation might occur when some components of the vector type do not correspond to an actual cell in the mesh. When using only this class, one usually does not need to bother about that fact since the values are padded with zeros. However, when this class is mixed with deal.II access to cells, care needs to be taken. This function returns true if not all n_lanes cells for the given cell_batch_index correspond to actual cells of the mesh and some are merely present for padding reasons. To find out how many cells are actually used, use the function n_active_entries_per_cell_batch().

◆ n_components_filled()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::n_components_filled ( const unsigned int  cell_batch_number) const

◆ n_active_entries_per_cell_batch()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::n_active_entries_per_cell_batch ( const unsigned int  cell_batch_index) const

This query returns how many cells among the VectorizedArrayType::size() many cells within a cell batch to actual cells in the mesh, rather than being present for padding reasons. For most given cell batches in n_cell_batches(), this number is equal to VectorizedArrayType::size(), but there might be one or a few cell batches in the mesh (where the numbers do not add up) where only some of the cells within a batch are used, indicated by the function at_irregular_cell().

◆ n_active_entries_per_face_batch()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::n_active_entries_per_face_batch ( const unsigned int  face_batch_index) const

Use this function to find out how many faces over the length of vectorization data types correspond to real faces (both interior and boundary faces, as those use the same indexing but with different ranges) in the mesh. For most given indices in n_inner_faces_batches() and n_boundary_face_batches(), this is just vectorization_length many, but there might be one or a few meshes (where the numbers do not add up) where there are less such lanes filled.

◆ get_dofs_per_cell()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::get_dofs_per_cell ( const unsigned int  dof_handler_index = 0,
const unsigned int  hp_active_fe_index = 0 
) const

Return the number of degrees of freedom per cell for a given hp-index.

◆ get_n_q_points()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::get_n_q_points ( const unsigned int  quad_index = 0,
const unsigned int  hp_active_fe_index = 0 
) const

Return the number of quadrature points per cell for a given hp-index.

◆ get_dofs_per_face()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::get_dofs_per_face ( const unsigned int  dof_handler_index = 0,
const unsigned int  hp_active_fe_index = 0 
) const

Return the number of degrees of freedom on each face of the cell for given hp-index.

◆ get_n_q_points_face()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::get_n_q_points_face ( const unsigned int  quad_index = 0,
const unsigned int  hp_active_fe_index = 0 
) const

Return the number of quadrature points on each face of the cell for given hp-index.

◆ get_quadrature()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
const Quadrature< dim > & MatrixFree< dim, Number, VectorizedArrayType >::get_quadrature ( const unsigned int  quad_index = 0,
const unsigned int  hp_active_fe_index = 0 
) const

Return the quadrature rule for given hp-index.

◆ get_face_quadrature()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
const Quadrature< dim - 1 > & MatrixFree< dim, Number, VectorizedArrayType >::get_face_quadrature ( const unsigned int  quad_index = 0,
const unsigned int  hp_active_fe_index = 0 
) const

Return the quadrature rule for given hp-index.

◆ get_cell_category()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::get_cell_category ( const unsigned int  cell_batch_index) const

Return the category the current batch of cells was assigned to. Categories run between the given values in the field AdditionalData::cell_vectorization_category for non-hp-DoFHandler types and return the active FE index in the hp-adaptive case.

◆ get_face_category()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
std::pair< unsigned int, unsigned int > MatrixFree< dim, Number, VectorizedArrayType >::get_face_category ( const unsigned int  macro_face) const

Return the category on the cells on the two sides of the current batch of faces.

◆ indices_initialized()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
bool MatrixFree< dim, Number, VectorizedArrayType >::indices_initialized ( ) const

Queries whether or not the indexation has been set.

◆ mapping_initialized()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
bool MatrixFree< dim, Number, VectorizedArrayType >::mapping_initialized ( ) const

Queries whether or not the geometry-related information for the cells has been set.

◆ get_mg_level()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::get_mg_level ( ) const

Return the level of the mesh to be worked on. Returns numbers::invalid_unsigned_int if working on active cells.

◆ memory_consumption()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
std::size_t MatrixFree< dim, Number, VectorizedArrayType >::memory_consumption ( ) const

Return an approximation of the memory consumption of this class in bytes.

◆ print_memory_consumption()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename StreamType >
void MatrixFree< dim, Number, VectorizedArrayType >::print_memory_consumption ( StreamType &  out) const

Prints a detailed summary of memory consumption in the different structures of this class to the given output stream.

◆ print()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
void MatrixFree< dim, Number, VectorizedArrayType >::print ( std::ostream &  out) const

Prints a summary of this class to the given output stream. It is focused on the indices, and does not print all the data stored.

◆ get_task_info()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
const internal::MatrixFreeFunctions::TaskInfo & MatrixFree< dim, Number, VectorizedArrayType >::get_task_info ( ) const

Return information on task graph.

◆ get_mapping_info()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
const internal::MatrixFreeFunctions:: MappingInfo< dim, Number, VectorizedArrayType > & MatrixFree< dim, Number, VectorizedArrayType >::get_mapping_info ( ) const

◆ get_dof_info()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
const internal::MatrixFreeFunctions::DoFInfo & MatrixFree< dim, Number, VectorizedArrayType >::get_dof_info ( const unsigned int  dof_handler_index_component = 0) const

Return information on indexation degrees of freedom.

◆ n_constraint_pool_entries()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::n_constraint_pool_entries ( ) const

Return the number of weights in the constraint pool.

◆ constraint_pool_begin()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
const Number * MatrixFree< dim, Number, VectorizedArrayType >::constraint_pool_begin ( const unsigned int  pool_index) const

Return a pointer to the first number in the constraint pool data with index pool_index (to be used together with constraint_pool_end()).

◆ constraint_pool_end()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
const Number * MatrixFree< dim, Number, VectorizedArrayType >::constraint_pool_end ( const unsigned int  pool_index) const

Return a pointer to one past the last number in the constraint pool data with index pool_index (to be used together with constraint_pool_begin()).

◆ get_shape_info()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
const internal::MatrixFreeFunctions::ShapeInfo< VectorizedArrayType > & MatrixFree< dim, Number, VectorizedArrayType >::get_shape_info ( const unsigned int  dof_handler_index_component = 0,
const unsigned int  quad_index = 0,
const unsigned int  fe_base_element = 0,
const unsigned int  hp_active_fe_index = 0,
const unsigned int  hp_active_quad_index = 0 
) const

Return the unit cell information for given hp-index.

◆ get_face_info()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
const internal::MatrixFreeFunctions::FaceToCellTopology< VectorizedArrayType::size()> & MatrixFree< dim, Number, VectorizedArrayType >::get_face_info ( const unsigned int  face_batch_index) const

Return the connectivity information of a face.

◆ get_cell_and_face_to_plain_faces()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
const Table< 3, unsigned int > & MatrixFree< dim, Number, VectorizedArrayType >::get_cell_and_face_to_plain_faces ( ) const

Return the table that translates a triple of the macro cell number, the index of a face within a cell and the index within the cell batch of vectorization into the index within the faces array.

◆ acquire_scratch_data()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
AlignedVector< VectorizedArrayType > * MatrixFree< dim, Number, VectorizedArrayType >::acquire_scratch_data ( ) const

Obtains a scratch data object for internal use. Make sure to release it afterwards by passing the pointer you obtain from this object to the release_scratch_data() function. This interface is used by FEEvaluation objects for storing their data structures.

The organization of the internal data structure is a thread-local storage of a list of vectors. Multiple threads will each get a separate storage field and separate vectors, ensuring thread safety. The mechanism to acquire and release objects is similar to the mechanisms used for the local contributions of WorkStream, see the WorkStream paper.

◆ release_scratch_data()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
void MatrixFree< dim, Number, VectorizedArrayType >::release_scratch_data ( const AlignedVector< VectorizedArrayType > *  memory) const

Makes the object of the scratchpad available again.

◆ acquire_scratch_data_non_threadsafe()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
AlignedVector< Number > * MatrixFree< dim, Number, VectorizedArrayType >::acquire_scratch_data_non_threadsafe ( ) const

Obtains a scratch data object for internal use. Make sure to release it afterwards by passing the pointer you obtain from this object to the release_scratch_data_non_threadsafe() function. Note that, as opposed to acquire_scratch_data(), this method can only be called by a single thread at a time, but opposed to the acquire_scratch_data() it is also possible that the thread releasing the scratch data can be different than the one that acquired it.

◆ release_scratch_data_non_threadsafe()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
void MatrixFree< dim, Number, VectorizedArrayType >::release_scratch_data_non_threadsafe ( const AlignedVector< Number > *  memory) const

Makes the object of the scratch data available again.

◆ internal_reinit()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename number2 , int q_dim>
void MatrixFree< dim, Number, VectorizedArrayType >::internal_reinit ( const std::shared_ptr< hp::MappingCollection< dim > > &  mapping,
const std::vector< const DoFHandler< dim, dim > * > &  dof_handlers,
const std::vector< const AffineConstraints< number2 > * > &  constraint,
const std::vector< IndexSet > &  locally_owned_set,
const std::vector< hp::QCollection< q_dim > > &  quad,
const AdditionalData additional_data 
)
private

This is the actual reinit function that sets up the indices for the DoFHandler case.

◆ initialize_indices()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
template<typename number2 >
void MatrixFree< dim, Number, VectorizedArrayType >::initialize_indices ( const std::vector< const AffineConstraints< number2 > * > &  constraint,
const std::vector< IndexSet > &  locally_owned_set,
const AdditionalData additional_data 
)
private

Initializes the fields in DoFInfo together with the constraint pool that holds all different weights in the constraints (not part of DoFInfo because several DoFInfo classes can have the same weights which consequently only need to be stored once).

◆ initialize_dof_handlers()

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
void MatrixFree< dim, Number, VectorizedArrayType >::initialize_dof_handlers ( const std::vector< const DoFHandler< dim, dim > * > &  dof_handlers,
const AdditionalData additional_data 
)
private

Initializes the DoFHandlers based on a DoFHandler<dim> argument.

Member Data Documentation

◆ dimension

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
const unsigned int MatrixFree< dim, Number, VectorizedArrayType >::dimension = dim
static

The dimension set by the template argument dim.

Definition at line 133 of file matrix_free.h.

◆ dof_handlers

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
std::vector<SmartPointer<const DoFHandler<dim> > > MatrixFree< dim, Number, VectorizedArrayType >::dof_handlers
private

Pointers to the DoFHandlers underlying the current problem.

Definition at line 2087 of file matrix_free.h.

◆ dof_info

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
std::vector<internal::MatrixFreeFunctions::DoFInfo> MatrixFree< dim, Number, VectorizedArrayType >::dof_info
private

Contains the information about degrees of freedom on the individual cells and constraints.

Definition at line 2093 of file matrix_free.h.

◆ constraint_pool_data

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
std::vector<Number> MatrixFree< dim, Number, VectorizedArrayType >::constraint_pool_data
private

Contains the weights for constraints stored in DoFInfo. Filled into a separate field since several vector components might share similar weights, which reduces memory consumption. Moreover, it obviates template arguments on DoFInfo and keeps it a plain field of indices only.

Definition at line 2101 of file matrix_free.h.

◆ constraint_pool_row_index

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
std::vector<unsigned int> MatrixFree< dim, Number, VectorizedArrayType >::constraint_pool_row_index
private

Contains an indicator to the start of the ith index in the constraint pool data.

Definition at line 2107 of file matrix_free.h.

◆ mapping_info

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
internal::MatrixFreeFunctions::MappingInfo<dim, Number, VectorizedArrayType> MatrixFree< dim, Number, VectorizedArrayType >::mapping_info
private

Holds information on transformation of cells from reference cell to real cell that is needed for evaluating integrals.

Definition at line 2114 of file matrix_free.h.

◆ shape_info

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
Table<4, internal::MatrixFreeFunctions::ShapeInfo<VectorizedArrayType> > MatrixFree< dim, Number, VectorizedArrayType >::shape_info
private

Contains shape value information on the unit cell.

Definition at line 2120 of file matrix_free.h.

◆ cell_level_index

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
std::vector<std::pair<unsigned int, unsigned int> > MatrixFree< dim, Number, VectorizedArrayType >::cell_level_index
private

Describes how the cells are gone through. With the cell level (first index in this field) and the index within the level, one can reconstruct a deal.II cell iterator and use all the traditional things deal.II offers to do with cell iterators.

Definition at line 2128 of file matrix_free.h.

◆ cell_level_index_end_local

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::cell_level_index_end_local
private

For discontinuous Galerkin, the cell_level_index includes cells that are not on the local processor but that are needed to evaluate the cell integrals. In cell_level_index_end_local, we store the number of local cells.

Definition at line 2137 of file matrix_free.h.

◆ task_info

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
internal::MatrixFreeFunctions::TaskInfo MatrixFree< dim, Number, VectorizedArrayType >::task_info
private

Stores the basic layout of the cells and faces to be treated, including the task layout for the shared memory parallelization and possible overlaps between communications and computations with MPI.

Definition at line 2144 of file matrix_free.h.

◆ face_info

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
internal::MatrixFreeFunctions::FaceInfo<VectorizedArrayType::size()> MatrixFree< dim, Number, VectorizedArrayType >::face_info
private

Vector holding face information. Only initialized if build_face_info=true.

Definition at line 2151 of file matrix_free.h.

◆ indices_are_initialized

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
bool MatrixFree< dim, Number, VectorizedArrayType >::indices_are_initialized
private

Stores whether indices have been initialized.

Definition at line 2156 of file matrix_free.h.

◆ mapping_is_initialized

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
bool MatrixFree< dim, Number, VectorizedArrayType >::mapping_is_initialized
private

Stores whether indices have been initialized.

Definition at line 2161 of file matrix_free.h.

◆ scratch_pad

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
Threads::ThreadLocalStorage< std::list<std::pair<bool, AlignedVector<VectorizedArrayType> > > > MatrixFree< dim, Number, VectorizedArrayType >::scratch_pad
mutableprivate

Scratchpad memory for use in evaluation. We allow more than one evaluation object to attach to this field (this, the outer std::vector), so we need to keep tracked of whether a certain data field is already used (first part of pair) and keep a list of objects.

Definition at line 2172 of file matrix_free.h.

◆ scratch_pad_non_threadsafe

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
std::list<std::pair<bool, AlignedVector<Number> > > MatrixFree< dim, Number, VectorizedArrayType >::scratch_pad_non_threadsafe
mutableprivate

Scratchpad memory for use in evaluation and other contexts, non-thread safe variant.

Definition at line 2179 of file matrix_free.h.

◆ mg_level

template<int dim, typename Number = double, typename VectorizedArrayType = VectorizedArray<Number>>
unsigned int MatrixFree< dim, Number, VectorizedArrayType >::mg_level
private

Stored the level of the mesh to be worked on.

Definition at line 2184 of file matrix_free.h.


The documentation for this class was generated from the following file: