//---------------------------------------------------------------------------
// $Id$
-// Version: $Name$
//
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
//
* BlockTrianglePrecondition.
*
* @see @ref GlossBlockLA "Block (linear algebra)"
- * @author Guido Kanschat, 2000-2005
+ * @author Guido Kanschat
+ * @date 2000-2005, 2010
*/
template <typename number = double>
class BlockMatrixArray : public Subscriptor
* Constructor fixing the
* dimensions.
*/
+ BlockMatrixArray (const unsigned int n_block_rows,
+ const unsigned int n_block_cols);
+
+ /**
+ * Initialize object
+ * completely. This is the
+ * function to call for an object
+ * created by the default
+ * constructor.
+ *
+ * @deprecated the last argument
+ * is ignored.
+ */
+ void initialize (const unsigned int n_block_rows,
+ const unsigned int n_block_cols);
+
+ /**
+ * Constructor fixing the
+ * dimensions.
+ *
+ * @deprecated the last argument
+ * is ignored.
+ */
BlockMatrixArray (const unsigned int n_block_rows,
const unsigned int n_block_cols,
VectorMemory<Vector<number> >& mem);
* function to call for an object
* created by the default
* constructor.
+ *
+ * @deprecated the last argument
+ * is ignored.
*/
void initialize (const unsigned int n_block_rows,
const unsigned int n_block_cols,
const unsigned int col,
const double prefix = 1.,
const bool transpose = false);
-
+
/**
* Add an entry like with enter,
* but use PointerMatrixAux for
* matrices not having functions
* vmult_add() and TVmult_add().
+ *
+ * @deprecated the first argument
+ * is ignored.
*/
template <class MATRIX>
void enter_aux (VectorMemory<Vector<number> >& mem,
unsigned row, unsigned int col,
double prefix, bool transpose);
- /**
- * Constructor initializing
- * all data fields. A
- * PointerMatrixAux object is
- * generated for
- * <tt>matrix</tt>.
- */
- template<class MATRIX>
- Entry (const MATRIX& matrix,
- unsigned row, unsigned int col,
- double prefix, bool transpose,
- VectorMemory<Vector<number> >& mem);
-
/**
* Copy constructor
* invalidating the old
* number of blocks per row.
*/
unsigned int block_cols;
- protected:
- /**
- * The memory used for auxiliary
- * vectors.
- */
- mutable SmartPointer<VectorMemory<Vector<number> >,BlockMatrixArray<number> > mem;
};
/*@}*/
* block-quadratic. The additional
* parameter allows for backward
* insertion instead of forward.
+ *
+ * @deprecated the second argument
+ * is ignored.
*/
BlockTrianglePrecondition (unsigned int n_block_rows,
VectorMemory<Vector<number> >& mem,
* function to call for an object
* created by the default
* constructor.
+ *
+ * @deprecated the second argument
+ * is ignored.
*/
void initialize (const unsigned int n_block_rows,
VectorMemory<Vector<number> >& mem,
* that the diagonal blocks
* should actually be inverse
* matrices or preconditioners.
+ *
+ * @deprecated The first
+ * argument is ignored. User
+ * enter() instead.
*/
template <class MATRIX>
void enter_aux (VectorMemory<Vector<double> >& mem,
-template <typename number>
-template <class MATRIX>
-inline
-BlockMatrixArray<number>::Entry::Entry (
- const MATRIX& m,
- unsigned row,
- unsigned int col,
- double prefix,
- bool transpose,
- VectorMemory<Vector<number> >& mem)
- :
- row (row),
- col (col),
- prefix (prefix),
- transpose (transpose),
- matrix (new PointerMatrixAux<MATRIX, Vector<number> >(&mem, &m, typeid(*this).name()))
-{}
-
-
-
template <typename number>
template <class MATRIX>
inline
double prefix,
bool transpose)
{
- Assert (mem != 0, ExcNotInitialized());
Assert(row<n_block_rows(), ExcIndexRange(row, 0, n_block_rows()));
Assert(col<n_block_cols(), ExcIndexRange(col, 0, n_block_cols()));
entries.push_back(Entry(matrix, row, col, prefix, transpose));
void
BlockMatrixArray<number>::print_latex (STREAM& out) const
{
- Assert (mem != 0, ExcNotInitialized());
out << "\\begin{array}{"
<< std::string(n_block_cols(), 'c')
<< "}" << std::endl;
//---------------------------------------------------------------------------
// $Id$
-// Version: $Name$
//
-// Copyright (C) 2005, 2006, 2008 by the deal.II authors
+// Copyright (C) 2005, 2006, 2008, 2010 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
template <typename number>
BlockMatrixArray<number>::BlockMatrixArray ()
: block_rows (0),
- block_cols (0),
- mem(0, typeid(*this).name())
+ block_cols (0)
{}
+template <typename number>
+BlockMatrixArray<number>::BlockMatrixArray (
+ const unsigned int n_block_rows,
+ const unsigned int n_block_cols)
+ : block_rows (n_block_rows),
+ block_cols (n_block_cols)
+{}
+
+
template <typename number>
BlockMatrixArray<number>::BlockMatrixArray (
const unsigned int n_block_rows,
const unsigned int n_block_cols,
- VectorMemory<Vector<number> >& mem)
+ VectorMemory<Vector<number> >&)
: block_rows (n_block_rows),
- block_cols (n_block_cols),
- mem(&mem, typeid(*this).name())
+ block_cols (n_block_cols)
{}
BlockMatrixArray<number>::initialize (
const unsigned int n_block_rows,
const unsigned int n_block_cols,
- VectorMemory<Vector<number> >& memory)
+ VectorMemory<Vector<number> >&)
{
block_rows = n_block_rows;
block_cols = n_block_cols;
- mem = &memory;
}
+template <typename number>
+void
+BlockMatrixArray<number>::initialize (
+ const unsigned int n_block_rows,
+ const unsigned int n_block_cols)
+{
+ block_rows = n_block_rows;
+ block_cols = n_block_cols;
+}
+
template <typename number>
const unsigned int n_block_rows,
const unsigned int n_block_cols)
{
- Assert (mem != 0, ExcNotInitialized());
clear();
block_rows = n_block_rows;
block_cols = n_block_cols;
BlockMatrixArray<number>::vmult_add (BlockVector<number>& dst,
const BlockVector<number>& src) const
{
- Assert (mem != 0, ExcNotInitialized());
-
+ GrowingVectorMemory<Vector<number> > mem;
Assert (dst.n_blocks() == block_rows,
ExcDimensionMismatch(dst.n_blocks(), block_rows));
Assert (src.n_blocks() == block_cols,
ExcDimensionMismatch(src.n_blocks(), block_cols));
- Vector<number>* p_aux = mem->alloc();
+ typename VectorMemory<Vector<number> >::Pointer p_aux(mem);
Vector<number>& aux = *p_aux;
typename std::vector<Entry>::const_iterator m = entries.begin();
m->matrix->vmult(aux, src.block(m->col));
dst.block(m->row).add (m->prefix, aux);
}
- mem->free(p_aux);
}
BlockMatrixArray<number>::Tvmult_add (BlockVector<number>& dst,
const BlockVector<number>& src) const
{
- Assert (mem != 0, ExcNotInitialized());
+ GrowingVectorMemory<Vector<number> > mem;
Assert (dst.n_blocks() == block_cols,
ExcDimensionMismatch(dst.n_blocks(), block_cols));
Assert (src.n_blocks() == block_rows,
typename std::vector<Entry>::const_iterator m = entries.begin();
typename std::vector<Entry>::const_iterator end = entries.end();
- Vector<number>* p_aux = mem->alloc();
+ typename VectorMemory<Vector<number> >::Pointer p_aux(mem);
Vector<number>& aux = *p_aux;
for (; m != end ; ++m)
m->matrix->Tvmult(aux, src.block(m->row));
dst.block(m->col).add (m->prefix, aux);
}
- mem->free(p_aux);
}
const BlockVector<number>& u,
const BlockVector<number>& v) const
{
- Assert (mem != 0, ExcNotInitialized());
+ GrowingVectorMemory<Vector<number> > mem;
Assert (u.n_blocks() == block_rows,
ExcDimensionMismatch(u.n_blocks(), block_rows));
Assert (v.n_blocks() == block_cols,
ExcDimensionMismatch(v.n_blocks(), block_cols));
- Vector<number>* p_aux = mem->alloc();
+ typename VectorMemory<Vector<number> >::Pointer p_aux(mem);
Vector<number>& aux = *p_aux;
typename std::vector<Entry>::const_iterator m;
}
result += u.block(i)*aux;
}
- mem->free(p_aux);
return result;
}
BlockVector<number>& dst,
unsigned int row_num) const
{
+ GrowingVectorMemory<Vector<number> > mem;
typename std::vector<typename BlockMatrixArray<number>::Entry>::const_iterator
m = this->entries.begin();
typename std::vector<typename BlockMatrixArray<number>::Entry>::const_iterator
std::vector<typename std::vector<typename BlockMatrixArray<number>::Entry>::const_iterator>
diagonals;
- Vector<number>* p_aux = this->mem->alloc();
+ typename VectorMemory<Vector<number> >::Pointer p_aux(mem);
Vector<number>& aux = *p_aux;
aux.reinit(dst.block(row_num), true);
}
dst.block(row_num) = aux;
}
-
- this->mem->free(p_aux);
}