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

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

Inheritance diagram for VectorMemory< VectorType >:


class  Pointer

Public Member Functions

virtual ~VectorMemory ()
virtual VectorType * alloc ()=0
virtual void free (const VectorType *const)=0
 DeclException0 (ExcNoMoreVectors)
 DeclException0 (ExcNotAllocatedHere)
- Public Member Functions inherited from Subscriptor
 Subscriptor ()
 Subscriptor (const Subscriptor &)
virtual ~Subscriptor ()
Subscriptoroperator= (const Subscriptor &)
void subscribe (const char *identifier=0) const
void unsubscribe (const char *identifier=0) const
unsigned int n_subscriptions () const
void list_subscribers () const
 DeclException3 (ExcInUse, int, char *, std::string &,<< "Object of class "<< arg2<< " is still used by "<< arg1<< " other objects."<< "\n\n"<< "(Additional information: "<< arg3<< ")\n\n"<< "See the entry in the Frequently Asked Questions of "<< "deal.II (linked to from for "<< "a lot more information on what this error means and "<< "how to fix programs in which it happens.")
 DeclException2 (ExcNoSubscriber, char *, char *,<< "No subscriber with identifier <"<< arg2<< "> subscribes to this object of class "<< arg1<< ". Consequently, it cannot be unsubscribed.")
template<class Archive >
void serialize (Archive &ar, const unsigned int version)

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.

Guido Kanschat, 1998-2003

Definition at line 26 of file pointer_matrix.h.

Constructor & Destructor Documentation

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

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

Definition at line 79 of file vector_memory.h.

Member Function Documentation

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 >, and PrimitiveVectorMemory< VectorType >.

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 >, and PrimitiveVectorMemory< VectorType >.

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