deal.II version GIT relicensing-2114-gd9582acac8 2024-11-06 19:20:00+00:00
\(\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\}}\)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
RelaxationBlockSOR< MatrixType, InverseNumberType, VectorType > Class Template Reference

#include <deal.II/lac/relaxation_block.h>

Inheritance diagram for RelaxationBlockSOR< MatrixType, InverseNumberType, VectorType >:
Inheritance graph
[legend]

Public Types

using number = typename MatrixType::value_type
 

Public Member Functions

void step (VectorType &dst, const VectorType &rhs) const
 
void Tstep (VectorType &dst, const VectorType &rhs) const
 
void vmult (VectorType &dst, const VectorType &rhs) const
 
void Tvmult (VectorType &dst, const VectorType &rhs) 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 ::ExceptionBaseExcInUse (int arg1, std::string arg2, std::string arg3)
 
static ::ExceptionBaseExcNoSubscriber (std::string arg1, std::string arg2)
 

Protected Types

using size_type = types::global_dof_index
 
enum  Inversion { gauss_jordan , householder , svd }
 

Protected Member Functions

void initialize (const MatrixType &A, const AdditionalData &parameters)
 
void clear ()
 
void invert_diagblocks ()
 
void do_step (VectorType &dst, const VectorType &prev, const VectorType &src, const bool backward) 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
 
std::size_t memory_consumption () const
 

Static Protected Member Functions

static ::ExceptionBaseExcDiagonalsNotStored ()
 
static ::ExceptionBaseExcInverseNotAvailable ()
 

Protected Attributes

ObserverPointer< const MatrixType, RelaxationBlock< MatrixType, InverseNumberType, VectorType > > A
 
ObserverPointer< const AdditionalData, RelaxationBlock< MatrixType, InverseNumberType, VectorType > > additional_data
 
Inversion inversion
 

Private Types

using map_value_type = decltype(counter_map)::value_type
 
using map_iterator = decltype(counter_map)::iterator
 
using value_type = InverseNumberType
 

Private Member Functions

void check_no_subscribers () const noexcept
 
void block_kernel (const size_type block_begin, const size_type block_end)
 

Private Attributes

std::atomic< unsigned intcounter
 
std::map< std::string, unsigned intcounter_map
 
std::vector< std::atomic< bool > * > validity_pointers
 
const std::type_info * object_info
 
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
 

Detailed Description

template<typename MatrixType, typename InverseNumberType = typename MatrixType::value_type, typename VectorType = Vector<double>>
class RelaxationBlockSOR< MatrixType, InverseNumberType, VectorType >

Block Gauss-Seidel method with possibly overlapping blocks.

This class implements the step() and Tstep() functions expected by the relaxation concept. They perform a multiplicative Schwarz method on the blocks provided in the block list of AdditionalData. Differing from PreconditionBlockSOR, these blocks may be of varying size, non-contiguous, and overlapping. On the other hand, this class does not implement the preconditioner interface expected by Solver objects.

Definition at line 381 of file relaxation_block.h.

Member Typedef Documentation

◆ number

template<typename MatrixType , typename InverseNumberType = typename MatrixType::value_type, typename VectorType = Vector<double>>
using RelaxationBlockSOR< MatrixType, InverseNumberType, VectorType >::number = typename MatrixType::value_type

Default constructor. Define number type of matrix.

Definition at line 394 of file relaxation_block.h.

◆ map_value_type

The data type used in counter_map.

Definition at line 238 of file enable_observer_pointer.h.

◆ map_iterator

The iterator type used in counter_map.

Definition at line 243 of file enable_observer_pointer.h.

◆ value_type

template<typename MatrixType , typename InverseNumberType = typename MatrixType::value_type, typename VectorType = Vector<double>>
using RelaxationBlock< MatrixType, InverseNumberType, VectorType >::value_type = InverseNumberType
privateinherited

Value type for inverse matrices.

Definition at line 66 of file relaxation_block.h.

◆ size_type

template<typename MatrixType , typename InverseNumberType = typename MatrixType::value_type, typename VectorType = Vector<double>>
using RelaxationBlock< MatrixType, InverseNumberType, VectorType >::size_type = types::global_dof_index
inherited

Declare type for container size.

Definition at line 72 of file relaxation_block.h.

