Reference documentation for deal.II version 9.1.0-pre
Public Member Functions | List of all members
PrimitiveVectorMemory< VectorType > Class Template Reference

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

Inheritance diagram for PrimitiveVectorMemory< VectorType >:
[legend]

Public Member Functions

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

Additional Inherited Members

- Static Public Member Functions inherited from VectorMemory< VectorType >
static::ExceptionBase & ExcNotAllocatedHere ()
 
- Static Public Member Functions inherited from Subscriptor
static::ExceptionBase & ExcInUse (int arg1, std::string arg2, std::string arg3)
 
static::ExceptionBase & ExcNoSubscriber (std::string arg1, std::string arg2)
 

Detailed Description

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

Simple memory management. See the documentation of the base class for a description of its purpose.

This class allocates and deletes vectors as needed from the global heap, i.e. performs no specially adapted actions for memory management.

Definition at line 241 of file vector_memory.h.

Member Function Documentation

template<typename VectorType = ::Vector<double>>
virtual VectorType* PrimitiveVectorMemory< VectorType >::alloc ( )
overridevirtual

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. In other words, the place that calls this function will need to resize or reinitialize it appropriately.

For the present class, calling this function will allocate a new vector on the heap and returning a pointer to it. Later calling free() then returns the memory to the global heap managed by the operating system.

Warning
Just like using new and delete explicitly in code invites bugs where memory is leaked (either because the corresponding delete is forgotten altogether, or because of exception safety issues), using the alloc() and free() functions explicitly invites writing code that accidentally leaks memory. You should consider using the VectorMemory::Pointer class instead, which provides the same kind of service that std::unique provides for arbitrary memory allocated on the heap.

Implements VectorMemory< VectorType >.

template<typename VectorType = ::Vector<double>>
virtual void PrimitiveVectorMemory< VectorType >::free ( const VectorType *const  v)
overridevirtual

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.

For the present class, this means that the vector is returned to the global heap.

Warning
Just like using new and delete explicitly in code invites bugs where memory is leaked (either because the corresponding delete is forgotten altogether, or because of exception safety issues), using the alloc() and free() functions explicitly invites writing code that accidentally leaks memory. You should consider using the VectorMemory::Pointer class instead, which provides the same kind of service that std::unique provides for arbitrary memory allocated on the heap.

Implements VectorMemory< VectorType >.


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