From 8ee959e8c6f26cab60ee9f2d05936b2aff96c88d Mon Sep 17 00:00:00 2001 From: David Wells Date: Sun, 18 Oct 2015 21:29:18 -0400 Subject: [PATCH] Use VectorType, not Vector, as a template type. Writing something like template is ambiguous because Vector is also a class. --- include/deal.II/base/index_set.h | 4 +- include/deal.II/distributed/grid_refinement.h | 26 +++--- include/deal.II/grid/grid_refinement.h | 44 +++++----- .../deal.II/numerics/vector_tools.templates.h | 22 ++--- source/distributed/grid_refinement.cc | 46 +++++------ source/grid/grid_refinement.cc | 81 +++++++++---------- tests/gla/extract_subvector_to.cc | 10 +-- tests/gla/extract_subvector_to_parallel.cc | 14 ++-- tests/lac/block_matrices_04.cc | 44 +++++----- tests/lapack/solver_cg.cc | 19 +++-- 10 files changed, 157 insertions(+), 153 deletions(-) diff --git a/include/deal.II/base/index_set.h b/include/deal.II/base/index_set.h index 74de38b1a2..b0dc5a4016 100644 --- a/include/deal.II/base/index_set.h +++ b/include/deal.II/base/index_set.h @@ -295,8 +295,8 @@ public: * Vector, BlockVector, but also std::vector@, std::vector@, * and std::vector@. */ - template - void fill_binary_vector (Vector &vector) const; + template + void fill_binary_vector (VectorType &vector) const; /** * Outputs a text representation of this IndexSet to the given stream. Used diff --git a/include/deal.II/distributed/grid_refinement.h b/include/deal.II/distributed/grid_refinement.h index e26a8f0ad8..ff774b1bc9 100644 --- a/include/deal.II/distributed/grid_refinement.h +++ b/include/deal.II/distributed/grid_refinement.h @@ -65,14 +65,14 @@ namespace parallel * * The same is true for the fraction of cells that is coarsened. */ - template + template void - refine_and_coarsen_fixed_number ( - parallel::distributed::Triangulation &tria, - const Vector &criteria, - const double top_fraction_of_cells, - const double bottom_fraction_of_cells, - const unsigned int max_n_cells = std::numeric_limits::max()); + refine_and_coarsen_fixed_number + (parallel::distributed::Triangulation &tria, + const VectorType &criteria, + const double top_fraction_of_cells, + const double bottom_fraction_of_cells, + const unsigned int max_n_cells = std::numeric_limits::max()); /** * Like dealii::GridRefinement::refine_and_coarsen_fixed_fraction, but @@ -94,13 +94,13 @@ namespace parallel * * The same is true for the fraction of cells that is coarsened. */ - template + template void - refine_and_coarsen_fixed_fraction ( - parallel::distributed::Triangulation &tria, - const Vector &criteria, - const double top_fraction_of_error, - const double bottom_fraction_of_error); + refine_and_coarsen_fixed_fraction + (parallel::distributed::Triangulation &tria, + const VectorType &criteria, + const double top_fraction_of_error, + const double bottom_fraction_of_error); } } } diff --git a/include/deal.II/grid/grid_refinement.h b/include/deal.II/grid/grid_refinement.h index 318cbb785e..3d47f705bb 100644 --- a/include/deal.II/grid/grid_refinement.h +++ b/include/deal.II/grid/grid_refinement.h @@ -146,14 +146,14 @@ namespace GridRefinement * indicator. The default value of this argument is to impose no limit on * the number of cells. */ - template + template void - refine_and_coarsen_fixed_number ( - Triangulation &tria, - const Vector &criteria, - const double top_fraction_of_cells, - const double bottom_fraction_of_cells, - const unsigned int max_n_cells = std::numeric_limits::max()); + refine_and_coarsen_fixed_number + (Triangulation &tria, + const VectorType &criteria, + const double top_fraction_of_cells, + const double bottom_fraction_of_cells, + const unsigned int max_n_cells = std::numeric_limits::max()); /** * This function provides a refinement strategy controlling the reduction of @@ -207,14 +207,14 @@ namespace GridRefinement * indicator. The default value of this argument is to impose no limit on * the number of cells. */ - template + template void - refine_and_coarsen_fixed_fraction ( - Triangulation &tria, - const Vector &criteria, - const double top_fraction, - const double bottom_fraction, - const unsigned int max_n_cells = std::numeric_limits::max()); + refine_and_coarsen_fixed_fraction + (Triangulation &tria, + const VectorType &criteria, + const double top_fraction, + const double bottom_fraction, + const unsigned int max_n_cells = std::numeric_limits::max()); @@ -290,11 +290,11 @@ namespace GridRefinement * thesis, University of Heidelberg, 2005. See in particular Section 4.3, * pp. 42-43. */ - template + template void refine_and_coarsen_optimize (Triangulation &tria, - const Vector &criteria, - const unsigned int order=2); + const VectorType &criteria, + const unsigned int order=2); /** * Flag all mesh cells for which the value in @p criteria exceeds @p @@ -310,11 +310,11 @@ namespace GridRefinement * This function does not implement a refinement strategy, it is more a * helper function for the actual strategies. */ - template + template void refine (Triangulation &tria, - const Vector &criteria, + const VectorType &criteria, const double threshold, - const unsigned int max_to_mark = numbers::invalid_unsigned_int); + const unsigned int max_to_mark = numbers::invalid_unsigned_int); /** * Flag all mesh cells for which the value in @p criteria is less than @p @@ -330,9 +330,9 @@ namespace GridRefinement * This function does not implement a refinement strategy, it is more a * helper function for the actual strategies. */ - template + template void coarsen (Triangulation &tria, - const Vector &criteria, + const VectorType &criteria, const double threshold); /** diff --git a/include/deal.II/numerics/vector_tools.templates.h b/include/deal.II/numerics/vector_tools.templates.h index eb89957101..928a9b3acc 100644 --- a/include/deal.II/numerics/vector_tools.templates.h +++ b/include/deal.II/numerics/vector_tools.templates.h @@ -543,12 +543,12 @@ namespace VectorTools template class DH, - class Vector> + class VectorType> void interpolate_to_different_mesh (const DH &dof1, - const Vector &u1, + const VectorType &u1, const DH &dof2, - Vector &u2) + VectorType &u2) { Assert(GridTools::have_same_coarse_mesh(dof1, dof2), ExcMessage ("The two containers must represent triangulations that " @@ -567,13 +567,13 @@ namespace VectorTools template class DH, - class Vector> + class VectorType> void interpolate_to_different_mesh (const DH &dof1, - const Vector &u1, + const VectorType &u1, const DH &dof2, const ConstraintMatrix &constraints, - Vector &u2) + VectorType &u2) { Assert(GridTools::have_same_coarse_mesh(dof1, dof2), ExcMessage ("The two containers must represent triangulations that " @@ -607,12 +607,12 @@ namespace VectorTools template class DH, - class Vector> + class VectorType> void interpolate_to_different_mesh (const InterGridMap > &intergridmap, - const Vector &u1, + const VectorType &u1, const ConstraintMatrix &constraints, - Vector &u2) + VectorType &u2) { const DH &dof1 = intergridmap.get_source_grid(); const DH &dof2 = intergridmap.get_destination_grid(); @@ -750,7 +750,7 @@ namespace VectorTools * Generic implementation of the project() function */ template class DH, template class M_or_MC, template class Q_or_QC> @@ -759,7 +759,7 @@ namespace VectorTools const ConstraintMatrix &constraints, const Q_or_QC &quadrature, const Function &function, - Vector &vec_result, + VectorType &vec_result, const bool enforce_zero_boundary, const Q_or_QC &q_boundary, const bool project_to_boundary_first) diff --git a/source/distributed/grid_refinement.cc b/source/distributed/grid_refinement.cc index 7325bc9e0e..81c6f0f6d2 100644 --- a/source/distributed/grid_refinement.cc +++ b/source/distributed/grid_refinement.cc @@ -149,11 +149,11 @@ namespace * or not), extract those that pertain to * locally owned cells. */ - template + template void get_locally_owned_indicators (const parallel::distributed::Triangulation &tria, - const Vector &criteria, - dealii::Vector &locally_owned_indicators) + const VectorType &criteria, + dealii::Vector &locally_owned_indicators) { Assert (locally_owned_indicators.size() == tria.n_locally_owned_active_cells(), ExcInternalError()); @@ -222,12 +222,12 @@ namespace * locally own as appropriate for * coarsening or refinement. */ - template + template void mark_cells (parallel::distributed::Triangulation &tria, - const Vector &criteria, - const double top_threshold, - const double bottom_threshold) + const VectorType &criteria, + const double top_threshold, + const double bottom_threshold) { dealii::GridRefinement::refine (tria, criteria, top_threshold); dealii::GridRefinement::coarsen (tria, criteria, bottom_threshold); @@ -451,14 +451,14 @@ namespace parallel { namespace GridRefinement { - template + template void - refine_and_coarsen_fixed_number ( - parallel::distributed::Triangulation &tria, - const Vector &criteria, - const double top_fraction_of_cells, - const double bottom_fraction_of_cells, - const unsigned int max_n_cells) + refine_and_coarsen_fixed_number + (parallel::distributed::Triangulation &tria, + const VectorType &criteria, + const double top_fraction_of_cells, + const double bottom_fraction_of_cells, + const unsigned int max_n_cells) { Assert (criteria.size() == tria.n_active_cells(), ExcDimensionMismatch (criteria.size(), tria.n_active_cells())); @@ -482,7 +482,7 @@ namespace parallel // vector of indicators the // ones that correspond to // cells that we locally own - dealii::Vector + dealii::Vector locally_owned_indicators (tria.n_locally_owned_active_cells()); get_locally_owned_indicators (tria, criteria, @@ -496,7 +496,7 @@ namespace parallel // need it here, but it's a // collective communication // call - const std::pair global_min_and_max + const std::pair global_min_and_max = compute_global_min_and_max_at_root (locally_owned_indicators, mpi_communicator); @@ -538,13 +538,13 @@ namespace parallel } - template + template void - refine_and_coarsen_fixed_fraction ( - parallel::distributed::Triangulation &tria, - const Vector &criteria, - const double top_fraction_of_error, - const double bottom_fraction_of_error) + refine_and_coarsen_fixed_fraction + (parallel::distributed::Triangulation &tria, + const VectorType &criteria, + const double top_fraction_of_error, + const double bottom_fraction_of_error) { Assert (criteria.size() == tria.n_active_cells(), ExcDimensionMismatch (criteria.size(), tria.n_active_cells())); @@ -561,7 +561,7 @@ namespace parallel // vector of indicators the // ones that correspond to // cells that we locally own - dealii::Vector + dealii::Vector locally_owned_indicators (tria.n_locally_owned_active_cells()); get_locally_owned_indicators (tria, criteria, diff --git a/source/grid/grid_refinement.cc b/source/grid/grid_refinement.cc index 8505d66fe9..f93af05734 100644 --- a/source/grid/grid_refinement.cc +++ b/source/grid/grid_refinement.cc @@ -118,30 +118,30 @@ namespace } /* namespace internal */ - template - typename constraint_and_return_value::value, - typename Vector::value_type>::type - min_element (const Vector &criteria) + template + typename constraint_and_return_value::value, + typename VectorType::value_type>::type + min_element (const VectorType &criteria) { return internal::min_element (criteria); } - template - typename constraint_and_return_value::value, - typename Vector::value_type>::type - max_element (const Vector &criteria) + template + typename constraint_and_return_value::value, + typename VectorType::value_type>::type + max_element (const VectorType &criteria) { return internal::max_element (criteria); } - template - typename constraint_and_return_value::value, - typename Vector::value_type>::type - min_element (const Vector &criteria) + template + typename constraint_and_return_value::value, + typename VectorType::value_type>::type + min_element (const VectorType &criteria) { - typename Vector::value_type t = internal::min_element(criteria.block(0)); + typename VectorType::value_type t = internal::min_element(criteria.block(0)); for (unsigned int b=1; b - typename constraint_and_return_value::value, - typename Vector::value_type>::type - max_element (const Vector &criteria) + template + typename constraint_and_return_value::value, + typename VectorType::value_type>::type + max_element (const VectorType &criteria) { - typename Vector::value_type t = internal::max_element(criteria.block(0)); + typename VectorType::value_type t = internal::max_element(criteria.block(0)); for (unsigned int b=1; b - void qsort_index (const Vector &a, + template + void qsort_index (const VectorType &a, std::vector &ind, int l, int r) { int i,j; - typename Vector::value_type v; + typename VectorType::value_type v; if (r<=l) return; @@ -214,9 +214,9 @@ namespace -template +template void GridRefinement::refine (Triangulation &tria, - const Vector &criteria, + const VectorType &criteria, const double threshold, const unsigned int max_to_mark) { @@ -261,10 +261,10 @@ void GridRefinement::refine (Triangulation &tria, -template +template void GridRefinement::coarsen (Triangulation &tria, - const Vector &criteria, - const double threshold) + const VectorType &criteria, + const double threshold) { Assert (criteria.size() == tria.n_active_cells(), ExcDimensionMismatch(criteria.size(), tria.n_active_cells())); @@ -359,13 +359,13 @@ GridRefinement::adjust_refine_and_coarsen_number_fraction (const unsigned int c return (adjusted_fractions); } -template +template void GridRefinement::refine_and_coarsen_fixed_number (Triangulation &tria, - const Vector &criteria, - const double top_fraction, - const double bottom_fraction, - const unsigned int max_n_cells) + const VectorType &criteria, + const double top_fraction, + const double bottom_fraction, + const unsigned int max_n_cells) { // correct number of cells is // checked in @p{refine} @@ -385,7 +385,7 @@ GridRefinement::refine_and_coarsen_fixed_number (Triangulation &tr if (refine_cells || coarsen_cells) { - dealii::Vector tmp (criteria); + dealii::Vector tmp (criteria); if (refine_cells) { std::nth_element (tmp.begin(), tmp.begin()+refine_cells, @@ -407,10 +407,10 @@ GridRefinement::refine_and_coarsen_fixed_number (Triangulation &tr -template +template void GridRefinement::refine_and_coarsen_fixed_fraction (Triangulation &tria, - const Vector &criteria, + const VectorType &criteria, const double top_fraction, const double bottom_fraction, const unsigned int max_n_cells) @@ -426,7 +426,7 @@ GridRefinement::refine_and_coarsen_fixed_fraction (Triangulation & // error, which is what we have to sum // up and compare with // @p{fraction_of_error*total_error}. - dealii::Vector tmp; + dealii::Vector tmp; tmp = criteria; const double total_error = tmp.l1_norm(); @@ -435,7 +435,7 @@ GridRefinement::refine_and_coarsen_fixed_fraction (Triangulation & std::sort (tmp.begin(), tmp.end(), std::greater()); // compute thresholds - typename dealii::Vector::const_iterator + typename dealii::Vector::const_iterator pp=tmp.begin(); for (double sum=0; (sum & double top_threshold = ( pp != tmp.begin () ? (*pp+*(pp-1))/2 : *pp ); - typename dealii::Vector::const_iterator + typename dealii::Vector::const_iterator qq=(tmp.end()-1); for (double sum=0; (sum & -template +template void GridRefinement::refine_and_coarsen_optimize (Triangulation &tria, - const Vector &criteria, - const unsigned int order) + const VectorType &criteria, + const unsigned int order) { Assert (criteria.size() == tria.n_active_cells(), ExcDimensionMismatch(criteria.size(), tria.n_active_cells())); @@ -586,4 +586,3 @@ GridRefinement::refine_and_coarsen_optimize (Triangulation &tria, #include "grid_refinement.inst" DEAL_II_NAMESPACE_CLOSE - diff --git a/tests/gla/extract_subvector_to.cc b/tests/gla/extract_subvector_to.cc index 5ebf4ec93a..743c156198 100644 --- a/tests/gla/extract_subvector_to.cc +++ b/tests/gla/extract_subvector_to.cc @@ -29,8 +29,8 @@ #include -template -void test (Vector &vector) +template +void test (VectorType &vector) { const unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); @@ -38,19 +38,19 @@ void test (Vector &vector) vector(i) = i; // select every other element - std::vector indices; + std::vector indices; for (unsigned int j=0; j values1 (indices.size()); + std::vector values1 (indices.size()); vector.extract_subvector_to (indices, values1); for (unsigned int j=0; j values2 (indices.size()); + std::vector values2 (indices.size()); vector.extract_subvector_to (indices.begin(), indices.end(), values2.begin()); diff --git a/tests/gla/extract_subvector_to_parallel.cc b/tests/gla/extract_subvector_to_parallel.cc index eddef20bda..a231ba956f 100644 --- a/tests/gla/extract_subvector_to_parallel.cc +++ b/tests/gla/extract_subvector_to_parallel.cc @@ -28,8 +28,8 @@ #include -template -void set (Vector &vector) +template +void set (VectorType &vector) { for (unsigned int i=0; i -void test (Vector &vector) +template +void test (VectorType &vector) { const unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); // select every other element - std::vector indices; + std::vector indices; for (unsigned int j=0; j values1 (indices.size()); + std::vector values1 (indices.size()); vector.extract_subvector_to (indices, values1); for (unsigned int j=0; j values2 (indices.size()); + std::vector values2 (indices.size()); vector.extract_subvector_to (indices.begin(), indices.end(), values2.begin()); diff --git a/tests/lac/block_matrices_04.cc b/tests/lac/block_matrices_04.cc index c036f37319..5aad98e6ab 100644 --- a/tests/lac/block_matrices_04.cc +++ b/tests/lac/block_matrices_04.cc @@ -54,7 +54,7 @@ #include -template +template class LaplaceProblem { public: @@ -64,7 +64,7 @@ public: void reinit_sparsity (); void reinit_vectors (); - Vector solution; + VectorType solution; private: void make_grid_and_dofs (); @@ -73,19 +73,19 @@ private: const unsigned int n_blocks; - Triangulation<2> triangulation; - FE_Q<2> fe; - DoFHandler<2> dof_handler; + Triangulation<2> triangulation; + FE_Q<2> fe; + DoFHandler<2> dof_handler; - Sparsity sparsity_pattern; - Matrix system_matrix; + Sparsity sparsity_pattern; + Matrix system_matrix; - Vector system_rhs; + VectorType system_rhs; }; -template -LaplaceProblem::LaplaceProblem (const unsigned int n_blocks) : +template +LaplaceProblem::LaplaceProblem (const unsigned int n_blocks) : n_blocks (n_blocks), fe(1), dof_handler (triangulation) @@ -113,8 +113,8 @@ LaplaceProblem,SparseMatrix,SparsityPattern>::LaplaceProble -template -void LaplaceProblem::make_grid_and_dofs () +template +void LaplaceProblem::make_grid_and_dofs () { GridGenerator::hyper_cube (triangulation, -1, 1); triangulation.refine_global (3); @@ -256,8 +256,8 @@ void LaplaceProblem,BlockSparseMatrix,BlockSparsityP -template -void LaplaceProblem::assemble_system () +template +void LaplaceProblem::assemble_system () { QGauss<2> quadrature_formula(2); FEValues<2> fe_values (fe, quadrature_formula, @@ -320,12 +320,12 @@ void LaplaceProblem::assemble_system () } -template -void LaplaceProblem::solve () +template +void LaplaceProblem::solve () { - SolverControl solver_control (1000, 1e-12, false, false); - PrimitiveVectorMemory vector_memory; - SolverCG cg (solver_control, vector_memory); + SolverControl solver_control (1000, 1e-12, false, false); + PrimitiveVectorMemory vector_memory; + SolverCG cg (solver_control, vector_memory); PreconditionJacobi preconditioner; preconditioner.initialize (system_matrix, 0.8); @@ -335,8 +335,8 @@ void LaplaceProblem::solve () } -template -void LaplaceProblem::run () +template +void LaplaceProblem::run () { make_grid_and_dofs (); assemble_system (); @@ -344,7 +344,7 @@ void LaplaceProblem::run () for (unsigned int i=0; i #include -template +template void -check_solve( SOLVER &solver, const MATRIX &A, - VECTOR &u, VECTOR &f, const PRECONDITION &P) +check_solve (SOLVER &solver, + const MATRIX &A, + VectorType &u, + VectorType &f, + const PRECONDITION &P) { u = 0.; f = 1.; @@ -48,10 +51,13 @@ check_solve( SOLVER &solver, const MATRIX &A, } } -template +template void -check_Tsolve(SOLVER &solver, const MATRIX &A, - VECTOR &u, VECTOR &f, const PRECONDITION &P) +check_Tsolve (SOLVER &solver, + const MATRIX &A, + VectorType &u, + VectorType &f, + const PRECONDITION &P) { u = 0.; f = 1.; @@ -136,4 +142,3 @@ int main() } } } - -- 2.39.5