Member Enumeration Documentation

◆ Inversion

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.

Member Function Documentation

◆ step()

template<typename MatrixType , typename InverseNumberType = typename MatrixType::value_type, typename VectorType = Vector<double>>
void RelaxationBlockSOR< MatrixType, InverseNumberType, VectorType >::step ( VectorType &  dst,
const VectorType &  rhs 
) const

Perform one step of the SOR iteration.

◆ Tstep()

template<typename MatrixType , typename InverseNumberType = typename MatrixType::value_type, typename VectorType = Vector<double>>
void RelaxationBlockSOR< MatrixType, InverseNumberType, VectorType >::Tstep ( VectorType &  dst,
const VectorType &  rhs 
) const

Perform one step of the transposed SOR iteration.

◆ vmult()

template<typename MatrixType , typename InverseNumberType = typename MatrixType::value_type, typename VectorType = Vector<double>>
void RelaxationBlockSOR< MatrixType, InverseNumberType, VectorType >::vmult ( VectorType &  dst,
const VectorType &  rhs 
) const

Implements a vmult() operation, which for this class first sets the dst() vector to zero before calling the step() method.

◆ Tvmult()

template<typename MatrixType , typename InverseNumberType = typename MatrixType::value_type, typename VectorType = Vector<double>>
void RelaxationBlockSOR< MatrixType, InverseNumberType, VectorType >::Tvmult ( VectorType &  dst,
const VectorType &  rhs 
) const

Implements a transpose vmult operation, which for this class first sets the dst() vector to zero before calling the Tstep() method.

◆ subscribe()

void EnableObserverPointer::subscribe ( std::atomic< bool > *const  validity,
const std::string &  identifier = "" 
) const
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.

◆ unsubscribe()

void EnableObserverPointer::unsubscribe ( std::atomic< bool > *const  validity,
const std::string &  identifier = "" 
) const
inherited

Unsubscribes a user from the object.

Note
The 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.

◆ n_subscriptions()

unsigned int EnableObserverPointer::n_subscriptions ( ) const
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.

◆ list_subscribers() [1/2]

template<typename StreamType >
void EnableObserverPointer::list_subscribers ( StreamType stream) const
inlineinherited

List the subscribers to the input stream.

Definition at line 339 of file enable_observer_pointer.h.

◆ list_subscribers() [2/2]

void EnableObserverPointer::list_subscribers ( ) const
inherited

List the subscribers to deallog.

Definition at line 199 of file enable_observer_pointer.cc.

◆ serialize()

template<class Archive >
void EnableObserverPointer::serialize ( Archive ar,
const unsigned int  version 
)
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.

◆ check_no_subscribers()

void EnableObserverPointer::check_no_subscribers ( ) const
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.

Note
Since this function is just a consistency check it does nothing in release mode.
If this function is called when there is an uncaught exception then, rather than aborting, this function prints an error message to the standard error stream and returns.

Definition at line 53 of file enable_observer_pointer.cc.

◆ initialize()

template<typename MatrixType , typename InverseNumberType = typename MatrixType::value_type, typename VectorType = Vector<double>>
void RelaxationBlock< MatrixType, InverseNumberType, VectorType >::initialize ( const MatrixType &  A,
const AdditionalData parameters 
)
inherited

Initialize matrix and additional information. In a second step, the inverses of the diagonal blocks may be computed.

Note that AdditionalData, different from other preconditioners, defines quite large objects, and that therefore the object is not copied, but rather a pointer is stored. Thus, the lifetime of additional_data hast to exceed the lifetime of this object.

◆ clear()

template<typename MatrixType , typename InverseNumberType = typename MatrixType::value_type, typename VectorType = Vector<double>>
void RelaxationBlock< MatrixType, InverseNumberType, VectorType >::clear ( )
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.

◆ invert_diagblocks()

template<typename MatrixType , typename InverseNumberType = typename MatrixType::value_type, typename VectorType = Vector<double>>
void RelaxationBlock< MatrixType, InverseNumberType, VectorType >::invert_diagblocks ( )
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.

◆ do_step()

template<typename MatrixType , typename InverseNumberType = typename MatrixType::value_type, typename VectorType = Vector<double>>
void RelaxationBlock< MatrixType, InverseNumberType, VectorType >::do_step ( VectorType &  dst,
const VectorType &  prev,
const VectorType &  src,
const bool  backward 
) const
protectedinherited

