From: Uwe Köcher Date: Thu, 12 Jan 2017 15:06:33 +0000 (+0100) Subject: Introduce type trait is_serial_vector X-Git-Tag: v8.5.0-rc1~182^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6af402f851d83efffa727ad3b745d26e73549f1;p=dealii.git Introduce type trait is_serial_vector renames type trait is_non_distributed_vector to is_serial_vector and put it into dealii::std_cxx11 namespace intendation with astyle 2.04 / script more obivious logical statements as requested moves true_type and false_type to dealii/base/std_cxx11/type_traits.h moves specialization of is_serial_vector for dealii::Vector classes to their implementation correction of implementation moves vector type traits from a single file to their declaration files testsuite for vector_type_traits.h for current vectors and instanciations change request for comments declares the is_serial_vector template without defining it and minor work on documentation squashes test cases for is_serial_vector and marks output files for trilinos, petsc, mpi corrects output files for testsuite (results are correct) corrects intendation intendation of #include --- diff --git a/include/deal.II/base/std_cxx11/type_traits.h b/include/deal.II/base/std_cxx11/type_traits.h index d9692f7de6..a6f9a89878 100644 --- a/include/deal.II/base/std_cxx11/type_traits.h +++ b/include/deal.II/base/std_cxx11/type_traits.h @@ -33,6 +33,8 @@ namespace std_cxx11 using std::is_standard_layout; using std::is_trivial; using std::enable_if; + using std::true_type; + using std::false_type; } DEAL_II_NAMESPACE_CLOSE @@ -77,6 +79,9 @@ namespace std_cxx11 boost::has_trivial_constructor::value && boost::has_trivial_destructor::value; }; + + using boost::true_type; + using boost::false_type; } DEAL_II_NAMESPACE_CLOSE diff --git a/include/deal.II/lac/block_vector.h b/include/deal.II/lac/block_vector.h index 0186b56cef..e981223f3b 100644 --- a/include/deal.II/lac/block_vector.h +++ b/include/deal.II/lac/block_vector.h @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 1999 - 2016 by the deal.II authors +// Copyright (C) 1999 - 2017 by the deal.II authors // // This file is part of the deal.II library. // @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -517,6 +518,17 @@ namespace internal } /* namespace LinearOperator */ } /* namespace internal */ + +/** + * Declare dealii::BlockVector< Number > as serial vector. + * + * @author Uwe Koecher, 2017 + */ +template +struct is_serial_vector< BlockVector< Number > > : std_cxx11::true_type +{ +}; + DEAL_II_NAMESPACE_CLOSE #endif diff --git a/include/deal.II/lac/constraint_matrix.templates.h b/include/deal.II/lac/constraint_matrix.templates.h index cadb380cc0..54949aa030 100644 --- a/include/deal.II/lac/constraint_matrix.templates.h +++ b/include/deal.II/lac/constraint_matrix.templates.h @@ -27,6 +27,7 @@ #include #include #include + #include #include #include @@ -855,16 +856,7 @@ ConstraintMatrix::distribute (VectorType &vec) const // the last else is for the simple case (sequential vector) const IndexSet vec_owned_elements = vec.locally_owned_elements(); - // FIXME: This has to be refactored into a typetrait - if ((typeid(vec) != typeid(Vector)) && - (typeid(vec) != typeid(Vector)) && - (typeid(vec) != typeid(Vector >)) && - (typeid(vec) != typeid(BlockVector)) && - (typeid(vec) != typeid(BlockVector)) && - (typeid(vec) != typeid(BlockVector >)) && - (typeid(vec) != typeid(LinearAlgebra::Vector)) && - (typeid(vec) != typeid(LinearAlgebra::Vector)) && - (typeid(vec) != typeid(LinearAlgebra::Vector >))) + if ( dealii::is_serial_vector< VectorType >::value == false ) { // This processor owns only part of the vector. one may think that // every processor should be able to simply communicate those elements diff --git a/include/deal.II/lac/la_parallel_block_vector.h b/include/deal.II/lac/la_parallel_block_vector.h index bbfeae8134..04a3a786ce 100644 --- a/include/deal.II/lac/la_parallel_block_vector.h +++ b/include/deal.II/lac/la_parallel_block_vector.h @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 1999 - 2016 by the deal.II authors +// Copyright (C) 1999 - 2017 by the deal.II authors // // This file is part of the deal.II library. // @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -578,7 +579,8 @@ namespace LinearAlgebra } // end of namespace distributed -} // end of namespace parallel +} // end of namespace LinearAlgebra + /** * Global function which overloads the default implementation of the C++ @@ -596,6 +598,18 @@ void swap (LinearAlgebra::distributed::BlockVector &u, u.swap (v); } + +/** + * Declare dealii::LinearAlgebra::BlockVector< Number > as distributed vector. + * + * @author Uwe Koecher, 2017 + */ +template +struct is_serial_vector< LinearAlgebra::distributed::BlockVector< Number > > : std_cxx11::false_type +{ +}; + + DEAL_II_NAMESPACE_CLOSE #ifdef DEAL_II_MSVC diff --git a/include/deal.II/lac/la_parallel_vector.h b/include/deal.II/lac/la_parallel_vector.h index b73fd4ea7e..95a02f9b80 100644 --- a/include/deal.II/lac/la_parallel_vector.h +++ b/include/deal.II/lac/la_parallel_vector.h @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2011 - 2016 by the deal.II authors +// Copyright (C) 2011 - 2017 by the deal.II authors // // This file is part of the deal.II library. // @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -1449,7 +1450,6 @@ namespace LinearAlgebra } - /** * Global function @p swap which overloads the default implementation of the * C++ standard library which uses a temporary object. The function simply @@ -1466,6 +1466,18 @@ void swap (LinearAlgebra::distributed::Vector &u, u.swap (v); } + +/** + * Declare dealii::LinearAlgebra::Vector< Number > as distributed vector. + * + * @author Uwe Koecher, 2017 + */ +template +struct is_serial_vector< LinearAlgebra::distributed::Vector< Number > > : std_cxx11::false_type +{ +}; + + DEAL_II_NAMESPACE_CLOSE #endif diff --git a/include/deal.II/lac/la_vector.h b/include/deal.II/lac/la_vector.h index 3894119dfd..18dbcf5d02 100644 --- a/include/deal.II/lac/la_vector.h +++ b/include/deal.II/lac/la_vector.h @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2015 by the deal.II authors +// Copyright (C) 2015 - 2017 by the deal.II authors // // This file is part of the deal.II library. // @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -376,6 +377,18 @@ namespace LinearAlgebra } } // end of namespace LinearAlgebra + +/** + * Declare dealii::LinearAlgebra::Vector< Number > as serial vector. + * + * @author Uwe Koecher, 2017 + */ +template +struct is_serial_vector< LinearAlgebra::Vector< Number > > : std_cxx11::true_type +{ +}; + + DEAL_II_NAMESPACE_CLOSE #ifdef DEAL_II_MSVC diff --git a/include/deal.II/lac/petsc_block_vector.h b/include/deal.II/lac/petsc_block_vector.h index c95b456cd1..c71f4a94b2 100644 --- a/include/deal.II/lac/petsc_block_vector.h +++ b/include/deal.II/lac/petsc_block_vector.h @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2016 by the deal.II authors +// Copyright (C) 2004 - 2017 by the deal.II authors // // This file is part of the deal.II library. // @@ -26,6 +26,7 @@ # include # include # include +# include DEAL_II_NAMESPACE_OPEN @@ -495,6 +496,18 @@ namespace internal } /* namespace LinearOperator */ } /* namespace internal */ + +/** + * Declare dealii::PETScWrappers::BlockVector as serial vector. + * + * @author Uwe Koecher, 2017 + */ +template <> +struct is_serial_vector< PETScWrappers::BlockVector > : std_cxx11::true_type +{ +}; + + DEAL_II_NAMESPACE_CLOSE #endif // DEAL_II_WITH_PETSC diff --git a/include/deal.II/lac/petsc_parallel_block_vector.h b/include/deal.II/lac/petsc_parallel_block_vector.h index 03e5940c33..66779bb586 100644 --- a/include/deal.II/lac/petsc_parallel_block_vector.h +++ b/include/deal.II/lac/petsc_parallel_block_vector.h @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2016 by the deal.II authors +// Copyright (C) 2004 - 2017 by the deal.II authors // // This file is part of the deal.II library. // @@ -25,6 +25,7 @@ # include # include # include +# include DEAL_II_NAMESPACE_OPEN @@ -574,6 +575,18 @@ namespace internal } /* namespace LinearOperator */ } /* namespace internal */ + +/** + * Declare dealii::PETScWrappers::MPI::BlockVector as distributed vector. + * + * @author Uwe Koecher, 2017 + */ +template <> +struct is_serial_vector< PETScWrappers::MPI::BlockVector > : std_cxx11::false_type +{ +}; + + DEAL_II_NAMESPACE_CLOSE #endif // DEAL_II_WITH_PETSC diff --git a/include/deal.II/lac/petsc_parallel_vector.h b/include/deal.II/lac/petsc_parallel_vector.h index 341511db40..df36bb05d7 100644 --- a/include/deal.II/lac/petsc_parallel_vector.h +++ b/include/deal.II/lac/petsc_parallel_vector.h @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2016 by the deal.II authors +// Copyright (C) 2004 - 2017 by the deal.II authors // // This file is part of the deal.II library. // @@ -26,6 +26,7 @@ # include # include # include +# include DEAL_II_NAMESPACE_OPEN @@ -619,6 +620,18 @@ namespace internal /**@}*/ + +/** + * Declare dealii::PETScWrappers::MPI::Vector as distributed vector. + * + * @author Uwe Koecher, 2017 + */ +template <> +struct is_serial_vector< PETScWrappers::MPI::Vector > : std_cxx11::false_type +{ +}; + + DEAL_II_NAMESPACE_CLOSE #endif // DEAL_II_WITH_PETSC diff --git a/include/deal.II/lac/petsc_vector.h b/include/deal.II/lac/petsc_vector.h index 34287adf78..c17688a56a 100644 --- a/include/deal.II/lac/petsc_vector.h +++ b/include/deal.II/lac/petsc_vector.h @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2016 by the deal.II authors +// Copyright (C) 2004 - 2017 by the deal.II authors // // This file is part of the deal.II library. // @@ -26,6 +26,7 @@ # include # include # include +# include DEAL_II_NAMESPACE_OPEN @@ -429,6 +430,18 @@ namespace internal } /* namespace LinearOperator */ } /* namespace internal */ + +/** + * Declare dealii::PETScWrappers::Vector as serial vector. + * + * @author Uwe Koecher, 2017 + */ +template <> +struct is_serial_vector< PETScWrappers::Vector > : std_cxx11::true_type +{ +}; + + DEAL_II_NAMESPACE_CLOSE #endif // DEAL_II_WITH_PETSC diff --git a/include/deal.II/lac/trilinos_block_vector.h b/include/deal.II/lac/trilinos_block_vector.h index 965bb14751..c3742e4a2d 100644 --- a/include/deal.II/lac/trilinos_block_vector.h +++ b/include/deal.II/lac/trilinos_block_vector.h @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2008 - 2016 by the deal.II authors +// Copyright (C) 2008 - 2017 by the deal.II authors // // This file is part of the deal.II library. // @@ -26,6 +26,7 @@ # include # include # include +# include DEAL_II_NAMESPACE_OPEN @@ -494,6 +495,28 @@ namespace internal } /* namespace internal */ +/** + * Declare dealii::TrilinosWrappers::BlockVector as serial vector. + * + * @author Uwe Koecher, 2017 + */ +template <> +struct is_serial_vector< TrilinosWrappers::BlockVector > : std_cxx11::true_type +{ +}; + + +/** + * Declare dealii::TrilinosWrappers::MPI::BlockVector as distributed vector. + * + * @author Uwe Koecher, 2017 + */ +template <> +struct is_serial_vector< TrilinosWrappers::MPI::BlockVector > : std_cxx11::false_type +{ +}; + + DEAL_II_NAMESPACE_CLOSE #endif // DEAL_II_WITH_TRILINOS diff --git a/include/deal.II/lac/trilinos_vector.h b/include/deal.II/lac/trilinos_vector.h index 71f130ad18..dff8b6c9d6 100644 --- a/include/deal.II/lac/trilinos_vector.h +++ b/include/deal.II/lac/trilinos_vector.h @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2008 - 2016 by the deal.II authors +// Copyright (C) 2008 - 2017 by the deal.II authors // // This file is part of the deal.II library. // @@ -28,6 +28,7 @@ # include # include # include +# include DEAL_II_DISABLE_EXTRA_DIAGNOSTICS # include "Epetra_Map.h" @@ -928,7 +929,6 @@ namespace TrilinosWrappers }; - // ------------------- inline and template functions -------------- @@ -1082,6 +1082,28 @@ namespace internal } /* namespace internal */ +/** + * Declare dealii::TrilinosWrappers::Vector as serial vector. + * + * @author Uwe Koecher, 2017 + */ +template <> +struct is_serial_vector< TrilinosWrappers::Vector > : std_cxx11::true_type +{ +}; + + +/** + * Declare dealii::TrilinosWrappers::MPI::Vector as distributed vector. + * + * @author Uwe Koecher, 2017 + */ +template <> +struct is_serial_vector< TrilinosWrappers::MPI::Vector > : std_cxx11::false_type +{ +}; + + DEAL_II_NAMESPACE_CLOSE #endif // DEAL_II_WITH_TRILINOS diff --git a/include/deal.II/lac/vector.h b/include/deal.II/lac/vector.h index c6af741f76..5b72371561 100644 --- a/include/deal.II/lac/vector.h +++ b/include/deal.II/lac/vector.h @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 1999 - 2016 by the deal.II authors +// Copyright (C) 1999 - 2017 by the deal.II authors // // This file is part of the deal.II library. // @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -1425,9 +1426,20 @@ operator << (LogStream &os, const Vector &v) return os; } - /*@}*/ + +/** + * Declare dealii::Vector< Number > as serial vector. + * + * @author Uwe Koecher, 2017 + */ +template +struct is_serial_vector< Vector > : std_cxx11::true_type +{ +}; + + DEAL_II_NAMESPACE_CLOSE #endif diff --git a/include/deal.II/lac/vector_type_traits.h b/include/deal.II/lac/vector_type_traits.h new file mode 100644 index 0000000000..db8a45fbe9 --- /dev/null +++ b/include/deal.II/lac/vector_type_traits.h @@ -0,0 +1,50 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + +#ifndef dealii__vector_type_traits_h +#define dealii__vector_type_traits_h + +#include + + +DEAL_II_NAMESPACE_OPEN + + +/** + * Type trait for a serial vector, i.e. a vector class for which storage is not + * supported to be distributed over processes. + * + * The specialization + * @code + * template <> + * struct is_serial_vector< VectorType > : std_cxx11::true_type {}; + * @endcode + * for a serial vector type, respectively, + * @code + * template <> + * struct is_serial_vector< VectorType > : std_cxx11::false_type {}; + * @endcode + * for a vector type with support of distributed storage, + * must be done in a header file of a vector declaration. + * + * @author Uwe Koecher, 2017 + */ +template +struct is_serial_vector; + + +DEAL_II_NAMESPACE_CLOSE + +#endif diff --git a/include/deal.II/numerics/vector_tools.templates.h b/include/deal.II/numerics/vector_tools.templates.h index 0b64ae5dc3..9c311ddf0e 100644 --- a/include/deal.II/numerics/vector_tools.templates.h +++ b/include/deal.II/numerics/vector_tools.templates.h @@ -7782,12 +7782,7 @@ namespace VectorTools else { // This function is not implemented for distributed vectors. - Assert(typeid(v) == typeid(Vector) || - typeid(v) == typeid(Vector) || - typeid(v) == typeid(BlockVector) || - typeid(v) == typeid(BlockVector) || - typeid(v) == typeid(LinearAlgebra::Vector) || - typeid(v) == typeid(LinearAlgebra::Vector), + Assert((dealii::is_serial_vector< VectorType >::value == true), ExcNotImplemented()); const unsigned int n = v.size(); diff --git a/source/lac/vector.cc b/source/lac/vector.cc index e7f0a283ed..4f24cdbbc3 100644 --- a/source/lac/vector.cc +++ b/source/lac/vector.cc @@ -30,7 +30,6 @@ void Vector::reinit(const Vector &, const bool); template class Vector; template long double Vector::operator *(const Vector &) const; - // do a few functions that currently don't fit the scheme because they have // two template arguments that need to be different (the case of same // arguments is covered by the default copy constructor and copy operator that diff --git a/source/lac/vector.inst.in b/source/lac/vector.inst.in index e9c29f5856..7965594f03 100644 --- a/source/lac/vector.inst.in +++ b/source/lac/vector.inst.in @@ -56,4 +56,3 @@ for (S1: REAL_SCALARS; S2: COMPLEX_SCALARS) template Vector& Vector::operator= (const Vector &); } - diff --git a/tests/lac/vector_type_traits_is_serial_01.cc b/tests/lac/vector_type_traits_is_serial_01.cc new file mode 100644 index 0000000000..a8686521a7 --- /dev/null +++ b/tests/lac/vector_type_traits_is_serial_01.cc @@ -0,0 +1,128 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 1998 - 2017 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// check is_serial_vector type trait for internal deal.II Vector types + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +void test () +{ + // make sure that is_serial_vector< dealii::Vector > is working + Assert (is_serial_vector< dealii::Vector >::value == true, + ExcInternalError()); + + deallog << is_serial_vector< dealii::Vector >::value << std::endl; + deallog << is_serial_vector< dealii::Vector >::value << std::endl; + deallog << is_serial_vector< dealii::Vector >::value << std::endl; + deallog << is_serial_vector< dealii::Vector >::value << std::endl; + + deallog << is_serial_vector< dealii::Vector< std::complex > >::value << std::endl; + deallog << is_serial_vector< dealii::Vector< std::complex > >::value << std::endl; + + deallog << "OK" << std::endl << std::endl; + + // make sure that is_serial_vector< dealii::BlockVector > is working + Assert (is_serial_vector< dealii::BlockVector >::value == true, + ExcInternalError()); + + deallog << is_serial_vector< dealii::BlockVector >::value << std::endl; + deallog << is_serial_vector< dealii::BlockVector >::value << std::endl; + + deallog << is_serial_vector< dealii::BlockVector< std::complex > >::value << std::endl; + deallog << is_serial_vector< dealii::BlockVector< std::complex > >::value << std::endl; + + deallog << "OK" << std::endl << std::endl; + + + // make sure that is_serial_vector< dealii::LinearAlgebra::Vector > is working + Assert (is_serial_vector< dealii::LinearAlgebra::Vector >::value == true, + ExcInternalError()); + + deallog << is_serial_vector< dealii::LinearAlgebra::Vector >::value << std::endl; + deallog << is_serial_vector< dealii::LinearAlgebra::Vector >::value << std::endl; + + deallog << is_serial_vector< dealii::LinearAlgebra::Vector< std::complex > >::value << std::endl; + deallog << is_serial_vector< dealii::LinearAlgebra::Vector< std::complex > >::value << std::endl; + + deallog << "OK" << std::endl << std::endl; + + // make sure that dealii::LinearAlgebra::distributed::Vector > is working + Assert (is_serial_vector< dealii::LinearAlgebra::distributed::Vector >::value == false, + ExcInternalError()); + + deallog << is_serial_vector< dealii::LinearAlgebra::distributed::Vector >::value << std::endl; + deallog << is_serial_vector< dealii::LinearAlgebra::distributed::Vector >::value << std::endl; + + deallog << is_serial_vector< dealii::LinearAlgebra::distributed::Vector< std::complex > >::value << std::endl; + deallog << is_serial_vector< dealii::LinearAlgebra::distributed::Vector< std::complex > >::value << std::endl; + + deallog << "OK" << std::endl << std::endl; + + // make sure that dealii::LinearAlgebra::distributed::BlockVector > is working + Assert (is_serial_vector< dealii::LinearAlgebra::distributed::BlockVector >::value == false, + ExcInternalError()); + + deallog << is_serial_vector< dealii::LinearAlgebra::distributed::BlockVector >::value << std::endl; + deallog << is_serial_vector< dealii::LinearAlgebra::distributed::BlockVector >::value << std::endl; + + deallog << is_serial_vector< dealii::LinearAlgebra::distributed::BlockVector< std::complex > >::value << std::endl; + deallog << is_serial_vector< dealii::LinearAlgebra::distributed::BlockVector< std::complex > >::value << std::endl; + + deallog << "OK" << std::endl; +} + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + + try + { + test (); + } + catch (std::exception &exc) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/lac/vector_type_traits_is_serial_01.output b/tests/lac/vector_type_traits_is_serial_01.output new file mode 100644 index 0000000000..9aaeb307e4 --- /dev/null +++ b/tests/lac/vector_type_traits_is_serial_01.output @@ -0,0 +1,32 @@ + +DEAL::1 +DEAL::1 +DEAL::1 +DEAL::1 +DEAL::1 +DEAL::1 +DEAL::OK +DEAL:: +DEAL::1 +DEAL::1 +DEAL::1 +DEAL::1 +DEAL::OK +DEAL:: +DEAL::1 +DEAL::1 +DEAL::1 +DEAL::1 +DEAL::OK +DEAL:: +DEAL::0 +DEAL::0 +DEAL::0 +DEAL::0 +DEAL::OK +DEAL:: +DEAL::0 +DEAL::0 +DEAL::0 +DEAL::0 +DEAL::OK diff --git a/tests/lac/vector_type_traits_is_serial_02.cc b/tests/lac/vector_type_traits_is_serial_02.cc new file mode 100644 index 0000000000..e263ef94d4 --- /dev/null +++ b/tests/lac/vector_type_traits_is_serial_02.cc @@ -0,0 +1,89 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 1998 - 2017 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// check is_serial_vector type trait + +#include "../tests.h" +#include +#include +#include +#include + +void test () +{ + // make sure that is_serial_vector< dealii::TrilinosWrappers::Vector > is working + Assert (is_serial_vector< dealii::TrilinosWrappers::Vector >::value == true, + ExcInternalError()); + + Assert (is_serial_vector< dealii::TrilinosWrappers::MPI::Vector >::value == false, + ExcInternalError()); + + deallog << is_serial_vector< dealii::TrilinosWrappers::Vector >::value << std::endl; + + deallog << is_serial_vector< dealii::TrilinosWrappers::MPI::Vector >::value << std::endl; + + deallog << "OK" << std::endl << std::endl; + + + // make sure that dealii::TrilinosWrappers::BlockVector > is working + Assert (is_serial_vector< dealii::TrilinosWrappers::BlockVector >::value == true, + ExcInternalError()); + + Assert (is_serial_vector< dealii::TrilinosWrappers::MPI::BlockVector >::value == false, + ExcInternalError()); + + deallog << is_serial_vector< dealii::TrilinosWrappers::BlockVector >::value << std::endl; + + deallog << is_serial_vector< dealii::TrilinosWrappers::MPI::BlockVector >::value << std::endl; + + deallog << "OK" << std::endl; +} + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + + try + { + test (); + } + catch (std::exception &exc) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/lac/vector_type_traits_is_serial_02.with_trilinos=true.with_mpi=true.output b/tests/lac/vector_type_traits_is_serial_02.with_trilinos=true.with_mpi=true.output new file mode 100644 index 0000000000..9536f3b0eb --- /dev/null +++ b/tests/lac/vector_type_traits_is_serial_02.with_trilinos=true.with_mpi=true.output @@ -0,0 +1,8 @@ + +DEAL::1 +DEAL::0 +DEAL::OK +DEAL:: +DEAL::1 +DEAL::0 +DEAL::OK diff --git a/tests/lac/vector_type_traits_is_serial_03.cc b/tests/lac/vector_type_traits_is_serial_03.cc new file mode 100644 index 0000000000..5b6536a708 --- /dev/null +++ b/tests/lac/vector_type_traits_is_serial_03.cc @@ -0,0 +1,96 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 1998 - 2017 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// check is_serial_vector type trait + +#include "../tests.h" +#include +#include +#include +#include +#include +#include + +void test () +{ + // make sure that is_serial_vector< dealii::PETScWrappers::Vector > is working + Assert (is_serial_vector< dealii::PETScWrappers::Vector >::value == true, + ExcInternalError()); + + deallog << is_serial_vector< dealii::PETScWrappers::Vector >::value << std::endl; + + deallog << "OK" << std::endl << std::endl; + + // make sure that is_serial_vector< dealii::PETScWrappers::BlockVector > is working + Assert (is_serial_vector< dealii::PETScWrappers::BlockVector >::value == true, + ExcInternalError()); + + deallog << is_serial_vector< dealii::PETScWrappers::BlockVector >::value << std::endl; + + deallog << "OK" << std::endl << std::endl; + + // make sure that is_serial_vector< dealii::PETScWrappers::MPI::Vector > is working + Assert (is_serial_vector< dealii::PETScWrappers::MPI::Vector >::value == false, + ExcInternalError()); + + deallog << is_serial_vector< dealii::PETScWrappers::MPI::Vector >::value << std::endl; + + deallog << "OK" << std::endl << std::endl; + + // make sure that is_serial_vector< dealii::PETScWrappers::MPI::BlockVector > is working + Assert (is_serial_vector< dealii::PETScWrappers::MPI::BlockVector >::value == false, + ExcInternalError()); + + deallog << is_serial_vector< dealii::PETScWrappers::MPI::BlockVector >::value << std::endl; + + deallog << "OK" << std::endl; +} + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + + try + { + test (); + } + catch (std::exception &exc) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/lac/vector_type_traits_is_serial_03.with_petsc=true.with_mpi=true.output b/tests/lac/vector_type_traits_is_serial_03.with_petsc=true.with_mpi=true.output new file mode 100644 index 0000000000..dee23be6e7 --- /dev/null +++ b/tests/lac/vector_type_traits_is_serial_03.with_petsc=true.with_mpi=true.output @@ -0,0 +1,12 @@ + +DEAL::1 +DEAL::OK +DEAL:: +DEAL::1 +DEAL::OK +DEAL:: +DEAL::0 +DEAL::OK +DEAL:: +DEAL::0 +DEAL::OK