deal.II version GIT relicensing-1982-gbb401394a0 2024-10-13 08:40:01+00:00
|
#include <deal.II/lac/precondition_block.h>
Classes | |
class | const_iterator |
Public Types | |
using | size_type = types::global_dof_index |
Public Member Functions | |
template<typename number2 > | |
void | vmult (Vector< number2 > &, const Vector< number2 > &) const |
template<typename number2 > | |
void | Tvmult (Vector< number2 > &, const Vector< number2 > &) const |
template<typename number2 > | |
void | vmult_add (Vector< number2 > &, const Vector< number2 > &) const |
template<typename number2 > | |
void | Tvmult_add (Vector< number2 > &, const Vector< number2 > &) const |
template<typename number2 > | |
void | step (Vector< number2 > &dst, const Vector< number2 > &rhs) const |
template<typename number2 > | |
void | Tstep (Vector< number2 > &dst, const Vector< number2 > &rhs) const |
const_iterator | begin () const |
const_iterator | end () const |
const_iterator | begin (const size_type r) const |
const_iterator | end (const size_type r) 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 | number = typename MatrixType::value_type |
using | map_value_type = decltype(counter_map)::value_type |
using | map_iterator = decltype(counter_map)::iterator |
using | value_type = inverse_type |
enum | Inversion { gauss_jordan , householder , svd } |
Private Member Functions | |
template<typename number2 > | |
void | do_vmult (Vector< number2 > &, const Vector< number2 > &, bool adding) const |
void | check_no_subscribers () const noexcept |
void | initialize (const MatrixType &A, const AdditionalData parameters) |
void | initialize (const MatrixType &A, const std::vector< size_type > &permutation, const std::vector< size_type > &inverse_permutation, const AdditionalData parameters) |
void | set_permutation (const std::vector< size_type > &permutation, const std::vector< size_type > &inverse_permutation) |
void | invert_permuted_diagblocks () |
void | clear () |
bool | empty () const |
value_type | el (size_type i, size_type j) const |
void | invert_diagblocks () |
template<typename number2 > | |
void | forward_step (Vector< number2 > &dst, const Vector< number2 > &prev, const Vector< number2 > &src, const bool transpose_diagonal) const |
template<typename number2 > | |
void | backward_step (Vector< number2 > &dst, const Vector< number2 > &prev, const Vector< number2 > &src, const bool transpose_diagonal) const |
size_type | block_size () const |
std::size_t | memory_consumption () const |
void | reinit (unsigned int nblocks, size_type blocksize, bool compress, Inversion method=gauss_jordan) |
void | inverses_computed (bool are_they) |
bool | same_diagonal () const |
bool | store_diagonals () const |
bool | inverses_ready () const |
unsigned int | size () const |
template<typename number2 > | |
void | inverse_vmult (size_type i, Vector< number2 > &dst, const Vector< number2 > &src) const |
template<typename number2 > | |
void | inverse_Tvmult (size_type i, Vector< number2 > &dst, const Vector< number2 > &src) const |
FullMatrix< number > & | inverse (size_type i) |
const FullMatrix< number > & | inverse (size_type i) const |
Householder< number > & | inverse_householder (size_type i) |
const Householder< number > & | inverse_householder (size_type i) const |
LAPACKFullMatrix< number > & | inverse_svd (size_type i) |
const LAPACKFullMatrix< number > & | inverse_svd (size_type i) const |
FullMatrix< number > & | diagonal (size_type i) |
const FullMatrix< number > & | diagonal (size_type i) const |
void | log_statistics () const |
Static Private Member Functions | |
static ::ExceptionBase & | ExcWrongBlockSize (int arg1, int arg2) |
static ::ExceptionBase & | ExcInverseMatricesAlreadyExist () |
static ::ExceptionBase & | ExcDiagonalsNotStored () |
static ::ExceptionBase & | ExcInverseNotAvailable () |
Private Attributes | |
std::atomic< unsigned int > | counter |
std::map< std::string, unsigned int > | counter_map |
std::vector< std::atomic< bool > * > | validity_pointers |
const std::type_info * | object_info |
size_type | blocksize |
ObserverPointer< const MatrixType, PreconditionBlock< MatrixType, inverse_type > > | A |
double | relaxation |
std::vector< size_type > | permutation |
std::vector< size_type > | inverse_permutation |
Inversion | inversion |
unsigned int | n_diagonal_blocks |
std::vector< FullMatrix< number > > | var_inverse_full |
std::vector< Householder< number > > | var_inverse_householder |
std::vector< LAPACKFullMatrix< number > > | var_inverse_svd |
std::vector< FullMatrix< number > > | var_diagonal |
bool | var_store_diagonals |
bool | var_same_diagonal |
bool | var_inverses_ready |
Static Private Attributes | |
static std::mutex | mutex |
Friends | |
class | Accessor |
class | const_iterator |
Block Jacobi preconditioning. See PreconditionBlock for requirements on the matrix. This class satisfies the relaxation concept.
<float> and <double>
; others can be generated in application programs (see the section on Template instantiations in the manual). Definition at line 378 of file precondition_block.h.
|
private |
Define number type of matrix.
Definition at line 386 of file precondition_block.h.
using PreconditionBlockJacobi< MatrixType, inverse_type >::size_type = types::global_dof_index |
Declare type for container size.
Definition at line 392 of file precondition_block.h.
|
privateinherited |
The data type used in counter_map.
Definition at line 231 of file enable_ref_counting_by_observer_pointer.h.
|
privateinherited |
The iterator type used in counter_map.
Definition at line 236 of file enable_ref_counting_by_observer_pointer.h.
|
privateinherited |
Value type for inverse matrices.
Definition at line 93 of file precondition_block.h.
|
inherited |
Choose a method for inverting the blocks, and thus the data type for the inverses.
Enumerator | |
---|---|
gauss_jordan | Use the standard Gauss-Jacobi method implemented in FullMatrix::inverse(). |
householder | Use QR decomposition of the Householder class. |
svd | Use the singular value decomposition of LAPACKFullMatrix. |
Definition at line 70 of file precondition_block_base.h.
template void PreconditionBlockJacobi< MatrixType, inverse_type >::vmult< double > | ( | Vector< number2 > & | , |
const Vector< number2 > & | |||
) | const |
Execute block Jacobi preconditioning.
This function will automatically use the inverse matrices if they exist, if not then BlockJacobi will need much time inverting the diagonal block matrices in each preconditioning step.
template void PreconditionBlockJacobi< MatrixType, inverse_type >::Tvmult< double > | ( | Vector< number2 > & | , |
const Vector< number2 > & | |||
) | const |
Same as vmult
, since Jacobi is symmetric.
template void PreconditionBlockJacobi< MatrixType, inverse_type >::vmult_add< double > | ( | Vector< number2 > & | , |
const Vector< number2 > & | |||
) | const |
Execute block Jacobi preconditioning, adding to dst
.
This function will automatically use the inverse matrices if they exist, if not then BlockJacobi will need much time inverting the diagonal block matrices in each preconditioning step.
template void PreconditionBlockJacobi< MatrixType, inverse_type >::Tvmult_add< double > | ( | Vector< number2 > & | , |
const Vector< number2 > & | |||
) | const |
Same as vmult_add
, since Jacobi is symmetric.
void PreconditionBlockJacobi< MatrixType, inverse_type >::step | ( | Vector< number2 > & | dst, |
const Vector< number2 > & | rhs | ||
) | const |
Perform one step of the Jacobi iteration.
void PreconditionBlockJacobi< MatrixType, inverse_type >::Tstep | ( | Vector< number2 > & | dst, |
const Vector< number2 > & | rhs | ||
) | const |
Perform one step of the Jacobi iteration.
const_iterator PreconditionBlockJacobi< MatrixType, inverse_type >::begin | ( | ) | const |
Iterator starting at the first entry.
const_iterator PreconditionBlockJacobi< MatrixType, inverse_type >::end | ( | ) | const |
Final iterator.
const_iterator PreconditionBlockJacobi< MatrixType, inverse_type >::begin | ( | const size_type | r | ) | const |
Iterator starting at the first entry of row r
.
const_iterator PreconditionBlockJacobi< MatrixType, inverse_type >::end | ( | const size_type | r | ) | const |
Final iterator of row r
.
|
private |
Actual implementation of the preconditioner.
Depending on adding
, the result of preconditioning is added to the destination vector.
|
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_ref_counting_by_observer.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_ref_counting_by_observer.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 315 of file enable_ref_counting_by_observer_pointer.h.
|
inlineinherited |
List the subscribers to the input stream
.
Definition at line 332 of file enable_ref_counting_by_observer_pointer.h.
|
inherited |
List the subscribers to deallog
.
Definition at line 199 of file enable_ref_counting_by_observer.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 324 of file enable_ref_counting_by_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_ref_counting_by_observer.cc.
|
inherited |
Initialize matrix and block size. We store the matrix and the block size in the preconditioner object. In a second step, the inverses of the diagonal blocks may be computed.
Additionally, a relaxation parameter for derived classes may be provided.
|
protectedinherited |
Initialize matrix and block size for permuted preconditioning. Additionally to the parameters of the other initialize() function, we hand over two index vectors with the permutation and its inverse. For the meaning of these vectors see PreconditionBlockSOR.
In a second step, the inverses of the diagonal blocks may be computed. Make sure you use invert_permuted_diagblocks() to yield consistent data.
Additionally, a relaxation parameter for derived classes may be provided.
|
protectedinherited |
Set either the permutation of rows or the permutation of blocks, depending on the size of the vector.
If the size of the permutation vectors is equal to the dimension of the linear system, it is assumed that rows are permuted individually. In this case, set_permutation() must be called before initialize(), since the diagonal blocks are built from the permuted entries of the matrix.
If the size of the permutation vector is not equal to the dimension of the system, the diagonal blocks are computed from the unpermuted entries. Instead, the relaxation methods step() and Tstep() are executed applying the blocks in the order given by the permutation vector. They will throw an exception if length of this vector is not equal to the number of blocks.
|
protectedinherited |
Replacement of invert_diagblocks() for permuted preconditioning.
|
inherited |
Deletes the inverse diagonal block matrices if existent, sets the blocksize to 0, hence leaves the class in the state that it had directly after calling the constructor.
|
inherited |
Check whether the object is empty.
|
inherited |
Read-only access to entries. This function is only possible if the inverse diagonal blocks are stored.
|
inherited |
Stores the inverse of the diagonal blocks in inverse
. This costs some additional memory - for DG methods about 1/3 (for double inverses) or 1/6 (for float inverses) of that used for the matrix - but it makes the preconditioning much faster.
It is not allowed to call this function twice (will produce an error) before a call of clear(...)
because at the second time there already exist the inverse matrices.
After this function is called, the lock on the matrix given through the use_matrix
function is released, i.e. you may overwrite of delete it. You may want to do this in case you use this matrix to precondition another matrix.
|
inherited |
Perform one block relaxation step in forward numbering.
Depending on the arguments dst
and pref
, this performs an SOR step (both reference the same vector) of a Jacobi step (both different vectors). For the Jacobi step, the calling function must copy dst
to pref
after this.
|
inherited |
Perform one block relaxation step in backward numbering.
Depending on the arguments dst
and pref
, this performs an SOR step (both reference the same vector) of a Jacobi step (both different vectors). For the Jacobi step, the calling function must copy dst
to pref
after this.
|
inherited |
Return the size of the blocks.
|
inherited |
Determine an estimate for the memory consumption (in bytes) of this object.
|
inlineinherited |
Resize to this number of diagonal blocks with the given block size. If compress
is true, then only one block will be stored.
Definition at line 333 of file precondition_block_base.h.
|
inlineinherited |
Tell the class that inverses are computed.
Definition at line 598 of file precondition_block_base.h.
|
inlineinherited |
Does the matrix use only one diagonal block?
Definition at line 582 of file precondition_block_base.h.
|
inlineinherited |
Check, whether diagonal blocks (not their inverses) should be stored.
Definition at line 590 of file precondition_block_base.h.
|
inlineinherited |
Return true, if inverses are ready for use.
Definition at line 606 of file precondition_block_base.h.
|
inlineinherited |
The number of blocks.
Definition at line 411 of file precondition_block_base.h.
|
inlineinherited |
Multiply with the inverse block at position i
.
Definition at line 419 of file precondition_block_base.h.
|
inlineinherited |
Multiply with the transposed inverse block at position i
.
Definition at line 448 of file precondition_block_base.h.
|
inlineinherited |
Access to the inverse diagonal blocks if Inversion is gauss_jordan.
Definition at line 526 of file precondition_block_base.h.
|
inlineinherited |
Access to the inverse diagonal blocks.
Definition at line 476 of file precondition_block_base.h.
|
inlineinherited |
Access to the inverse diagonal blocks if Inversion is householder.
Definition at line 540 of file precondition_block_base.h.
|
inlineinherited |
Access to the inverse diagonal blocks if Inversion is householder.
Definition at line 488 of file precondition_block_base.h.
|
inlineinherited |
Access to the inverse diagonal blocks if Inversion is householder.
Definition at line 554 of file precondition_block_base.h.
|
inlineinherited |
Access to the inverse diagonal blocks if Inversion is householder.
Definition at line 500 of file precondition_block_base.h.
|
inlineinherited |
Access to the diagonal blocks.
Definition at line 568 of file precondition_block_base.h.
|
inlineinherited |
Access to the diagonal blocks.
Definition at line 512 of file precondition_block_base.h.
|
inlineinherited |
Print some statistics about the inverses to deallog
. Output depends on Inversion. It is richest for svd, where we obtain statistics on extremal singular values and condition numbers.
Definition at line 614 of file precondition_block_base.h.
|
friend |
Definition at line 614 of file precondition_block.h.
|
friend |
Definition at line 615 of file precondition_block.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 220 of file enable_ref_counting_by_observer_pointer.h.
|
mutableprivateinherited |
In this map, we count subscriptions for each different identification string supplied to subscribe().
Definition at line 226 of file enable_ref_counting_by_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 242 of file enable_ref_counting_by_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 250 of file enable_ref_counting_by_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 273 of file enable_ref_counting_by_observer_pointer.h.
|
protectedinherited |
Size of the blocks. Each diagonal block is assumed to be of the same size.
Definition at line 337 of file precondition_block.h.
|
protectedinherited |
Pointer to the matrix. Make sure that the matrix exists as long as this class needs it, i.e. until calling invert_diagblocks
, or (if the inverse matrices should not be stored) until the last call of the preconditoining vmult
function of the derived classes.
Definition at line 346 of file precondition_block.h.
|
protectedinherited |
Relaxation parameter to be used by derived classes.
Definition at line 350 of file precondition_block.h.
|
protectedinherited |
The permutation vector
Definition at line 355 of file precondition_block.h.
|
protectedinherited |
The inverse permutation vector
Definition at line 360 of file precondition_block.h.
|
protectedinherited |
The method used for inverting blocks.
Definition at line 243 of file precondition_block_base.h.
|
privateinherited |
The number of (inverse) diagonal blocks, if only one is stored.
Definition at line 249 of file precondition_block_base.h.
|
privateinherited |
Storage of the inverse matrices of the diagonal blocks matrices as FullMatrix<number>
matrices, if Inversion gauss_jordan is used. Using number=float
saves memory in comparison with number=double
, but may introduce numerical instability.
Definition at line 257 of file precondition_block_base.h.
|
privateinherited |
Storage of the inverse matrices of the diagonal blocks matrices as Householder
matrices if Inversion householder is used. Using number=float
saves memory in comparison with number=double
, but may introduce numerical instability.
Definition at line 265 of file precondition_block_base.h.
|
privateinherited |
Storage of the inverse matrices of the diagonal blocks matrices as LAPACKFullMatrix
matrices if Inversion svd is used. Using number=float
saves memory in comparison with number=double
, but may introduce numerical instability.
Definition at line 273 of file precondition_block_base.h.
|
privateinherited |
Storage of the original diagonal blocks.
Used by the blocked SSOR method.
Definition at line 280 of file precondition_block_base.h.
|
privateinherited |
This is true, if the field var_diagonal is to be used.
Definition at line 286 of file precondition_block_base.h.
|
privateinherited |
This is true, if only one inverse is stored.
Definition at line 291 of file precondition_block_base.h.
|
privateinherited |
The inverse matrices are usable. Set by the parent class via inverses_computed().
Definition at line 297 of file precondition_block_base.h.