From f16b96196779d6b30e8ba3c7eb08f9c29ae7b780 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 10 Jul 2015 17:28:06 -0500 Subject: [PATCH] Move IsBlockMatrix from block_indices.h to constraint_matrix.h. The latter is the only file where it is actually used, so we may as well have it there. --- doc/news/changes.h | 9 ++- include/deal.II/lac/block_indices.h | 80 ------------------------ include/deal.II/lac/constraint_matrix.h | 82 ++++++++++++++++++++++++- tests/lac/is_block_matrix.cc | 3 +- 4 files changed, 91 insertions(+), 83 deletions(-) diff --git a/doc/news/changes.h b/doc/news/changes.h index d0af277767..a0efda592b 100644 --- a/doc/news/changes.h +++ b/doc/news/changes.h @@ -547,7 +547,14 @@ inconvenience this causes.
    -
  1. New: CellId::to_string() returns a string representation. +
  2. Changed: The IsBlockMatrix class is now declared in + constraint_matrix.h instead of its former home in + block_indices.h. +
    + (Wolfgang Bangerth, 2015/07/10) +
  3. + +
  4. New: CellId::to_string() returns a string representation of a CellId object.
    (Timo Heister, 2015/07/05)
  5. diff --git a/include/deal.II/lac/block_indices.h b/include/deal.II/lac/block_indices.h index 41fafc8acf..2f9625769b 100644 --- a/include/deal.II/lac/block_indices.h +++ b/include/deal.II/lac/block_indices.h @@ -210,86 +210,6 @@ operator << (LogStream &s, const BlockIndices &bi) } -template class BlockMatrixBase; -template class BlockSparsityPatternBase; -template class BlockSparseMatrixEZ; - -/** - * A class that can be used to determine whether a given type is a block - * matrix type or not. For example, - * @code - * IsBlockMatrix >::value - * @endcode - * has the value false, whereas - * @code - * IsBlockMatrix >::value - * @endcode - * is true. This is sometimes useful in template contexts where we may want to - * do things differently depending on whether a template type denotes a - * regular or a block matrix type. - * - * @see - * @ref GlossBlockLA "Block (linear algebra)" - * @author Wolfgang Bangerth, 2009 - */ -template -struct IsBlockMatrix -{ -private: - struct yes_type - { - char c[1]; - }; - struct no_type - { - char c[2]; - }; - - /** - * Overload returning true if the class is derived from BlockMatrixBase, - * which is what block matrices do (with the exception of - * BlockSparseMatrixEZ). - */ - template - static yes_type check_for_block_matrix (const BlockMatrixBase *); - - /** - * Overload returning true if the class is derived from - * BlockSparsityPatternBase, which is what block sparsity patterns do. - */ - template - static yes_type check_for_block_matrix (const BlockSparsityPatternBase *); - - /** - * Overload for BlockSparseMatrixEZ, which is the only block matrix not - * derived from BlockMatrixBase at the time of writing this class. - */ - template - static yes_type check_for_block_matrix (const BlockSparseMatrixEZ *); - - /** - * Catch all for all other potential matrix types that are not block - * matrices. - */ - static no_type check_for_block_matrix (...); - -public: - /** - * A statically computable value that indicates whether the template - * argument to this class is a block matrix (in fact whether the type is - * derived from BlockMatrixBase). - */ - static const bool value = (sizeof(check_for_block_matrix - ((MatrixType *)0)) - == - sizeof(yes_type)); -}; - - -// instantiation of the static member -template -const bool IsBlockMatrix::value; - /* ---------------------- template and inline functions ------------------- */ diff --git a/include/deal.II/lac/constraint_matrix.h b/include/deal.II/lac/constraint_matrix.h index 4073d22682..85fe21b231 100644 --- a/include/deal.II/lac/constraint_matrix.h +++ b/include/deal.II/lac/constraint_matrix.h @@ -44,7 +44,7 @@ class BlockDynamicSparsityPattern; template class SparseMatrix; template class BlockSparseMatrix; class BlockIndices; -template struct IsBlockMatrix; + namespace internals { @@ -1634,6 +1634,86 @@ void ConstraintMatrix::get_dof_values (const VectorType &global_vector, } +template class BlockMatrixBase; +template class BlockSparsityPatternBase; +template class BlockSparseMatrixEZ; + +/** + * A class that can be used to determine whether a given type is a block + * matrix type or not. For example, + * @code + * IsBlockMatrix >::value + * @endcode + * has the value false, whereas + * @code + * IsBlockMatrix >::value + * @endcode + * is true. This is sometimes useful in template contexts where we may want to + * do things differently depending on whether a template type denotes a + * regular or a block matrix type. + * + * @see + * @ref GlossBlockLA "Block (linear algebra)" + * @author Wolfgang Bangerth, 2009 + */ +template +struct IsBlockMatrix +{ +private: + struct yes_type + { + char c[1]; + }; + struct no_type + { + char c[2]; + }; + + /** + * Overload returning true if the class is derived from BlockMatrixBase, + * which is what block matrices do (with the exception of + * BlockSparseMatrixEZ). + */ + template + static yes_type check_for_block_matrix (const BlockMatrixBase *); + + /** + * Overload returning true if the class is derived from + * BlockSparsityPatternBase, which is what block sparsity patterns do. + */ + template + static yes_type check_for_block_matrix (const BlockSparsityPatternBase *); + + /** + * Overload for BlockSparseMatrixEZ, which is the only block matrix not + * derived from BlockMatrixBase at the time of writing this class. + */ + template + static yes_type check_for_block_matrix (const BlockSparseMatrixEZ *); + + /** + * Catch all for all other potential matrix types that are not block + * matrices. + */ + static no_type check_for_block_matrix (...); + +public: + /** + * A statically computable value that indicates whether the template + * argument to this class is a block matrix (in fact whether the type is + * derived from BlockMatrixBase). + */ + static const bool value = (sizeof(check_for_block_matrix + ((MatrixType *)0)) + == + sizeof(yes_type)); +}; + + +// instantiation of the static member +template +const bool IsBlockMatrix::value; + template inline diff --git a/tests/lac/is_block_matrix.cc b/tests/lac/is_block_matrix.cc index cd23062bbe..655d0e2ade 100644 --- a/tests/lac/is_block_matrix.cc +++ b/tests/lac/is_block_matrix.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2009 - 2014 by the deal.II authors +// Copyright (C) 2009 - 2015 by the deal.II authors // // This file is part of the deal.II library. // @@ -24,6 +24,7 @@ #include #include #include +#include #include #include -- 2.39.5