]> https://gitweb.dealii.org/ - dealii.git/commitdiff
PointerMatrixAux has own memory just in case
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Tue, 18 Sep 2007 22:56:02 +0000 (22:56 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Tue, 18 Sep 2007 22:56:02 +0000 (22:56 +0000)
git-svn-id: https://svn.dealii.org/trunk@15221 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/pointer_matrix.h

index 382b2556992e9020dedd3ad51c7b63d9fca42f65..9bec2c89d8db779e44651be30ec38db27dfad122 100644 (file)
@@ -16,6 +16,7 @@
 #include <base/subscriptor.h>
 #include <base/smartpointer.h>
 #include <lac/vector.h>
+#include <lac/vector_memory.h>
 
 DEAL_II_NAMESPACE_OPEN
 
@@ -267,6 +268,10 @@ class PointerMatrixAux : public PointerMatrixBase<VECTOR>
                                      *
                                      * If <tt>M</tt> is zero, no
                                      * matrix is stored.
+                                     *
+                                     * If <tt>mem</tt> is zero, a
+                                     * PrimitiveVectorMemory is
+                                     * generated.
                                      */
     PointerMatrixAux (VectorMemory<VECTOR>* mem = 0,
                      const MATRIX* M=0);
@@ -348,6 +353,11 @@ class PointerMatrixAux : public PointerMatrixBase<VECTOR>
                                      */
     virtual const void* get() const;
 
+                                    /**
+                                     * The backup memory if none was provided.
+                                     */
+    PrimitiveVectorMemory<VECTOR> my_memory;
+
                                     /**
                                      * Object for getting the
                                      * auxiliary vector.
@@ -836,7 +846,10 @@ PointerMatrixAux<MATRIX, VECTOR>::PointerMatrixAux (
   const MATRIX* M)
                : mem(mem, typeid(*this).name()),
                  m(M, typeid(*this).name())
-{}
+{
+  if (mem == 0)
+    mem = &my_memory;
+}
 
 
 template<class MATRIX, class VECTOR>
@@ -845,7 +858,10 @@ PointerMatrixAux<MATRIX, VECTOR>::PointerMatrixAux (
   const char* name)
                : mem(mem, name),
                  m(0, name)
-{}
+{
+  if (mem == 0)
+    mem = &my_memory;
+}
 
 
 template<class MATRIX, class VECTOR>
@@ -855,7 +871,10 @@ PointerMatrixAux<MATRIX, VECTOR>::PointerMatrixAux (
   const char* name)
                : mem(mem, name),
                  m(M, name)
-{}
+{
+  if (mem == 0)
+    mem = &my_memory;
+}
 
 
 template<class MATRIX, class VECTOR>
@@ -880,6 +899,8 @@ inline void
 PointerMatrixAux<MATRIX, VECTOR>::set_memory(VectorMemory<VECTOR>* M)
 {
   mem = M;
+  if (mem == 0)
+    mem = &my_memory;
 }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.