Perform one block relaxation step.

Depending on the arguments dst and pref, this performs an SOR step (both reference the same vector) or a Jacobi step (both are different vectors). For the Jacobi step, the calling function must copy dst to prev after this.

◆ block_kernel()

template<typename MatrixType , typename InverseNumberType = typename MatrixType::value_type, typename VectorType = Vector<double>>
void RelaxationBlock< MatrixType, InverseNumberType, VectorType >::block_kernel ( const size_type  block_begin,
const size_type  block_end 
)
privateinherited

Computes (the inverse of) a range of blocks.

◆ reinit()

template<typename number >
void PreconditionBlockBase< number >::reinit ( unsigned int  nblocks,
size_type  blocksize,
bool  compress,
Inversion  method = gauss_jordan 
)
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.

◆ inverses_computed()

template<typename number >
void PreconditionBlockBase< number >::inverses_computed ( bool  are_they)
inlineinherited

Tell the class that inverses are computed.

Definition at line 598 of file precondition_block_base.h.

◆ same_diagonal()

template<typename number >
bool PreconditionBlockBase< number >::same_diagonal ( ) const
inlineinherited

Does the matrix use only one diagonal block?

Definition at line 582 of file precondition_block_base.h.

◆ store_diagonals()

template<typename number >
bool PreconditionBlockBase< number >::store_diagonals ( ) const
inlineinherited

Check, whether diagonal blocks (not their inverses) should be stored.

Definition at line 590 of file precondition_block_base.h.

◆ inverses_ready()

template<typename number >
bool PreconditionBlockBase< number >::inverses_ready ( ) const
inlineinherited

Return true, if inverses are ready for use.

Definition at line 606 of file precondition_block_base.h.

◆ size()

template<typename number >
unsigned int PreconditionBlockBase< number >::size ( ) const
inlineinherited

The number of blocks.

Definition at line 411 of file precondition_block_base.h.

◆ inverse_vmult()

template<typename number >
template<typename number2 >
void PreconditionBlockBase< number >::inverse_vmult ( size_type  i,
Vector< number2 > &  dst,
const Vector< number2 > &  src 
) const
inlineinherited

Multiply with the inverse block at position i.

Definition at line 419 of file precondition_block_base.h.

◆ inverse_Tvmult()

template<typename number >
template<typename number2 >
void PreconditionBlockBase< number >::inverse_Tvmult ( size_type  i,
Vector< number2 > &  dst,
const Vector< number2 > &  src 
) const
inlineinherited

Multiply with the transposed inverse block at position i.

Definition at line 448 of file precondition_block_base.h.

◆ inverse() [1/2]

template<typename number >
FullMatrix< number > & PreconditionBlockBase< number >::inverse ( size_type  i)
inlineinherited

Access to the inverse diagonal blocks if Inversion is gauss_jordan.

Definition at line 526 of file precondition_block_base.h.

◆ inverse() [2/2]

template<typename number >
const FullMatrix< number > & PreconditionBlockBase< number >::inverse ( size_type  i) const
inlineinherited

Access to the inverse diagonal blocks.

Definition at line 476 of file precondition_block_base.h.

◆ inverse_householder() [1/2]

template<typename number >
Householder< number > & PreconditionBlockBase< number >::inverse_householder ( size_type  i)
inlineinherited

Access to the inverse diagonal blocks if Inversion is householder.

Definition at line 540 of file precondition_block_base.h.

◆ inverse_householder() [2/2]

template<typename number >
const Householder< number > & PreconditionBlockBase< number >::inverse_householder ( size_type  i) const
inlineinherited

Access to the inverse diagonal blocks if Inversion is householder.

Definition at line 488 of file precondition_block_base.h.

◆ inverse_svd() [1/2]

template<typename number >
LAPACKFullMatrix< number > & PreconditionBlockBase< number >::inverse_svd ( size_type  i)
inlineinherited

Access to the inverse diagonal blocks if Inversion is householder.

Definition at line 554 of file precondition_block_base.h.

◆ inverse_svd() [2/2]

