VectorMemory< VECTOR > Class Template Reference
[Vector memory management]

Inheritance diagram for VectorMemory< VECTOR >:

Inheritance graph
[legend]

List of all members.

Classes

class  ExcNoMoreVectors
class  ExcNotAllocatedHere
class  Pointer

Public Member Functions

virtual ~VectorMemory ()
virtual VECTOR * alloc ()=0
virtual void free (const VECTOR *const)=0


Detailed Description

template<class VECTOR = ::Vector<double>>
class VectorMemory< VECTOR >

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

Constructor & Destructor Documentation

template<class VECTOR = ::Vector<double>>
virtual VectorMemory< VECTOR >::~VectorMemory (  )  [inline, virtual]

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


Member Function Documentation

template<class VECTOR = ::Vector<double>>
virtual VECTOR* VectorMemory< VECTOR >::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 PrimitiveVectorMemory< VECTOR >, and GrowingVectorMemory< VECTOR >.

Referenced by EigenInverse< VECTOR >::solve(), and EigenPower< VECTOR >::solve().

template<class VECTOR = ::Vector<double>>
virtual void VectorMemory< VECTOR >::free ( const VECTOR *  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 PrimitiveVectorMemory< VECTOR >, and GrowingVectorMemory< VECTOR >.

Referenced by EigenInverse< VECTOR >::solve(), and EigenPower< VECTOR >::solve().


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

deal.II documentation generated on Sat Aug 15 16:52:31 2009 by doxygen 1.5.9