Reference documentation for deal.II version 8.5.1
Classes | Public Member Functions | Static Public Member Functions | List of all members
VectorMemory< VectorType > Class Template Referenceabstract

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

Inheritance diagram for VectorMemory< VectorType >:
[legend]

Classes

class  Pointer
 

Public Member Functions

virtual ~VectorMemory ()
 
virtual VectorType * alloc ()=0
 
virtual void free (const VectorType *const)=0
 
- Public Member Functions inherited from Subscriptor
 Subscriptor ()
 
 Subscriptor (const Subscriptor &)
 
 Subscriptor (Subscriptor &&)
 
virtual ~Subscriptor ()
 
Subscriptoroperator= (const Subscriptor &)
 
Subscriptoroperator= (Subscriptor &&)
 
void subscribe (const char *identifier=0) const
 
void unsubscribe (const char *identifier=0) const
 
unsigned int n_subscriptions () const
 
void list_subscribers () const
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Static Public Member Functions

static ::ExceptionBaseExcNotAllocatedHere ()
 
- Static Public Member Functions inherited from Subscriptor
static ::ExceptionBaseExcInUse (int arg1, char *arg2, std::string &arg3)
 
static ::ExceptionBaseExcNoSubscriber (char *arg1, char *arg2)
 

Detailed Description

template<typename VectorType = ::Vector<double>>
class VectorMemory< VectorType >

Memory management base class for vectors. This is an abstract base class used, among other places, by all iterative methods to allocate space for auxiliary vectors.

The purpose of this class is as follows: in iterative solvers and other places, one needs to allocate temporary storage for vectors, for example for auxiliary vectors. One could allocate and release them anew every time, but this may be expensive in some situations if it has to happen very frequently. A common case for this is when an iterative method is used to invert a matrix in each iteration an outer solver, such as when inverting a matrix block for a Schur complement solver.

In such situations, allocating and deallocating vectors anew in each call to the inner solver is expensive and leads to memory fragmentation. The present class allows to avoid this by offering an interface that other classes can use to allocate and deallocate vectors. Different derived classes then implement different strategies to provide temporary storage vectors to using classes.

For example, the PrimitiveVectorMemory class simply allocates and deallocated vectors each time it is asked for a vector. It is an appropriate implementation to use for iterative solvers that are called only once, or very infrequently.

On the other hand, the GrowingVectorMemory class never returns memory space to the operating system memory management subsystem during its lifetime; it only marks them as unused and allows them to be reused next time a vector is requested.

Yet other classes, when implemented, could provide even other strategies for memory management.

Author
Guido Kanschat, 1998-2003

Definition at line 26 of file pointer_matrix.h.

Constructor & Destructor Documentation

◆ ~VectorMemory()

template<typename VectorType = ::Vector<double>>
virtual VectorMemory< VectorType >::~VectorMemory ( )
inlinevirtual

Virtual destructor is needed as there are virtual functions in this class.

Definition at line 79 of file vector_memory.h.

Member Function Documentation

◆ alloc()

template<typename VectorType = ::Vector<double>>
virtual VectorType* VectorMemory< VectorType >::alloc ( )
pure virtual

Return a pointer to a new vector. The number of elements or their subdivision into blocks (if applicable) is unspecified and users of this function should reset vectors to their proper size. The same holds for the contents of vectors: they are unspecified.

Implemented in GrowingVectorMemory< VectorType >, GrowingVectorMemory< BlockVector< number > >, and PrimitiveVectorMemory< VectorType >.

◆ free()

template<typename VectorType = ::Vector<double>>
virtual void VectorMemory< VectorType >::free ( const VectorType *  const)
pure virtual

Return a vector and indicate that it is not going to be used any further by the instance that called alloc() to get a pointer to it.

Implemented in GrowingVectorMemory< VectorType >, GrowingVectorMemory< BlockVector< number > >, and PrimitiveVectorMemory< VectorType >.


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