template<typename number >
const LAPACKFullMatrix< number > & PreconditionBlockBase< number >::inverse_svd ( size_type  i) const
inlineinherited

Access to the inverse diagonal blocks if Inversion is householder.

Definition at line 500 of file precondition_block_base.h.

◆ diagonal() [1/2]

template<typename number >
FullMatrix< number > & PreconditionBlockBase< number >::diagonal ( size_type  i)
inlineinherited

Access to the diagonal blocks.

Definition at line 568 of file precondition_block_base.h.

◆ diagonal() [2/2]

template<typename number >
const FullMatrix< number > & PreconditionBlockBase< number >::diagonal ( size_type  i) const
inlineinherited

Access to the diagonal blocks.

Definition at line 512 of file precondition_block_base.h.

◆ log_statistics()

template<typename number >
void PreconditionBlockBase< number >::log_statistics ( ) const
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.

◆ memory_consumption()

template<typename number >
std::size_t PreconditionBlockBase< number >::memory_consumption ( ) const
inlineinherited

Determine an estimate for the memory consumption (in bytes) of this object.

Definition at line 667 of file precondition_block_base.h.

Member Data Documentation

◆ counter

std::atomic<unsigned int> EnableObserverPointer::counter
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.

◆ counter_map

std::map<std::string, unsigned int> EnableObserverPointer::counter_map
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.

◆ validity_pointers

std::vector<std::atomic<bool> *> EnableObserverPointer::validity_pointers
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.

◆ object_info

const std::type_info* EnableObserverPointer::object_info
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.

◆ mutex

std::mutex EnableObserverPointer::mutex
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.

◆ A

template<typename MatrixType , typename InverseNumberType = typename MatrixType::value_type, typename VectorType = Vector<double>>
ObserverPointer<const MatrixType, RelaxationBlock<MatrixType, InverseNumberType, VectorType> > RelaxationBlock< MatrixType, InverseNumberType, VectorType >::A
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 preconditioning vmult function of the derived classes.

Definition at line 251 of file relaxation_block.h.

◆ additional_data

template<typename MatrixType , typename InverseNumberType = typename MatrixType::value_type, typename VectorType = Vector<double>>
ObserverPointer<const AdditionalData, RelaxationBlock<MatrixType, InverseNumberType, VectorType> > RelaxationBlock< MatrixType, InverseNumberType, VectorType >::additional_data
protectedinherited

Control information.

Definition at line 258 of file relaxation_block.h.

◆ inversion

template<typename number >
Inversion PreconditionBlockBase< number >::inversion
protectedinherited

The method used for inverting blocks.

Definition at line 243 of file precondition_block_base.h.

◆ n_diagonal_blocks

template<typename number >
unsigned int PreconditionBlockBase< number >::n_diagonal_blocks
privateinherited

The number of (inverse) diagonal blocks, if only one is stored.

Definition at line 249 of file precondition_block_base.h.

◆ var_inverse_full

template<typename number >
std::vector<FullMatrix<number> > PreconditionBlockBase< number >::var_inverse_full
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.

◆ var_inverse_householder

template<typename number >
std::vector<Householder<number> > PreconditionBlockBase< number >::var_inverse_householder
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.

◆ var_inverse_svd

template<typename number >
std::vector<LAPACKFullMatrix<number> > PreconditionBlockBase< number >::var_inverse_svd
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.

◆ var_diagonal

template<typename number >
std::vector<FullMatrix<number> > PreconditionBlockBase< number >::var_diagonal
privateinherited

Storage of the original diagonal blocks.

Used by the blocked SSOR method.

Definition at line 280 of file precondition_block_base.h.

◆ var_store_diagonals

template<typename number >
bool PreconditionBlockBase< number >::var_store_diagonals
privateinherited

This is true, if the field var_diagonal is to be used.

Definition at line 286 of file precondition_block_base.h.

◆ var_same_diagonal

template<typename number >
bool PreconditionBlockBase< number >::var_same_diagonal
privateinherited

This is true, if only one inverse is stored.

Definition at line 291 of file precondition_block_base.h.

◆ var_inverses_ready

template<typename number >
bool PreconditionBlockBase< number >::var_inverses_ready
privateinherited

The inverse matrices are usable. Set by the parent class via inverses_computed().

Definition at line 297 of file precondition_block_base.h.


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