From 7d2682fcc4746e2007cb467d94c283fb07f8f529 Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 8 May 2000 12:03:19 +0000 Subject: [PATCH] Move some functions around from .h to .templates.h files and back or forth. git-svn-id: https://svn.dealii.org/trunk@2825 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/block_sparse_matrix.h | 149 ++++---------- .../lac/block_sparse_matrix.templates.h | 122 ++++++++++++ .../lac/include/lac/block_sparsity_pattern.h | 174 ++--------------- .../lac/block_sparsity_pattern.templates.h | 183 ++++++++++++++++++ deal.II/lac/include/lac/block_vector.h | 12 ++ deal.II/lac/include/lac/full_matrix.h | 11 ++ deal.II/lac/include/lac/precondition_block.h | 17 +- deal.II/lac/include/lac/sparse_ilu.h | 11 ++ deal.II/lac/include/lac/sparse_matrix.h | 12 ++ deal.II/lac/include/lac/sparse_vanka.h | 12 ++ deal.II/lac/include/lac/swappable_vector.h | 12 ++ deal.II/lac/include/lac/vector.h | 12 ++ deal.II/lac/source/block_sparse_matrix.cc | 30 +++ deal.II/lac/source/block_sparsity_pattern.cc | 21 ++ 14 files changed, 503 insertions(+), 275 deletions(-) create mode 100644 deal.II/lac/include/lac/block_sparse_matrix.templates.h create mode 100644 deal.II/lac/include/lac/block_sparsity_pattern.templates.h create mode 100644 deal.II/lac/source/block_sparse_matrix.cc create mode 100644 deal.II/lac/source/block_sparsity_pattern.cc diff --git a/deal.II/lac/include/lac/block_sparse_matrix.h b/deal.II/lac/include/lac/block_sparse_matrix.h index 8f8e15c53f..fd17b3c2a2 100644 --- a/deal.II/lac/include/lac/block_sparse_matrix.h +++ b/deal.II/lac/include/lac/block_sparse_matrix.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000 by the deal.II authors +// Copyright (C) 2000 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -19,6 +19,23 @@ +/** + * Blocked sparse matrix. + * + * + * \section{On template instantiations} + * + * Member functions of this class are either implemented in this file + * or in a file of the same name with suffix ``.templates.h''. For the + * most common combinations of the template parameters, instantiations + * of this class are provided in a file with suffix ``.cc'' in the + * ``source'' directory. If you need an instantiation that is not + * listed there, you have to include this file along with the + * corresponding ``.templates.h'' file and instantiate the respective + * class yourself. + * + * @author Wolfgang Bangerth, 2000 + */ template class BlockSparseMatrix : public Subscriptor { @@ -382,60 +399,6 @@ class BlockSparseMatrix : public Subscriptor /* ------------------------- Template functions ---------------------- */ -template -BlockSparseMatrix::BlockSparseMatrix () : - sparsity_pattern (0) -{}; - - - -template -BlockSparseMatrix:: -BlockSparseMatrix (const BlockSparsityPattern &sparsity) -{ - reinit (sparsity); -}; - - - -template -BlockSparseMatrix & -BlockSparseMatrix:: -operator = (const BlockSparseMatrix &m) -{ - *sparsity_pattern = *m.sparsity_pattern; - for (unsigned int r=0; r -void -BlockSparseMatrix::reinit () -{ - for (unsigned int r=0; r -void -BlockSparseMatrix::reinit (const BlockSparsityPattern &sparsity) -{ - sparsity_pattern = &sparsity; - - for (unsigned int r=0; r inline SparseMatrix & @@ -465,31 +428,7 @@ BlockSparseMatrix::block (const unsigned int row, template -void -BlockSparseMatrix::clear () -{ - sparsity_pattern = 0; - for (unsigned int r=0; r -bool -BlockSparseMatrix::empty () const -{ - for (unsigned int r=0; r +inline unsigned int BlockSparseMatrix::m () const { @@ -499,6 +438,7 @@ BlockSparseMatrix::m () const template +inline unsigned int BlockSparseMatrix::n () const { @@ -508,15 +448,7 @@ BlockSparseMatrix::n () const template -unsigned int -BlockSparseMatrix::n_nonzero_elements () const -{ - return sparsity_pattern->n_nonzero_elements (); -}; - - - -template +inline void BlockSparseMatrix::set (const unsigned int i, const unsigned int j, @@ -533,6 +465,7 @@ BlockSparseMatrix::set (const unsigned int i, template +inline void BlockSparseMatrix::add (const unsigned int i, const unsigned int j, @@ -548,6 +481,22 @@ BlockSparseMatrix::add (const unsigned int i, +template +inline +number +BlockSparseMatrix::operator () (const unsigned int i, + const unsigned int j) const +{ + const pair + row_index = sparsity_pattern->row_indices.global_to_local (i), + col_index = sparsity_pattern->column_indices.global_to_local (j); + return block(row_index.first,col_index.first) (row_index.second, + col_index.second); +}; + + + + template template BlockSparseMatrix & @@ -577,19 +526,6 @@ add_scaled (const number factor, -template -number -BlockSparseMatrix::operator () (const unsigned int i, - const unsigned int j) const -{ - const pair - row_index = sparsity_pattern->row_indices.global_to_local (i), - col_index = sparsity_pattern->column_indices.global_to_local (j); - return block(row_index.first,col_index.first) (row_index.second, - col_index.second); -}; - - template template @@ -700,15 +636,6 @@ matrix_scalar_product (const BlockVector &u, -template -const BlockSparsityPattern & -BlockSparseMatrix::get_sparsity_pattern () const -{ - return *sparsity_pattern; -}; - - - #endif // __deal2__block_sparse_matrix_h diff --git a/deal.II/lac/include/lac/block_sparse_matrix.templates.h b/deal.II/lac/include/lac/block_sparse_matrix.templates.h new file mode 100644 index 0000000000..bc8b277c42 --- /dev/null +++ b/deal.II/lac/include/lac/block_sparse_matrix.templates.h @@ -0,0 +1,122 @@ +//---------------------------- block_sparse_matrix.templates.h --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 1998, 1999, 2000 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//---------------------------- block_sparse_matrix.templates.h --------------------------- +#ifndef __deal2__block_sparse_matrix_templates_h +#define __deal2__block_sparse_matrix_templates_h + + +#include + + + +template +BlockSparseMatrix::BlockSparseMatrix () : + sparsity_pattern (0) +{}; + + + +template +BlockSparseMatrix:: +BlockSparseMatrix (const BlockSparsityPattern &sparsity) +{ + reinit (sparsity); +}; + + + +template +BlockSparseMatrix & +BlockSparseMatrix:: +operator = (const BlockSparseMatrix &m) +{ + // this operator does not do + // anything except than checking + // whether the base objects want to + // do something + for (unsigned int r=0; r +void +BlockSparseMatrix::reinit () +{ + for (unsigned int r=0; r +void +BlockSparseMatrix:: +reinit (const BlockSparsityPattern &sparsity) +{ + sparsity_pattern = &sparsity; + + for (unsigned int r=0; r +void +BlockSparseMatrix::clear () +{ + sparsity_pattern = 0; + for (unsigned int r=0; r +bool +BlockSparseMatrix::empty () const +{ + for (unsigned int r=0; r +unsigned int +BlockSparseMatrix::n_nonzero_elements () const +{ + return sparsity_pattern->n_nonzero_elements (); +}; + + + +template +const BlockSparsityPattern & +BlockSparseMatrix::get_sparsity_pattern () const +{ + return *sparsity_pattern; +}; + + + +#endif // ifdef block_sparse_matrix_templates_h diff --git a/deal.II/lac/include/lac/block_sparsity_pattern.h b/deal.II/lac/include/lac/block_sparsity_pattern.h index 2363c2ec54..4ffdf16814 100644 --- a/deal.II/lac/include/lac/block_sparsity_pattern.h +++ b/deal.II/lac/include/lac/block_sparsity_pattern.h @@ -44,6 +44,18 @@ * that all sub-matrices in a column have to have the same number of * columns. * + * + * \section{On template instantiations} + * + * Member functions of this class are either implemented in this file + * or in a file of the same name with suffix ``.templates.h''. For the + * most common combinations of the template parameters, instantiations + * of this class are provided in a file with suffix ``.cc'' in the + * ``source'' directory. If you need an instantiation that is not + * listed there, you have to include this file along with the + * corresponding ``.templates.h'' file and instantiate the respective + * class yourself. + * * @author Wolfgang Bangerth, 2000 */ template @@ -270,68 +282,6 @@ class BlockSparsityPattern : public Subscriptor /*---------------------- Template functions -----------------------------------*/ -template -BlockSparsityPattern::BlockSparsityPattern () -{ - Assert (rows>0, ExcInvalidSize (rows)); - Assert (columns>0, ExcInvalidSize (columns)); -}; - - - -template -BlockSparsityPattern & -BlockSparsityPattern::operator = (const BlockSparsityPattern &bsp) -{ - // copy objects - for (unsigned int i=0; i -void -BlockSparsityPattern::collect_sizes () -{ - vector row_sizes (rows); - vector col_sizes (columns); - - // first find out the row sizes - // from the first block column - for (unsigned int r=0; r inline @@ -355,50 +305,6 @@ BlockSparsityPattern::block (const unsigned int row, -template -inline -void -BlockSparsityPattern::compress () -{ - for (unsigned int i=0; i -bool -BlockSparsityPattern::empty () const -{ - for (unsigned int i=0; i -unsigned int -BlockSparsityPattern::max_entries_per_row () const -{ - unsigned int max_entries = 0; - for (unsigned int block_row=0; block_row max_entries) - max_entries = this_row; - }; - return max_entries; -}; - - - template inline void @@ -417,60 +323,4 @@ BlockSparsityPattern::add (const unsigned int i, -template -unsigned int -BlockSparsityPattern::n_rows () const -{ - // only count in first column, since - // all rows should be equivalent - unsigned int count = 0; - for (unsigned int r=0; r -unsigned int -BlockSparsityPattern::n_cols () const -{ - // only count in first row, since - // all rows should be equivalent - unsigned int count = 0; - for (unsigned int c=0; c -unsigned int -BlockSparsityPattern::n_nonzero_elements () const -{ - unsigned int count = 0; - for (unsigned int i=0; i -bool -BlockSparsityPattern::is_compressed () const -{ - for (unsigned int i=0; i + + +template +BlockSparsityPattern::BlockSparsityPattern () +{ + Assert (rows>0, ExcInvalidSize (rows)); + Assert (columns>0, ExcInvalidSize (columns)); +}; + + + +template +BlockSparsityPattern & +BlockSparsityPattern::operator = (const BlockSparsityPattern &bsp) +{ + // copy objects + for (unsigned int i=0; i +void +BlockSparsityPattern::collect_sizes () +{ + vector row_sizes (rows); + vector col_sizes (columns); + + // first find out the row sizes + // from the first block column + for (unsigned int r=0; r +void +BlockSparsityPattern::compress () +{ + for (unsigned int i=0; i +bool +BlockSparsityPattern::empty () const +{ + for (unsigned int i=0; i +unsigned int +BlockSparsityPattern::max_entries_per_row () const +{ + unsigned int max_entries = 0; + for (unsigned int block_row=0; block_row max_entries) + max_entries = this_row; + }; + return max_entries; +}; + + +template +unsigned int +BlockSparsityPattern::n_rows () const +{ + // only count in first column, since + // all rows should be equivalent + unsigned int count = 0; + for (unsigned int r=0; r +unsigned int +BlockSparsityPattern::n_cols () const +{ + // only count in first row, since + // all rows should be equivalent + unsigned int count = 0; + for (unsigned int c=0; c +unsigned int +BlockSparsityPattern::n_nonzero_elements () const +{ + unsigned int count = 0; + for (unsigned int i=0; i +bool +BlockSparsityPattern::is_compressed () const +{ + for (unsigned int i=0; i diff --git a/deal.II/lac/include/lac/full_matrix.h b/deal.II/lac/include/lac/full_matrix.h index b7747df96c..e44678438a 100644 --- a/deal.II/lac/include/lac/full_matrix.h +++ b/deal.II/lac/include/lac/full_matrix.h @@ -45,6 +45,17 @@ template class Vector; * type, the matrix number type is used. * * + * \section{On template instantiations} + * + * Member functions of this class are either implemented in this file + * or in a file of the same name with suffix ``.templates.h''. For the + * most common combinations of the template parameters, instantiations + * of this class are provided in a file with suffix ``.cc'' in the + * ``source'' directory. If you need an instantiation that is not + * listed there, you have to include this file along with the + * corresponding ``.templates.h'' file and instantiate the respective + * class yourself. + * * @author Guido Kanschat, Franz-Theo Suttmeier, Wolfgang Bangerth */ template diff --git a/deal.II/lac/include/lac/precondition_block.h b/deal.II/lac/include/lac/precondition_block.h index 1875e3fd44..071d4df14b 100644 --- a/deal.II/lac/include/lac/precondition_block.h +++ b/deal.II/lac/include/lac/precondition_block.h @@ -52,9 +52,22 @@ * an exact solver, but rather as a preconditioner, you may probably want to * store the inverted blocks with less accuracy than the original matrix; * for example, #number==double, inverse_type=float# might be a viable choice. + * + * + * \section{On template instantiations} + * + * Member functions of this class are either implemented in this file + * or in a file of the same name with suffix ``.templates.h''. For the + * most common combinations of the template parameters, instantiations + * of this class are provided in a file with suffix ``.cc'' in the + * ``source'' directory. If you need an instantiation that is not + * listed there, you have to include this file along with the + * corresponding ``.templates.h'' file and instantiate the respective + * class yourself. + * + * @author Ralf Hartmann, 1999 */ -template +template class PreconditionBlock: public Subscriptor { public: diff --git a/deal.II/lac/include/lac/sparse_ilu.h b/deal.II/lac/include/lac/sparse_ilu.h index 0a51693e66..e092baa40a 100644 --- a/deal.II/lac/include/lac/sparse_ilu.h +++ b/deal.II/lac/include/lac/sparse_ilu.h @@ -83,6 +83,17 @@ * \end{verbatim} * * + * \section{On template instantiations} + * + * Member functions of this class are either implemented in this file + * or in a file of the same name with suffix ``.templates.h''. For the + * most common combinations of the template parameters, instantiations + * of this class are provided in a file with suffix ``.cc'' in the + * ``source'' directory. If you need an instantiation that is not + * listed there, you have to include this file along with the + * corresponding ``.templates.h'' file and instantiate the respective + * class yourself. + * * @author Wolfgang Bangerth, 1999, based on a similar implementation by Malte Braack */ template diff --git a/deal.II/lac/include/lac/sparse_matrix.h b/deal.II/lac/include/lac/sparse_matrix.h index 7a880eab2f..c2258cc8d7 100644 --- a/deal.II/lac/include/lac/sparse_matrix.h +++ b/deal.II/lac/include/lac/sparse_matrix.h @@ -26,6 +26,18 @@ /** * Sparse matrix. * + * + * \section{On template instantiations} + * + * Member functions of this class are either implemented in this file + * or in a file of the same name with suffix ``.templates.h''. For the + * most common combinations of the template parameters, instantiations + * of this class are provided in a file with suffix ``.cc'' in the + * ``source'' directory. If you need an instantiation that is not + * listed there, you have to include this file along with the + * corresponding ``.templates.h'' file and instantiate the respective + * class yourself. + * * @author Original version by Roland Becker, Guido Kanschat, Franz-Theo Suttmeier; lots of enhancements, reorganisation and documentation by Wolfgang Bangerth 1998 */ template diff --git a/deal.II/lac/include/lac/sparse_vanka.h b/deal.II/lac/include/lac/sparse_vanka.h index 1e894a80a3..74427cc2ad 100644 --- a/deal.II/lac/include/lac/sparse_vanka.h +++ b/deal.II/lac/include/lac/sparse_vanka.h @@ -110,6 +110,18 @@ * whether this might pose some problems in the inversion of the local matrices. * Maybe someone would like to check this. * + * + * \section{On template instantiations} + * + * Member functions of this class are either implemented in this file + * or in a file of the same name with suffix ``.templates.h''. For the + * most common combinations of the template parameters, instantiations + * of this class are provided in a file with suffix ``.cc'' in the + * ``source'' directory. If you need an instantiation that is not + * listed there, you have to include this file along with the + * corresponding ``.templates.h'' file and instantiate the respective + * class yourself. + * * @author Guido Kanschat, Wolfgang Bangerth; 1999, 2000 */ template diff --git a/deal.II/lac/include/lac/swappable_vector.h b/deal.II/lac/include/lac/swappable_vector.h index af2e7a348f..7b67b23f82 100644 --- a/deal.II/lac/include/lac/swappable_vector.h +++ b/deal.II/lac/include/lac/swappable_vector.h @@ -42,6 +42,18 @@ * #reload# is called. If it is not available, #reload# waits until * the detached thread has loaded the data. * + * + * \section{On template instantiations} + * + * Member functions of this class are either implemented in this file + * or in a file of the same name with suffix ``.templates.h''. For the + * most common combinations of the template parameters, instantiations + * of this class are provided in a file with suffix ``.cc'' in the + * ``source'' directory. If you need an instantiation that is not + * listed there, you have to include this file along with the + * corresponding ``.templates.h'' file and instantiate the respective + * class yourself. + * * @author Wolfgang Bangerth, 1999, 2000 */ template diff --git a/deal.II/lac/include/lac/vector.h b/deal.II/lac/include/lac/vector.h index 76d7c140b0..6bf0f45b27 100644 --- a/deal.II/lac/include/lac/vector.h +++ b/deal.II/lac/include/lac/vector.h @@ -28,6 +28,18 @@ * As opposed to the array of the C++ standard library called #vector#, this class implements * an element of a vector space suitable for numerical computations. * + * + * \section{On template instantiations} + * + * Member functions of this class are either implemented in this file + * or in a file of the same name with suffix ``.templates.h''. For the + * most common combinations of the template parameters, instantiations + * of this class are provided in a file with suffix ``.cc'' in the + * ``source'' directory. If you need an instantiation that is not + * listed there, you have to include this file along with the + * corresponding ``.templates.h'' file and instantiate the respective + * class yourself. + * * @author Guido Kanschat, Franz-Theo Suttmeier, Wolfgang Bangerth */ template diff --git a/deal.II/lac/source/block_sparse_matrix.cc b/deal.II/lac/source/block_sparse_matrix.cc new file mode 100644 index 0000000000..504d7c5bfc --- /dev/null +++ b/deal.II/lac/source/block_sparse_matrix.cc @@ -0,0 +1,30 @@ +//---------------------------- block_block_sparse_matrix.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2000 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//---------------------------- block_block_sparse_matrix.cc --------------------------- + +#include + +// explicit instantiations +template class BlockSparseMatrix; +template class BlockSparseMatrix; + +template class BlockSparseMatrix; +template class BlockSparseMatrix; + + + +template class BlockSparseMatrix; +template class BlockSparseMatrix; + +template class BlockSparseMatrix; +template class BlockSparseMatrix; + diff --git a/deal.II/lac/source/block_sparsity_pattern.cc b/deal.II/lac/source/block_sparsity_pattern.cc new file mode 100644 index 0000000000..e886af0c12 --- /dev/null +++ b/deal.II/lac/source/block_sparsity_pattern.cc @@ -0,0 +1,21 @@ +//---------------------------- block_block_sparsity_pattern.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2000 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//---------------------------- block_block_sparsity_pattern.cc --------------------------- + +#include + +// explicit instantiations +template class BlockSparsityPattern<2,2>; +template class BlockSparsityPattern<2,3>; + +template class BlockSparsityPattern<3,2>; +template class BlockSparsityPattern<3,3>; -- 2.39.5