From: Daniel Arndt Date: Fri, 30 Nov 2018 11:34:19 +0000 (+0100) Subject: Cast variables in AssertDimension X-Git-Tag: v9.1.0-rc1~515^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc927f92313afb5254ebf1ce1df112a8d7931444;p=dealii.git Cast variables in AssertDimension --- diff --git a/include/deal.II/base/exceptions.h b/include/deal.II/base/exceptions.h index 3a9be34422..67373a476f 100644 --- a/include/deal.II/base/exceptions.h +++ b/include/deal.II/base/exceptions.h @@ -1365,8 +1365,14 @@ namespace deal_II_exceptions * @ingroup Exceptions * @author Guido Kanschat 2007 */ -#define AssertDimension(dim1, dim2) \ - Assert((dim1) == (dim2), dealii::ExcDimensionMismatch((dim1), (dim2))) +#define AssertDimension(dim1, dim2) \ + Assert(static_cast::type)>::type>(dim1) == \ + static_cast::type)>::type>(dim2), \ + dealii::ExcDimensionMismatch((dim1), (dim2))) /** diff --git a/include/deal.II/lac/trilinos_precondition.h b/include/deal.II/lac/trilinos_precondition.h index 6a51d7c925..0a8787fa76 100644 --- a/include/deal.II/lac/trilinos_precondition.h +++ b/include/deal.II/lac/trilinos_precondition.h @@ -2015,9 +2015,9 @@ namespace TrilinosWrappers PreconditionBase::vmult(dealii::Vector & dst, const dealii::Vector &src) const { - AssertDimension(static_cast(dst.size()), + AssertDimension(dst.size(), preconditioner->OperatorDomainMap().NumMyElements()); - AssertDimension(static_cast(src.size()), + AssertDimension(src.size(), preconditioner->OperatorRangeMap().NumMyElements()); Epetra_Vector tril_dst(View, preconditioner->OperatorDomainMap(), @@ -2035,9 +2035,9 @@ namespace TrilinosWrappers PreconditionBase::Tvmult(dealii::Vector & dst, const dealii::Vector &src) const { - AssertDimension(static_cast(dst.size()), + AssertDimension(dst.size(), preconditioner->OperatorDomainMap().NumMyElements()); - AssertDimension(static_cast(src.size()), + AssertDimension(src.size(), preconditioner->OperatorRangeMap().NumMyElements()); Epetra_Vector tril_dst(View, preconditioner->OperatorDomainMap(), @@ -2059,11 +2059,9 @@ namespace TrilinosWrappers LinearAlgebra::distributed::Vector & dst, const LinearAlgebra::distributed::Vector &src) const { - AssertDimension(static_cast( - dst.local_size()), + AssertDimension(dst.local_size(), preconditioner->OperatorDomainMap().NumMyElements()); - AssertDimension(static_cast( - src.local_size()), + AssertDimension(src.local_size(), preconditioner->OperatorRangeMap().NumMyElements()); Epetra_Vector tril_dst(View, preconditioner->OperatorDomainMap(), @@ -2081,11 +2079,9 @@ namespace TrilinosWrappers LinearAlgebra::distributed::Vector & dst, const LinearAlgebra::distributed::Vector &src) const { - AssertDimension(static_cast( - dst.local_size()), + AssertDimension(dst.local_size(), preconditioner->OperatorDomainMap().NumMyElements()); - AssertDimension(static_cast( - src.local_size()), + AssertDimension(src.local_size(), preconditioner->OperatorRangeMap().NumMyElements()); Epetra_Vector tril_dst(View, preconditioner->OperatorDomainMap(), diff --git a/include/deal.II/matrix_free/operators.h b/include/deal.II/matrix_free/operators.h index 36807a5b63..f09d56a138 100644 --- a/include/deal.II/matrix_free/operators.h +++ b/include/deal.II/matrix_free/operators.h @@ -1275,8 +1275,7 @@ namespace MatrixFreeOperators { if (data_->n_macro_cells() > 0) { - AssertDimension(static_cast(level), - data_->get_cell_iterator(0, 0, j)->level()); + AssertDimension(level, data_->get_cell_iterator(0, 0, j)->level()); } // setup edge_constrained indices diff --git a/source/lac/trilinos_solver.cc b/source/lac/trilinos_solver.cc index 09f5a211a5..059a4d0ef4 100644 --- a/source/lac/trilinos_solver.cc +++ b/source/lac/trilinos_solver.cc @@ -229,12 +229,8 @@ namespace TrilinosWrappers { // In case we call the solver with deal.II vectors, we create views of the // vectors in Epetra format. - AssertDimension(static_cast( - x.local_size()), - A.domain_partitioner().NumMyElements()); - AssertDimension(static_cast( - b.local_size()), - A.range_partitioner().NumMyElements()); + AssertDimension(x.local_size(), A.domain_partitioner().NumMyElements()); + AssertDimension(b.local_size(), A.range_partitioner().NumMyElements()); Epetra_Vector ep_x(View, A.domain_partitioner(), x.begin()); Epetra_Vector ep_b(View, @@ -257,12 +253,8 @@ namespace TrilinosWrappers const dealii::LinearAlgebra::distributed::Vector &b, const PreconditionBase &preconditioner) { - AssertDimension(static_cast( - x.local_size()), - A.OperatorDomainMap().NumMyElements()); - AssertDimension(static_cast( - b.local_size()), - A.OperatorRangeMap().NumMyElements()); + AssertDimension(x.local_size(), A.OperatorDomainMap().NumMyElements()); + AssertDimension(b.local_size(), A.OperatorRangeMap().NumMyElements()); Epetra_Vector ep_x(View, A.OperatorDomainMap(), x.begin()); Epetra_Vector ep_b(View, @@ -913,12 +905,8 @@ namespace TrilinosWrappers dealii::LinearAlgebra::distributed::Vector & x, const dealii::LinearAlgebra::distributed::Vector &b) { - AssertDimension(static_cast( - x.local_size()), - A.domain_partitioner().NumMyElements()); - AssertDimension(static_cast( - b.local_size()), - A.range_partitioner().NumMyElements()); + AssertDimension(x.local_size(), A.domain_partitioner().NumMyElements()); + AssertDimension(b.local_size(), A.range_partitioner().NumMyElements()); Epetra_Vector ep_x(View, A.domain_partitioner(), x.begin()); Epetra_Vector ep_b(View, A.range_partitioner(), diff --git a/source/lac/trilinos_sparse_matrix.cc b/source/lac/trilinos_sparse_matrix.cc index d4e01cea70..2f1c18e426 100644 --- a/source/lac/trilinos_sparse_matrix.cc +++ b/source/lac/trilinos_sparse_matrix.cc @@ -492,13 +492,9 @@ namespace TrilinosWrappers if (input_row_map.Comm().MyPID() == 0) { AssertDimension(sparsity_pattern.n_rows(), - static_cast( - TrilinosWrappers::n_global_elements( - input_row_map))); + TrilinosWrappers::n_global_elements(input_row_map)); AssertDimension(sparsity_pattern.n_cols(), - static_cast( - TrilinosWrappers::n_global_elements( - input_col_map))); + TrilinosWrappers::n_global_elements(input_col_map)); } column_space_map = std_cxx14::make_unique(input_col_map); @@ -584,8 +580,7 @@ namespace TrilinosWrappers // check whether we got the number of columns right. AssertDimension(sparsity_pattern.n_cols(), - static_cast( - TrilinosWrappers::n_global_cols(*graph))); + TrilinosWrappers::n_global_cols(*graph)); (void)n_global_cols; // And now finally generate the matrix. @@ -634,11 +629,9 @@ namespace TrilinosWrappers nonlocal_matrix_exporter.reset(); AssertDimension(sparsity_pattern.n_rows(), - static_cast( - TrilinosWrappers::n_global_elements(input_row_map))); + TrilinosWrappers::n_global_elements(input_row_map)); AssertDimension(sparsity_pattern.n_cols(), - static_cast( - TrilinosWrappers::n_global_elements(input_col_map))); + TrilinosWrappers::n_global_elements(input_col_map)); column_space_map = std_cxx14::make_unique(input_col_map); @@ -786,8 +779,7 @@ namespace TrilinosWrappers graph->OptimizeStorage(); AssertDimension(sparsity_pattern.n_cols(), - static_cast( - TrilinosWrappers::n_global_cols(*graph))); + TrilinosWrappers::n_global_cols(*graph)); matrix = std_cxx14::make_unique(Copy, *graph, false); } @@ -1867,7 +1859,7 @@ namespace TrilinosWrappers indices.size(), n_indices, indices.data()); - AssertDimension(static_cast(n_indices), indices.size()); + AssertDimension(n_indices, indices.size()); for (TrilinosWrappers::types::int_type i = 0; i < n_indices; ++i) std::cout << indices[i] << " "; @@ -2100,11 +2092,9 @@ namespace TrilinosWrappers src, dst); const size_type dst_local_size = internal::end(dst) - internal::begin(dst); - AssertDimension(dst_local_size, - static_cast(matrix->RangeMap().NumMyPoints())); + AssertDimension(dst_local_size, matrix->RangeMap().NumMyPoints()); const size_type src_local_size = internal::end(src) - internal::begin(src); - AssertDimension(src_local_size, - static_cast(matrix->DomainMap().NumMyPoints())); + AssertDimension(src_local_size, matrix->DomainMap().NumMyPoints()); Epetra_MultiVector tril_dst( View, matrix->RangeMap(), internal::begin(dst), dst_local_size, 1); @@ -2133,11 +2123,9 @@ namespace TrilinosWrappers dst, src); const size_type dst_local_size = internal::end(dst) - internal::begin(dst); - AssertDimension(dst_local_size, - static_cast(matrix->DomainMap().NumMyPoints())); + AssertDimension(dst_local_size, matrix->DomainMap().NumMyPoints()); const size_type src_local_size = internal::end(src) - internal::begin(src); - AssertDimension(src_local_size, - static_cast(matrix->RangeMap().NumMyPoints())); + AssertDimension(src_local_size, matrix->RangeMap().NumMyPoints()); Epetra_MultiVector tril_dst( View, matrix->DomainMap(), internal::begin(dst), dst_local_size, 1); @@ -3097,13 +3085,9 @@ namespace TrilinosWrappers // Duplicated from TrilinosWrappers::SparseMatrix::vmult const size_type i_local_size = i->end() - i->begin(); - AssertDimension(i_local_size, - static_cast( - first_op_init_map.NumMyPoints())); + AssertDimension(i_local_size, first_op_init_map.NumMyPoints()); const Epetra_Map &second_op_init_map = second_op.OperatorDomainMap(); - AssertDimension(i_local_size, - static_cast( - second_op_init_map.NumMyPoints())); + AssertDimension(i_local_size, second_op_init_map.NumMyPoints()); (void)second_op_init_map; Intermediate tril_int(View, first_op_init_map, @@ -3141,13 +3125,9 @@ namespace TrilinosWrappers // Duplicated from TrilinosWrappers::SparseMatrix::vmult const size_type i_local_size = i->end() - i->begin(); - AssertDimension(i_local_size, - static_cast( - first_op_init_map.NumMyPoints())); + AssertDimension(i_local_size, first_op_init_map.NumMyPoints()); const Epetra_Map &second_op_init_map = second_op.OperatorRangeMap(); - AssertDimension(i_local_size, - static_cast( - second_op_init_map.NumMyPoints())); + AssertDimension(i_local_size, second_op_init_map.NumMyPoints()); (void)second_op_init_map; Intermediate tril_int(View, first_op_init_map, @@ -3182,13 +3162,9 @@ namespace TrilinosWrappers // Duplicated from TrilinosWrappers::SparseMatrix::vmult const size_type i_local_size = i->end() - i->begin(); - AssertDimension(i_local_size, - static_cast( - first_op_init_map.NumMyPoints())); + AssertDimension(i_local_size, first_op_init_map.NumMyPoints()); const Epetra_Map &second_op_init_map = second_op.OperatorRangeMap(); - AssertDimension(i_local_size, - static_cast( - second_op_init_map.NumMyPoints())); + AssertDimension(i_local_size, second_op_init_map.NumMyPoints()); (void)second_op_init_map; Intermediate tril_int(View, first_op_init_map, @@ -3226,13 +3202,9 @@ namespace TrilinosWrappers // Duplicated from TrilinosWrappers::SparseMatrix::vmult const size_type i_local_size = i->end() - i->begin(); - AssertDimension(i_local_size, - static_cast( - first_op_init_map.NumMyPoints())); + AssertDimension(i_local_size, first_op_init_map.NumMyPoints()); const Epetra_Map &second_op_init_map = second_op.OperatorDomainMap(); - AssertDimension(i_local_size, - static_cast( - second_op_init_map.NumMyPoints())); + AssertDimension(i_local_size, second_op_init_map.NumMyPoints()); (void)second_op_init_map; Intermediate tril_int(View, first_op_init_map, @@ -3288,13 +3260,9 @@ namespace TrilinosWrappers // Duplicated from TrilinosWrappers::SparseMatrix::vmult const size_type i_local_size = i->end() - i->begin(); - AssertDimension(i_local_size, - static_cast( - first_op_init_map.NumMyPoints())); + AssertDimension(i_local_size, first_op_init_map.NumMyPoints()); const Epetra_Map &second_op_init_map = second_op.OperatorRangeMap(); - AssertDimension(i_local_size, - static_cast( - second_op_init_map.NumMyPoints())); + AssertDimension(i_local_size, second_op_init_map.NumMyPoints()); (void)second_op_init_map; Intermediate tril_int(View, first_op_init_map, @@ -3330,13 +3298,9 @@ namespace TrilinosWrappers // Duplicated from TrilinosWrappers::SparseMatrix::vmult const size_type i_local_size = i->end() - i->begin(); - AssertDimension(i_local_size, - static_cast( - first_op_init_map.NumMyPoints())); + AssertDimension(i_local_size, first_op_init_map.NumMyPoints()); const Epetra_Map &second_op_init_map = second_op.OperatorDomainMap(); - AssertDimension(i_local_size, - static_cast( - second_op_init_map.NumMyPoints())); + AssertDimension(i_local_size, second_op_init_map.NumMyPoints()); (void)second_op_init_map; Intermediate tril_int(View, first_op_init_map, @@ -3368,13 +3332,9 @@ namespace TrilinosWrappers // Duplicated from TrilinosWrappers::SparseMatrix::vmult const size_type i_local_size = i->end() - i->begin(); - AssertDimension(i_local_size, - static_cast( - first_op_init_map.NumMyPoints())); + AssertDimension(i_local_size, first_op_init_map.NumMyPoints()); const Epetra_Map &second_op_init_map = second_op.OperatorDomainMap(); - AssertDimension(i_local_size, - static_cast( - second_op_init_map.NumMyPoints())); + AssertDimension(i_local_size, second_op_init_map.NumMyPoints()); (void)second_op_init_map; Intermediate tril_int(View, first_op_init_map, @@ -3410,13 +3370,9 @@ namespace TrilinosWrappers // Duplicated from TrilinosWrappers::SparseMatrix::vmult const size_type i_local_size = i->end() - i->begin(); - AssertDimension(i_local_size, - static_cast( - first_op_init_map.NumMyPoints())); + AssertDimension(i_local_size, first_op_init_map.NumMyPoints()); const Epetra_Map &second_op_init_map = second_op.OperatorRangeMap(); - AssertDimension(i_local_size, - static_cast( - second_op_init_map.NumMyPoints())); + AssertDimension(i_local_size, second_op_init_map.NumMyPoints()); (void)second_op_init_map; Intermediate tril_int(View, first_op_init_map, diff --git a/source/lac/trilinos_sparsity_pattern.cc b/source/lac/trilinos_sparsity_pattern.cc index 6c71e8af47..2a2bdf71f1 100644 --- a/source/lac/trilinos_sparsity_pattern.cc +++ b/source/lac/trilinos_sparsity_pattern.cc @@ -335,8 +335,7 @@ namespace TrilinosWrappers nonlocal_graph.reset(); graph.reset(); AssertDimension(n_entries_per_row.size(), - static_cast( - TrilinosWrappers::n_global_elements(row_map))); + TrilinosWrappers::n_global_elements(row_map)); column_space_map = std_cxx14::make_unique(col_map); std::vector local_entries_per_row( @@ -376,11 +375,9 @@ namespace TrilinosWrappers graph.reset(); AssertDimension(sp.n_rows(), - static_cast( - TrilinosWrappers::n_global_elements(row_map))); + TrilinosWrappers::n_global_elements(row_map)); AssertDimension(sp.n_cols(), - static_cast( - TrilinosWrappers::n_global_elements(col_map))); + TrilinosWrappers::n_global_elements(col_map)); column_space_map = std_cxx14::make_unique(col_map); @@ -405,8 +402,7 @@ namespace TrilinosWrappers graph = std_cxx14::make_unique( Copy, row_map, col_map, n_entries_per_row.data(), false); - AssertDimension(sp.n_rows(), - static_cast(n_global_rows(*graph))); + AssertDimension(sp.n_rows(), n_global_rows(*graph)); std::vector row_indices;