deal.II version GIT relicensing-2165-gc91f007519 2024-11-20 01:40:00+00:00
|
#include <deal.II/matrix_free/portable_matrix_free.h>
Classes | |
struct | AdditionalData |
struct | Data |
Public Types | |
using | jacobian_type = Tensor< 2, dim, Tensor< 1, dim, Number > > |
using | point_type = Point< dim, Number > |
using | CellFilter = FilteredIterator< typename DoFHandler< dim >::active_cell_iterator > |
Public Member Functions | |
MatrixFree () | |
unsigned int | get_padding_length () const |
template<typename IteratorFiltersType > | |
void | reinit (const Mapping< dim > &mapping, const DoFHandler< dim > &dof_handler, const AffineConstraints< Number > &constraints, const Quadrature< 1 > &quad, const IteratorFiltersType &iterator_filter, const AdditionalData &additional_data=AdditionalData()) |
void | reinit (const Mapping< dim > &mapping, const DoFHandler< dim > &dof_handler, const AffineConstraints< Number > &constraints, const Quadrature< 1 > &quad, const AdditionalData &additional_data=AdditionalData()) |
void | reinit (const DoFHandler< dim > &dof_handler, const AffineConstraints< Number > &constraints, const Quadrature< 1 > &quad, const AdditionalData &additional_data=AdditionalData()) |
Data | get_data (unsigned int color) const |
template<typename Functor , typename VectorType > | |
void | cell_loop (const Functor &func, const VectorType &src, VectorType &dst) const |
template<typename Functor > | |
void | evaluate_coefficients (Functor func) const |
template<typename VectorType > | |
void | copy_constrained_values (const VectorType &src, VectorType &dst) const |
template<typename VectorType > | |
void | set_constrained_values (const Number val, VectorType &dst) const |
template<typename MemorySpaceType > | |
void | initialize_dof_vector (LinearAlgebra::distributed::Vector< Number, MemorySpaceType > &vec) const |
const std::vector< std::vector< CellFilter > > & | get_colored_graph () const |
const std::shared_ptr< const Utilities::MPI::Partitioner > & | get_vector_partitioner () const |
const DoFHandler< dim > & | get_dof_handler () const |
std::size_t | memory_consumption () const |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
EnableObserverPointer functionality | |
Classes derived from EnableObserverPointer provide a facility to subscribe to this object. This is mostly used by the ObserverPointer class. | |
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 |
Static Public Member Functions | |
static ::ExceptionBase & | ExcInUse (int arg1, std::string arg2, std::string arg3) |
static ::ExceptionBase & | ExcNoSubscriber (std::string arg1, std::string arg2) |
Private Types | |
using | map_value_type = decltype(counter_map)::value_type |
using | map_iterator = decltype(counter_map)::iterator |
Private Member Functions | |
template<typename IteratorFiltersType > | |
void | internal_reinit (const Mapping< dim > &mapping, const DoFHandler< dim > &dof_handler, const AffineConstraints< Number > &constraints, const Quadrature< 1 > &quad, const IteratorFiltersType &iterator_filter, const std::shared_ptr< const MPI_Comm > &comm, const AdditionalData additional_data) |
template<typename Functor , typename VectorType > | |
void | serial_cell_loop (const Functor &func, const VectorType &src, VectorType &dst) const |
template<typename Functor > | |
void | distributed_cell_loop (const Functor &func, const LinearAlgebra::distributed::Vector< Number, MemorySpace::Default > &src, LinearAlgebra::distributed::Vector< Number, MemorySpace::Default > &dst) const |
void | check_no_subscribers () const noexcept |
Static Private Attributes | |
static std::mutex | mutex |
Friends | |
class | internal::ReinitHelper< dim, Number > |
Related Symbols | |
(Note that these are not member symbols.) | |
template<int dim, typename Number > | |
DataHost< dim, Number > | copy_mf_data_to_host (const typename::Portable::MatrixFree< dim, Number >::Data &data, const UpdateFlags &update_flags) |
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.
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.
This class implements 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 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 Portable::FEEvaluation.
This class traverse the cells in a different order than the usual Triangulation class in deal.II.
Definition at line 89 of file portable_matrix_free.h.
using Portable::MatrixFree< dim, Number >::jacobian_type = Tensor<2, dim, Tensor<1, dim, Number> > |
Definition at line 92 of file portable_matrix_free.h.
using Portable::MatrixFree< dim, Number >::point_type = Point<dim, Number> |
Definition at line 93 of file portable_matrix_free.h.
using Portable::MatrixFree< dim, Number >::CellFilter = FilteredIterator<typename DoFHandler<dim>::active_cell_iterator> |
Definition at line 94 of file portable_matrix_free.h.
|
privateinherited |
The data type used in counter_map.
Definition at line 238 of file enable_observer_pointer.h.
|
privateinherited |
The iterator type used in counter_map.
Definition at line 243 of file enable_observer_pointer.h.
Portable::MatrixFree< dim, Number >::MatrixFree | ( | ) |
Default constructor.
unsigned int Portable::MatrixFree< dim, Number >::get_padding_length | ( | ) | const |
Return the length of the padding.
void Portable::MatrixFree< dim, Number >::reinit | ( | const Mapping< dim > & | mapping, |
const DoFHandler< dim > & | dof_handler, | ||
const AffineConstraints< Number > & | constraints, | ||
const Quadrature< 1 > & | quad, | ||
const IteratorFiltersType & | iterator_filter, | ||
const AdditionalData & | additional_data = AdditionalData() |
||
) |
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 transformation from unit to real cell, and the finite element underlying the DoFHandler together with the quadrature formula describe the local operations. This function takes an IteratorFilters object (predicate) to loop over a subset of the active cells. When using MPI, the predicate should filter out non locally owned cells.
void Portable::MatrixFree< dim, Number >::reinit | ( | const Mapping< dim > & | mapping, |
const DoFHandler< dim > & | dof_handler, | ||
const AffineConstraints< Number > & | constraints, | ||
const Quadrature< 1 > & | quad, | ||
const AdditionalData & | additional_data = AdditionalData() |
||
) |
Same as above using Iterators::LocallyOwnedCell() as predicate.
void Portable::MatrixFree< dim, Number >::reinit | ( | const DoFHandler< dim > & | dof_handler, |
const AffineConstraints< Number > & | constraints, | ||
const Quadrature< 1 > & | quad, | ||
const AdditionalData & | additional_data = AdditionalData() |
||
) |
Initializes the data structures. Same as above but using a Q1 mapping.
Data Portable::MatrixFree< dim, Number >::get_data | ( | unsigned int | color | ) | const |
Return the Data structure associated with color
.
void Portable::MatrixFree< dim, Number >::cell_loop | ( | const Functor & | func, |
const VectorType & | src, | ||
VectorType & | dst | ||
) | const |
This method runs the loop over all cells and apply the local operation on each element in parallel. func
is a functor which is applied on each color.
func
needs to define
void Portable::MatrixFree< dim, Number >::evaluate_coefficients | ( | Functor | func | ) | const |
This method runs the loop over all cells and apply the local operation on each element in parallel. This function is very similar to cell_loop() but it uses a simpler functor.
func
needs to define
void Portable::MatrixFree< dim, Number >::copy_constrained_values | ( | const VectorType & | src, |
VectorType & | dst | ||
) | const |
Copy the values of the constrained entries from src
to dst
. This is used to impose zero Dirichlet boundary condition.
void Portable::MatrixFree< dim, Number >::set_constrained_values | ( | const Number | val, |
VectorType & | dst | ||
) | const |
Set the entries in dst
corresponding to constrained values to val
. The main purpose of this function is to set the constrained entries of the source vector used in cell_loop() to zero.
void Portable::MatrixFree< dim, Number >::initialize_dof_vector | ( | LinearAlgebra::distributed::Vector< Number, MemorySpaceType > & | vec | ) | const |
Initialize a distributed vector. The local elements correspond to the locally owned degrees of freedom and the ghost elements correspond to the (additional) locally relevant dofs.
const std::vector< std::vector< CellFilter > > & Portable::MatrixFree< dim, Number >::get_colored_graph | ( | ) | const |
Return the colored graph of locally owned active cells.
const std::shared_ptr< const Utilities::MPI::Partitioner > & Portable::MatrixFree< dim, Number >::get_vector_partitioner | ( | ) | 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.
const DoFHandler< dim > & Portable::MatrixFree< dim, Number >::get_dof_handler | ( | ) | const |
Return the DoFHandler.
std::size_t Portable::MatrixFree< dim, Number >::memory_consumption | ( | ) | const |
Return an approximation of the memory consumption of this class in bytes.
|
private |
Initializes the data structures.
|
private |
Helper function. Loop over all the cells and apply the functor on each element in parallel. This function is used when MPI is not used.
|
private |
Helper function. Loop over all the cells and apply the functor on each element in parallel. This function is used when MPI is used.
|
inherited |
Subscribes a user of the object by storing the pointer validity
. The subscriber may be identified by text supplied as identifier
.
Definition at line 131 of file enable_observer_pointer.cc.
|
inherited |
Unsubscribes a user from the object.
identifier
and the validity
pointer must be the same as the one supplied to subscribe(). Definition at line 151 of file enable_observer_pointer.cc.
|
inlineinherited |
Return the present number of subscriptions to this object. This allows to use this class for reference counted lifetime determination where the last one to unsubscribe also deletes the object.
Definition at line 322 of file enable_observer_pointer.h.
|
inlineinherited |
List the subscribers to the input stream
.
Definition at line 339 of file enable_observer_pointer.h.
|
inherited |
List the subscribers to deallog
.
Definition at line 199 of file enable_observer_pointer.cc.
|
inlineinherited |
Read or write the data of this object to or from a stream for the purpose of serialization using the BOOST serialization library.
This function does not actually serialize any of the member variables of this class. The reason is that what this class stores is only who subscribes to this object, but who does so at the time of storing the contents of this object does not necessarily have anything to do with who subscribes to the object when it is restored. Consequently, we do not want to overwrite the subscribers at the time of restoring, and then there is no reason to write the subscribers out in the first place.
Definition at line 331 of file enable_observer_pointer.h.
|
privatenoexceptinherited |
Check that there are no objects subscribing to this object. If this check passes then it is safe to destroy the current object. It this check fails then this function will either abort or print an error message to deallog (by using the AssertNothrow mechanism), but will not throw an exception.
Definition at line 53 of file enable_observer_pointer.cc.
|
friend |
Definition at line 611 of file portable_matrix_free.h.
|
related |
Copy data
from the device to the host. update_flags
should be identical to the one used in MatrixFree::AdditionalData.
Definition at line 759 of file portable_matrix_free.h.
|
private |
Unique ID associated with the object.
Definition at line 459 of file portable_matrix_free.h.
|
private |
If true, use graph coloring. Otherwise, use atomic operations. Graph coloring ensures bitwise reproducibility but is slower on Pascal and newer architectures.
Definition at line 466 of file portable_matrix_free.h.
|
private |
Overlap MPI communications with computation. This requires device-aware MPI and use_coloring must be false.
Definition at line 472 of file portable_matrix_free.h.
|
private |
Total number of degrees of freedom.
Definition at line 477 of file portable_matrix_free.h.
|
private |
Degree of the finite element used.
Definition at line 482 of file portable_matrix_free.h.
|
private |
Number of components.
Definition at line 487 of file portable_matrix_free.h.
|
private |
Number of scalar degrees of freedom per cell.
Definition at line 492 of file portable_matrix_free.h.
|
private |
Number of degrees of freedom per cell.
Definition at line 497 of file portable_matrix_free.h.
|
private |
Number of constrained degrees of freedom.
Definition at line 502 of file portable_matrix_free.h.
|
private |
Number of quadrature points per cells.
Definition at line 507 of file portable_matrix_free.h.
|
private |
Number of colors produced by the graph coloring algorithm.
Definition at line 512 of file portable_matrix_free.h.
|
private |
Number of cells in each color.
Definition at line 517 of file portable_matrix_free.h.
|
private |
Vector of Kokkos::View to the quadrature points associated to the cells of each color.
Definition at line 524 of file portable_matrix_free.h.
|
private |
Map the position in the local vector to the position in the global vector.
Definition at line 532 of file portable_matrix_free.h.
|
private |
Vector of Kokkos::View of the inverse Jacobian associated to the cells of each color.
Definition at line 540 of file portable_matrix_free.h.
|
private |
Vector of Kokkos::View to the Jacobian times the weights associated to the cells of each color.
Definition at line 547 of file portable_matrix_free.h.
|
private |
Kokkos::View to the constrained degrees of freedom.
Definition at line 553 of file portable_matrix_free.h.
|
private |
Mask deciding where constraints are set on a given cell.
Definition at line 561 of file portable_matrix_free.h.
|
private |
Values of the shape functions.
Definition at line 566 of file portable_matrix_free.h.
|
private |
Gradients of the shape functions.
Definition at line 571 of file portable_matrix_free.h.
|
private |
Gradients of the shape functions for collocation methods.
Definition at line 577 of file portable_matrix_free.h.
|
private |
Weights used when resolving hanginf nodes.
Definition at line 583 of file portable_matrix_free.h.
|
private |
Shared pointer to a Partitioner for distributed Vectors used in cell_loop. When MPI is not used the pointer is null.
Definition at line 589 of file portable_matrix_free.h.
|
private |
Length of the padding (closest power of two larger than or equal to the number of thread).
Definition at line 596 of file portable_matrix_free.h.
|
private |
Row start of each color.
Definition at line 601 of file portable_matrix_free.h.
|
private |
Pointer to the DoFHandler associated with the object.
Definition at line 606 of file portable_matrix_free.h.
|
private |
Colored graphed of locally owned active cells.
Definition at line 611 of file portable_matrix_free.h.
|
mutableprivateinherited |
Store the number of objects which subscribed to this object. Initially, this number is zero, and upon destruction it shall be zero again (i.e. all objects which subscribed should have unsubscribed again).
The creator (and owner) of an object is counted in the map below if HE manages to supply identification.
We use the mutable
keyword in order to allow subscription to constant objects also.
This counter may be read from and written to concurrently in multithreaded code: hence we use the std::atomic
class template.
Definition at line 227 of file enable_observer_pointer.h.
|
mutableprivateinherited |
In this map, we count subscriptions for each different identification string supplied to subscribe().
Definition at line 233 of file enable_observer_pointer.h.
|
mutableprivateinherited |
In this vector, we store pointers to the validity bool in the ObserverPointer objects that subscribe to this class.
Definition at line 249 of file enable_observer_pointer.h.
|
mutableprivateinherited |
Pointer to the typeinfo object of this object, from which we can later deduce the class name. Since this information on the derived class is neither available in the destructor, nor in the constructor, we obtain it in between and store it here.
Definition at line 257 of file enable_observer_pointer.h.
|
staticprivateinherited |
A mutex used to ensure data consistency when accessing the mutable
members of this class. This lock is used in the subscribe() and unsubscribe() functions, as well as in list_subscribers()
.
Definition at line 280 of file enable_observer_pointer.h.