From: turcksin Date: Fri, 22 Feb 2013 20:56:58 +0000 (+0000) Subject: Convert unsigned int to size_type. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=546f70c3347b4a8d5eece8ffa7cc2c1398a054f8;p=dealii-svn.git Convert unsigned int to size_type. git-svn-id: https://svn.dealii.org/branches/branch_bigger_global_dof_indices_4@28531 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/files b/deal.II/files index 5e614a31aa..da5d3954fe 100644 --- a/deal.II/files +++ b/deal.II/files @@ -90,10 +90,10 @@ KAINAN source/fe/mapping_q1.cc KAINAN source/fe/mapping_q1_eulerian.cc KAINAN source/fe/mapping_q.cc KAINAN source/fe/mapping_q_eulerian.cc -source/grid/grid_generator.cc -source/grid/grid_in.cc -source/grid/grid_out.cc -source/grid/grid_refinement.cc +BRUNO source/grid/grid_generator.cc +BRUNO source/grid/grid_in.cc +BRUNO source/grid/grid_out.cc +BRUNO source/grid/grid_refinement.cc source/grid/grid_reordering.cc source/grid/grid_tools.cc source/grid/intergrid_map.cc @@ -144,19 +144,19 @@ BRUNO source/lac/petsc_vector.cc BRUNO source/lac/precondition_block.cc BRUNO source/lac/precondition_block_ez.cc BRUNO source/lac/relaxation_block.cc -source/lac/slepc_solver.cc -source/lac/slepc_spectral_transformation.cc -source/lac/solver.cc -source/lac/solver_control.cc -source/lac/sparse_decomposition.cc -source/lac/sparse_direct.cc -source/lac/sparse_ilu.cc -source/lac/sparse_matrix.cc -source/lac/sparse_matrix_ez.cc -source/lac/sparse_mic.cc -source/lac/sparse_vanka.cc -source/lac/sparsity_pattern.cc -source/lac/sparsity_tools.cc +BRUNO source/lac/slepc_solver.cc +BRUNO source/lac/slepc_spectral_transformation.cc +BRUNO source/lac/solver.cc +BRUNO source/lac/solver_control.cc +BRUNO source/lac/sparse_decomposition.cc +BRUNO source/lac/sparse_direct.cc +BRUNO source/lac/sparse_ilu.cc +BRUNO source/lac/sparse_matrix.cc +BRUNO source/lac/sparse_matrix_ez.cc +BRUNO source/lac/sparse_mic.cc +BRUNO source/lac/sparse_vanka.cc +BRUNO source/lac/sparsity_pattern.cc +BRUNO source/lac/sparsity_tools.cc BRUNO source/lac/swappable_vector.cc BRUNO source/lac/timestep_control.cc BRUNO source/lac/tridiagonal_matrix.cc @@ -273,16 +273,16 @@ TIMO include/deal.II/distributed/tria.h MARKUS include/deal.II/dofs/block_info.h TIMO include/deal.II/dofs/dof_accessor.h TIMO include/deal.II/dofs/dof_accessor.templates.h -include/deal.II/dofs/dof_constraints.h +BRUNO include/deal.II/dofs/dof_constraints.h UWE include/deal.II/dofs/dof_faces.h MARKUS include/deal.II/dofs/dof_handler.h TIMO include/deal.II/dofs/dof_handler_policy.h -include/deal.II/dofs/dof_iterator_selector.h +BRUNO include/deal.II/dofs/dof_iterator_selector.h UWE include/deal.II/dofs/dof_levels.h UWE include/deal.II/dofs/dof_objects.h HELENE include/deal.II/dofs/dof_renumbering.h UWE include/deal.II/dofs/dof_tools.h -include/deal.II/dofs/function_map.h +BRUNO include/deal.II/dofs/function_map.h TIMO include/deal.II/dofs/number_cache.h GK include/deal.II/fe/fe_abf.h GK include/deal.II/fe/fe_base.h @@ -316,12 +316,12 @@ KAINAN include/deal.II/fe/mapping_q1_eulerian.h KAINAN include/deal.II/fe/mapping_q1.h KAINAN include/deal.II/fe/mapping_q_eulerian.h KAINAN include/deal.II/fe/mapping_q.h -include/deal.II/grid/filtered_iterator.h -include/deal.II/grid/geometry_info.h -include/deal.II/grid/grid_generator.h -include/deal.II/grid/grid_in.h -include/deal.II/grid/grid_out.h -include/deal.II/grid/grid_refinement.h +BRUNO include/deal.II/grid/filtered_iterator.h +BRUNO include/deal.II/grid/geometry_info.h +BRUNO include/deal.II/grid/grid_generator.h +BRUNO include/deal.II/grid/grid_in.h +BRUNO include/deal.II/grid/grid_out.h +BRUNO include/deal.II/grid/grid_refinement.h include/deal.II/grid/grid_reordering.h include/deal.II/grid/grid_reordering_internal.h include/deal.II/grid/grid_tools.h @@ -419,33 +419,33 @@ BRUNO include/deal.II/lac/relaxation_block.h BRUNO include/deal.II/lac/relaxation_block.templates.h BRUNO include/deal.II/lac/schur_matrix.h BRUNO include/deal.II/lac/shifted_matrix.h -include/deal.II/lac/slepc_solver.h -include/deal.II/lac/slepc_spectral_transformation.h -include/deal.II/lac/solver_bicgstab.h -include/deal.II/lac/solver_cg.h -include/deal.II/lac/solver_control.h -include/deal.II/lac/solver_gmres.h -include/deal.II/lac/solver.h -include/deal.II/lac/solver_minres.h -include/deal.II/lac/solver_qmrs.h -include/deal.II/lac/solver_relaxation.h -include/deal.II/lac/solver_richardson.h -include/deal.II/lac/solver_selector.h -include/deal.II/lac/sparse_decomposition.h -include/deal.II/lac/sparse_decomposition.templates.h -include/deal.II/lac/sparse_direct.h -include/deal.II/lac/sparse_ilu.h -include/deal.II/lac/sparse_ilu.templates.h -include/deal.II/lac/sparse_matrix_ez.h -include/deal.II/lac/sparse_matrix_ez.templates.h -include/deal.II/lac/sparse_matrix.h -include/deal.II/lac/sparse_matrix.templates.h -include/deal.II/lac/sparse_mic.h -include/deal.II/lac/sparse_mic.templates.h -include/deal.II/lac/sparse_vanka.h -include/deal.II/lac/sparse_vanka.templates.h -include/deal.II/lac/sparsity_pattern.h -include/deal.II/lac/sparsity_tools.h +BRUNO include/deal.II/lac/slepc_solver.h +BRUNO include/deal.II/lac/slepc_spectral_transformation.h +BRUNO include/deal.II/lac/solver_bicgstab.h +BRUNO include/deal.II/lac/solver_cg.h +BRUNO include/deal.II/lac/solver_control.h +BRUNO include/deal.II/lac/solver_gmres.h +BRUNO include/deal.II/lac/solver.h +BRUNO include/deal.II/lac/solver_minres.h +BRUNO include/deal.II/lac/solver_qmrs.h +BRUNO include/deal.II/lac/solver_relaxation.h +BRUNO include/deal.II/lac/solver_richardson.h +BRUNO include/deal.II/lac/solver_selector.h +BRUNO include/deal.II/lac/sparse_decomposition.h +BRUNO include/deal.II/lac/sparse_decomposition.templates.h +BRUNO include/deal.II/lac/sparse_direct.h +BRUNO include/deal.II/lac/sparse_ilu.h +BRUNO include/deal.II/lac/sparse_ilu.templates.h +BRUNO include/deal.II/lac/sparse_matrix_ez.h +BRUNO include/deal.II/lac/sparse_matrix_ez.templates.h +BRUNO include/deal.II/lac/sparse_matrix.h +BRUNO include/deal.II/lac/sparse_matrix.templates.h +BRUNO include/deal.II/lac/sparse_mic.h +BRUNO include/deal.II/lac/sparse_mic.templates.h +BRUNO include/deal.II/lac/sparse_vanka.h +BRUNO include/deal.II/lac/sparse_vanka.templates.h +BRUNO include/deal.II/lac/sparsity_pattern.h +BRUNO include/deal.II/lac/sparsity_tools.h BRUNO include/deal.II/lac/swappable_vector.h BRUNO include/deal.II/lac/swappable_vector.templates.h BRUNO include/deal.II/lac/transpose_matrix.h diff --git a/deal.II/include/deal.II/grid/grid_generator.h b/deal.II/include/deal.II/grid/grid_generator.h index b92327f0bf..f899b62e7f 100644 --- a/deal.II/include/deal.II/grid/grid_generator.h +++ b/deal.II/include/deal.II/grid/grid_generator.h @@ -51,6 +51,11 @@ template class SparseMatrix; class GridGenerator { public: + /** + * Declare type for number of cell. + */ + typedef types::global_dof_index size_type; + /** * Initialize the given triangulation with a hypercube (line in 1D, square * in 2D, etc) consisting of exactly one cell. The hypercube volume is the @@ -262,7 +267,7 @@ public: static void subdivided_parallelepiped (Triangulation &tria, - const unsigned int n_subdivisions, + const size_type n_subdivisions, const Point (&corners) [dim], const bool colorize = false); @@ -278,7 +283,7 @@ public: static void subdivided_parallelepiped (Triangulation &tria, - const unsigned int ( n_subdivisions) [dim], + const size_type ( n_subdivisions) [dim], const Point (&corners) [dim], const bool colorize = false); @@ -486,7 +491,7 @@ public: const Point ¢er, const double inner_radius, const double outer_radius, - const unsigned int n_cells = 0, + const size_type n_cells = 0, bool colorize = false); /** @@ -515,7 +520,7 @@ public: const Point ¢er, const double inner_radius, const double outer_radius, - const unsigned int n_cells = 0, + const size_type n_cells = 0, const bool colorize = false); @@ -544,7 +549,7 @@ public: const Point ¢er, const double inner_radius, const double outer_radius, - const unsigned int n_cells = 0, + const size_type n_cells = 0, const bool colorize = false); /** @@ -564,8 +569,8 @@ public: const double length, const double inner_radius, const double outer_radius, - const unsigned int n_radial_cells = 0, - const unsigned int n_axial_cells = 0); + const size_type n_radial_cells = 0, + const size_type n_axial_cells = 0); @@ -631,7 +636,7 @@ public: * @param r The radius of the cylinder bend together as loop. */ static void moebius (Triangulation<3,3> &tria, - const unsigned int n_cells, + const size_type n_cells, const unsigned int n_rotations, const double R, const double r); @@ -684,7 +689,7 @@ public: static void extrude_triangulation(const Triangulation<2, 2> & input, - const unsigned int n_slices, + const size_type n_slices, const double height, Triangulation<3,3> &result); @@ -702,7 +707,7 @@ public: */ template static void laplace_transformation (Triangulation &tria, - const std::map > &new_points); + const std::map > &new_points); /** * Exception @@ -780,7 +785,7 @@ private: static void laplace_solve (const SparseMatrix &S, - const std::map &m, + const std::map &m, Vector &u); }; diff --git a/deal.II/include/deal.II/lac/slepc_solver.h b/deal.II/include/deal.II/lac/slepc_solver.h index 7c7a38f923..367a986fb0 100644 --- a/deal.II/include/deal.II/lac/slepc_solver.h +++ b/deal.II/include/deal.II/lac/slepc_solver.h @@ -105,6 +105,10 @@ namespace SLEPcWrappers class SolverBase { public: + /** + * Declare type for container size. + */ + typedef types::global_dof_index size_type; /** * Constructor. Takes the MPI communicator over which parallel @@ -143,7 +147,7 @@ namespace SLEPcWrappers solve (const PETScWrappers::MatrixBase &A, std::vector &kr, std::vector &vr, - const unsigned int n_eigenvectors); + const size_type n_eigenvectors); /** * Same as above, but here a composite method for solving the @@ -155,7 +159,7 @@ namespace SLEPcWrappers const PETScWrappers::MatrixBase &B, std::vector &kr, std::vector &vr, - const unsigned int n_eigenvectors); + const size_type n_eigenvectors); /** * Initialize solver for the linear system $Ax=\lambda x$. (Note: @@ -201,7 +205,7 @@ namespace SLEPcWrappers * SLEPc eigensolver used. */ void - solve (const unsigned int n_eigenvectors, unsigned int *n_converged); + solve (const size_type n_eigenvectors, size_type *n_converged); /** * Access the solutions for a solved eigenvector problem, pair @@ -209,7 +213,7 @@ namespace SLEPcWrappers * \text{n\_converged}-1$. */ void - get_eigenpair (const unsigned int index, + get_eigenpair (const size_type index, #ifndef PETSC_USE_COMPLEX double &kr, #else @@ -637,9 +641,9 @@ namespace SLEPcWrappers SolverBase::solve (const PETScWrappers::MatrixBase &A, std::vector &kr, std::vector &vr, - const unsigned int n_eigenvectors = 1) + const size_type n_eigenvectors = 1) { - unsigned int n_converged = 0; + size_type n_converged = 0; // Set the matrices of the problem set_matrices (A); @@ -656,7 +660,7 @@ namespace SLEPcWrappers vr.resize (n_converged, vr.front()); kr.resize (n_converged); - for (unsigned int index=0; index &kr, std::vector &vr, - const unsigned int n_eigenvectors = 1) + const size_type n_eigenvectors = 1) { - unsigned int n_converged = 0; + size_type n_converged = 0; // Set the matrices of the problem set_matrices (A, B); @@ -686,7 +690,7 @@ namespace SLEPcWrappers vr.resize (n_converged, vr.front()); kr.resize (n_converged); - for (unsigned int index=0; index > class SolverCG : public Solver { public: + /** + * Declare type for container size. + */ + typedef types::global_dof_index size_type; + /** * Standardized data struct to pipe * additional data to the solver. @@ -403,7 +408,7 @@ SolverCG::solve (const MATRIX &A, if (additional_data.compute_all_condition_numbers && (diagonal.size()>1)) { TridiagonalMatrix T(diagonal.size(), true); - for (unsigned int i=0; i::solve (const MATRIX &A, if (do_eigenvalues) { TridiagonalMatrix T(diagonal.size(), true); - for (unsigned int i=0; i::solve (const MATRIX &A, T.eigenvalue(T.n()-1)/T.eigenvalue(0) << std::endl; if (additional_data.compute_eigenvalues) { - for (unsigned int i=0; istrengthen_diagonal's * value. */ - virtual number get_strengthen_diagonal(const number rowsum, const unsigned int row) const; + virtual number get_strengthen_diagonal(const number rowsum, const size_type row) const; /** * State flag. If not in @@ -421,7 +426,7 @@ protected: * available after invocation of * decompose(). */ - std::vector prebuilt_lower_bound; + std::vector prebuilt_lower_bound; private: /** @@ -460,7 +465,7 @@ template inline number SparseLUDecomposition:: get_strengthen_diagonal(const number /*rowsum*/, - const unsigned int /*row*/) const + const size_type /*row*/) const { return strengthen_diagonal; } diff --git a/deal.II/include/deal.II/lac/sparse_decomposition.templates.h b/deal.II/include/deal.II/lac/sparse_decomposition.templates.h index 3935ef107b..c5426eae00 100644 --- a/deal.II/include/deal.II/lac/sparse_decomposition.templates.h +++ b/deal.II/include/deal.II/lac/sparse_decomposition.templates.h @@ -54,7 +54,7 @@ void SparseLUDecomposition::clear() { decomposed = false; - std::vector tmp; + std::vector tmp; tmp.swap (prebuilt_lower_bound); SparseMatrix::clear(); @@ -129,7 +129,7 @@ void SparseLUDecomposition::initialize ( typename SparsityPattern::ExcDiagonalNotOptimized()); decomposed = false; { - std::vector tmp; + std::vector tmp; tmp.swap (prebuilt_lower_bound); } SparseMatrix::reinit (*sparsity_pattern_to_use); @@ -160,7 +160,7 @@ void SparseLUDecomposition::reinit (const SparsityPattern &sparsity) typename SparsityPattern::ExcDiagonalNotOptimized()); decomposed = false; { - std::vector tmp; + std::vector tmp; tmp.swap (prebuilt_lower_bound); } SparseMatrix::reinit (sparsity); @@ -172,15 +172,15 @@ template void SparseLUDecomposition::prebuild_lower_bound() { - const unsigned int *const + const size_type *const column_numbers = this->get_sparsity_pattern().colnums; const std::size_t *const rowstart_indices = this->get_sparsity_pattern().rowstart; - const unsigned int N = this->m(); + const size_type N = this->m(); prebuilt_lower_bound.resize (N); - for (unsigned int row=0; row::copy_from (const SparseMatrix &matrix SparseMatrix::operator= (number(0)); // both allow more and less entries in the new matrix - for (unsigned int row=0; rowm(); ++row) + for (size_type row=0; rowm(); ++row) { typename SparseMatrix::iterator index = this->begin(row); typename SparseMatrix::const_iterator @@ -240,7 +240,7 @@ template void SparseLUDecomposition::strengthen_diagonal_impl () { - for (unsigned int row=0; rowm(); ++row) + for (size_type row=0; rowm(); ++row) { // get the global index of the first // non-diagonal element in this row diff --git a/deal.II/include/deal.II/lac/sparse_direct.h b/deal.II/include/deal.II/lac/sparse_direct.h index d236fbd6c9..9c893d4638 100644 --- a/deal.II/include/deal.II/lac/sparse_direct.h +++ b/deal.II/include/deal.II/lac/sparse_direct.h @@ -191,6 +191,11 @@ DEAL_II_NAMESPACE_OPEN class SparseDirectMA27 : public Subscriptor { public: + /** + * Declare type for container size. + */ + typedef types::global_dof_index size_type; + /** * Constructor. See the * documentation of this class @@ -458,14 +463,14 @@ private: * the sparsity pattern on and * above the diagonal. */ - unsigned int n_nonzero_elements; + size_type n_nonzero_elements; /** * Arrays holding row and column * indices. */ - std::vector row_numbers; - std::vector column_numbers; + std::vector row_numbers; + std::vector column_numbers; /** * Array to hold the matrix @@ -477,7 +482,7 @@ private: /** * Length of the A array. */ - unsigned int LA; + size_type LA; /** * Scratch arrays and variables @@ -488,13 +493,13 @@ private: * letters as is usual in * Fortran. */ - unsigned int LIW; - std::vector IW; - std::vector IKEEP; - std::vector IW1; + size_type LIW; + std::vector IW; + std::vector IKEEP; + std::vector IW1; - unsigned int NSTEPS; - unsigned int MAXFRT; + size_type NSTEPS; + size_type MAXFRT; /** * Two values that live inside a @@ -506,8 +511,8 @@ private: * from the Fortran functions to * the outside world. */ - unsigned int NRLNEC; - unsigned int NIRNEC; + size_type NRLNEC; + size_type NIRNEC; /** * Flag indicating the level of @@ -536,71 +541,71 @@ private: * with the given args, either * locally or remote. */ - void call_ma27ad (const unsigned int *N, - const unsigned int *NZ, - const unsigned int *IRN, - const unsigned int *ICN, - unsigned int *IW, - const unsigned int *LIW, - unsigned int *IKEEP, - unsigned int *IW1, - unsigned int *NSTEPS, - int *IFLAG); + void call_ma27ad (const size_type *N, + const size_type *NZ, + const size_type *IRN, + const size_type *ICN, + size_type *IW, + const size_type *LIW, + size_type *IKEEP, + size_type *IW1, + size_type *NSTEPS, + int *IFLAG); /** * Call the respective function * with the given args, either * locally or remote. */ - void call_ma27bd (const unsigned int *N, - const unsigned int *NZ, - const unsigned int *IRN, - const unsigned int *ICN, - double *A, - const unsigned int *LA, - unsigned int *IW, - const unsigned int *LIW, - const unsigned int *IKEEP, - const unsigned int *NSTEPS, - unsigned int *MAXFRT, - unsigned int *IW1, - int *IFLAG); + void call_ma27bd (const size_type *N, + const size_type *NZ, + const size_type *IRN, + const size_type *ICN, + double *A, + const size_type *LA, + size_type *IW, + const size_type *LIW, + const size_type *IKEEP, + const size_type *NSTEPS, + size_type *MAXFRT, + size_type *IW1, + int *IFLAG); /** * Call the respective function * with the given args, either * locally or remote. */ - void call_ma27cd (const unsigned int *N, - const double *A, - const unsigned int *LA, - const unsigned int *IW, - const unsigned int *LIW, - const unsigned int *MAXFRT, - double *RHS, - const unsigned int *IW1, - const unsigned int *NSTEPS) const; + void call_ma27cd (const size_type *N, + const double *A, + const size_type *LA, + const size_type *IW, + const size_type *LIW, + const size_type *MAXFRT, + double *RHS, + const size_type *IW1, + const size_type *NSTEPS) const; /** * Call the respective function * with the given args, either * locally or remote. */ - void call_ma27x1 (unsigned int *NRLNEC); + void call_ma27x1 (size_type *NRLNEC); /** * Call the respective function * with the given args, either * locally or remote. */ - void call_ma27x2 (unsigned int *NIRNEC); + void call_ma27x2 (size_type *NIRNEC); /** * Call the respective function * with the given args, either * locally or remote. */ - void call_ma27x3 (const unsigned int *LP); + void call_ma27x3 (const size_type *LP); }; @@ -681,6 +686,11 @@ private: class SparseDirectMA47 : public Subscriptor { public: + /** + * Declare type for container size. + */ + typedef types::global_dof_index size_type; + /** * Constructor. See the * documentation of this class @@ -896,13 +906,13 @@ private: * the sparsity pattern on and * above the diagonal. */ - unsigned int n_nonzero_elements; + size_type n_nonzero_elements; /** * Control values set by MA47ID. */ - double CNTL[2]; - unsigned int ICNTL[7]; + double CNTL[2]; + size_type ICNTL[7]; /** * Info field filled by the MA47 @@ -915,8 +925,8 @@ private: * Arrays holding row and column * indices. */ - std::vector row_numbers; - std::vector column_numbers; + std::vector row_numbers; + std::vector column_numbers; /** * Array to hold the matrix @@ -928,7 +938,7 @@ private: /** * Length of the A array. */ - unsigned int LA; + size_type LA; /** * Scratch arrays and variables @@ -939,10 +949,10 @@ private: * letters as is usual in * Fortran. */ - unsigned int LIW; - std::vector IW; - std::vector KEEP; - std::vector IW1; + size_type LIW; + std::vector IW; + std::vector KEEP; + std::vector IW1; /** * Mutex for synchronising access @@ -961,52 +971,52 @@ private: * Call the ma47id function * with the given args. */ - void call_ma47id (double *CNTL, - unsigned int *ICNTL); + void call_ma47id (double *CNTL, + size_type *ICNTL); /** * Call the ma47ad function * with the given args. */ - void call_ma47ad (const unsigned int *n_rows, - const unsigned int *n_nonzero_elements, - unsigned int *row_numbers, - unsigned int *column_numbers, - unsigned int *IW, - const unsigned int *LIW, - unsigned int *KEEP, - const unsigned int *ICNTL, - int *INFO); + void call_ma47ad (const size_type *n_rows, + const size_type *n_nonzero_elements, + size_type *row_numbers, + size_type *column_numbers, + size_type *IW, + const size_type *LIW, + size_type *KEEP, + const size_type *ICNTL, + int *INFO); /** * Call the ma47bd function * with the given args. */ - void call_ma47bd (const unsigned int *n_rows, - const unsigned int *n_nonzero_elements, - const unsigned int *column_numbers, - double *A, - const unsigned int *LA, - unsigned int *IW, - const unsigned int *LIW, - const unsigned int *KEEP, - const double *CNTL, - const unsigned int *ICNTL, - unsigned int *IW1, - int *INFO); + void call_ma47bd (const size_type *n_rows, + const size_type *n_nonzero_elements, + const size_type *column_numbers, + double *A, + const size_type *LA, + size_type *IW, + const size_type *LIW, + const size_type *KEEP, + const double *CNTL, + const size_type *ICNTL, + size_type *IW1, + int *INFO); /** * Call the ma47bd function * with the given args. */ - void call_ma47cd (const unsigned int *n_rows, - const double *A, - const unsigned int *LA, - const unsigned int *IW, - const unsigned int *LIW, - double *rhs_and_solution, - unsigned int *IW1, - const unsigned int *ICNTL); + void call_ma47cd (const size_type *n_rows, + const double *A, + const size_type *LA, + const size_type *IW, + const size_type *LIW, + double *rhs_and_solution, + size_type *IW1, + const size_type *ICNTL); }; @@ -1304,12 +1314,12 @@ private: DMUMPS_STRUC_C id; #endif // DEAL_II_USE_MUMPS - double *a; - double *rhs; - int *irn; - int *jcn; - unsigned int n; - unsigned int nz; + double *a; + double *rhs; + int *irn; + int *jcn; + types::global_dof_index n; + types::global_dof_index nz; /** * This function initializes a MUMPS instance @@ -1333,6 +1343,10 @@ private: bool initialize_called; public: + /** + * Declare type for container size. + */ + typedef types::global_dof_index size_type; /** * Constructor diff --git a/deal.II/include/deal.II/lac/sparse_ilu.h b/deal.II/include/deal.II/lac/sparse_ilu.h index ba745ccbbf..3465cd7665 100644 --- a/deal.II/include/deal.II/lac/sparse_ilu.h +++ b/deal.II/include/deal.II/lac/sparse_ilu.h @@ -53,6 +53,11 @@ template class SparseILU : public SparseLUDecomposition { public: + /** + * Declare type for container size. + */ + typedef types::global_dof_index size_type; + /** * Constructor. Does nothing. * diff --git a/deal.II/include/deal.II/lac/sparse_ilu.templates.h b/deal.II/include/deal.II/lac/sparse_ilu.templates.h index c695e9face..4080ceafc9 100644 --- a/deal.II/include/deal.II/lac/sparse_ilu.templates.h +++ b/deal.II/include/deal.II/lac/sparse_ilu.templates.h @@ -71,29 +71,29 @@ void SparseILU::decompose (const SparseMatrix &matrix, // translating in essence the algorithm given at the end of section 10.3.2, // using the names of variables used there const SparsityPattern &sparsity = this->get_sparsity_pattern(); - const std::size_t *const ia = sparsity.rowstart; - const unsigned int *const ja = sparsity.colnums; + const std::size_t *const ia = sparsity.rowstart; + const size_type *const ja = sparsity.colnums; number *luval = this->SparseMatrix::val; - const unsigned int N = this->m(); - unsigned int jrow = 0; + const size_type N = this->m(); + size_type jrow = 0; - std::vector iw (N, numbers::invalid_unsigned_int); + std::vector iw (N, numbers::invalid_unsigned_int); - for (unsigned int k=0; k::vmult (Vector &dst, Assert (dst.size() == src.size(), ExcDimensionMismatch(dst.size(), src.size())); Assert (dst.size() == this->m(), ExcDimensionMismatch(dst.size(), this->m())); - const unsigned int N=dst.size(); - const std::size_t *const rowstart_indices + const size_type N=dst.size(); + const std::size_t *const rowstart_indices = this->get_sparsity_pattern().rowstart; - const unsigned int *const column_numbers + const size_type *const column_numbers = this->get_sparsity_pattern().colnums; // solve LUx=b in two steps: @@ -177,19 +177,19 @@ void SparseILU::vmult (Vector &dst, // perform it at the outset of the // loop dst = src; - for (unsigned int row=0; rowprebuilt_lower_bound[row]; + const size_type *const first_after_diagonal = this->prebuilt_lower_bound[row]; somenumber dst_row = dst(row); const number *luval = this->SparseMatrix::val + (rowstart - column_numbers); - for (const unsigned int *col=rowstart; col!=first_after_diagonal; ++col, ++luval) + for (const size_type *col=rowstart; col!=first_after_diagonal; ++col, ++luval) dst_row -= *luval * dst(*col); dst(row) = dst_row; } @@ -205,15 +205,15 @@ void SparseILU::vmult (Vector &dst, for (int row=N-1; row>=0; --row) { // get end of this row - const unsigned int *const rowend = &column_numbers[rowstart_indices[row+1]]; + const size_type *const rowend = &column_numbers[rowstart_indices[row+1]]; // find the position where the part // right of the diagonal starts - const unsigned int *const first_after_diagonal = this->prebuilt_lower_bound[row]; + const size_type *const first_after_diagonal = this->prebuilt_lower_bound[row]; somenumber dst_row = dst(row); const number *luval = this->SparseMatrix::val + (first_after_diagonal - column_numbers); - for (const unsigned int *col=first_after_diagonal; col!=rowend; ++col, ++luval) + for (const size_type *col=first_after_diagonal; col!=rowend; ++col, ++luval) dst_row -= *luval * dst(*col); // scale by the diagonal element. @@ -232,10 +232,10 @@ void SparseILU::Tvmult (Vector &dst, Assert (dst.size() == src.size(), ExcDimensionMismatch(dst.size(), src.size())); Assert (dst.size() == this->m(), ExcDimensionMismatch(dst.size(), this->m())); - const unsigned int N=dst.size(); - const std::size_t *const rowstart_indices + const size_type N=dst.size(); + const std::size_t *const rowstart_indices = this->get_sparsity_pattern().rowstart; - const unsigned int *const column_numbers + const size_type *const column_numbers = this->get_sparsity_pattern().colnums; // solve (LU)'x=b in two steps: @@ -249,7 +249,7 @@ void SparseILU::Tvmult (Vector &dst, Vector tmp (N); dst = src; - for (unsigned int row=0; row::Tvmult (Vector &dst, dst(row) *= this->diag_element(row); // get end of this row - const unsigned int *const rowend = &column_numbers[rowstart_indices[row+1]]; + const size_type *const rowend = &column_numbers[rowstart_indices[row+1]]; // find the position where the part // right of the diagonal starts - const unsigned int *const first_after_diagonal = this->prebuilt_lower_bound[row]; + const size_type *const first_after_diagonal = this->prebuilt_lower_bound[row]; const somenumber dst_row = dst (row); const number *luval = this->SparseMatrix::val + (first_after_diagonal - column_numbers); - for (const unsigned int *col=first_after_diagonal; col!=rowend; ++col, ++luval) + for (const size_type *col=first_after_diagonal; col!=rowend; ++col, ++luval) tmp(*col) += *luval * dst_row; } @@ -285,15 +285,15 @@ void SparseILU::Tvmult (Vector &dst, // get start of this row. skip the // diagonal element - const unsigned int *const rowstart = &column_numbers[rowstart_indices[row]+1]; + const size_type *const rowstart = &column_numbers[rowstart_indices[row]+1]; // find the position where the part // right of the diagonal starts - const unsigned int *const first_after_diagonal = this->prebuilt_lower_bound[row]; + const size_type *const first_after_diagonal = this->prebuilt_lower_bound[row]; const somenumber dst_row = dst (row); const number *luval = this->SparseMatrix::val + (rowstart - column_numbers); - for (const unsigned int *col=rowstart; col!=first_after_diagonal; ++col, ++luval) + for (const size_type *col=rowstart; col!=first_after_diagonal; ++col, ++luval) tmp(*col) += *luval * dst_row; } } diff --git a/deal.II/include/deal.II/lac/sparse_matrix.h b/deal.II/include/deal.II/lac/sparse_matrix.h index 41b672c7b1..e23294bda0 100644 --- a/deal.II/include/deal.II/lac/sparse_matrix.h +++ b/deal.II/include/deal.II/lac/sparse_matrix.h @@ -38,6 +38,11 @@ template class SparseILU; */ namespace SparseMatrixIterators { + /** + * Declare type for container size. + */ + typedef types::global_dof_index size_type; + // forward declaration template class Iterator; @@ -97,9 +102,9 @@ namespace SparseMatrixIterators * @deprecated This constructor is deprecated. Use the other constructor * with a global index instead. */ - Accessor (MatrixType *matrix, - const unsigned int row, - const unsigned int index) DEAL_II_DEPRECATED; + Accessor (MatrixType *matrix, + const size_type row, + const size_type index) DEAL_II_DEPRECATED; /** * Constructor. @@ -239,9 +244,9 @@ namespace SparseMatrixIterators /** * Constructor. */ - Accessor (MatrixType *matrix, - const unsigned int row, - const unsigned int index); + Accessor (MatrixType *matrix, + const size_type row, + const size_type index); /** * Constructor. @@ -345,9 +350,9 @@ namespace SparseMatrixIterators * @deprecated This constructor is deprecated. Use the other constructor * with a global index instead. */ - Iterator (MatrixType *matrix, - const unsigned int row, - const unsigned int index) DEAL_II_DEPRECATED; + Iterator (MatrixType *matrix, + const size_type row, + const size_type index) DEAL_II_DEPRECATED; /** * Constructor. Create an iterator into the matrix @p matrix for the given @@ -423,7 +428,7 @@ namespace SparseMatrixIterators /** * Return an iterator that is @p n ahead of the current one. */ - Iterator operator + (const unsigned int n) const; + Iterator operator + (const size_type n) const; private: /** @@ -469,6 +474,11 @@ template class SparseMatrix : public virtual Subscriptor { public: + /** + * Declare type for container size. + */ + typedef types::global_dof_index size_type; + /** * Type of matrix entries. In analogy to the STL container classes. */ @@ -642,25 +652,25 @@ public: * Return the dimension of the image space. To remember: the matrix is of * dimension $m \times n$. */ - unsigned int m () const; + size_type m () const; /** * Return the dimension of the range space. To remember: the matrix is of * dimension $m \times n$. */ - unsigned int n () const; + size_type n () const; /** * Return the number of entries in a specific row. */ - unsigned int get_row_length (const unsigned int row) const; + size_type get_row_length (const size_type row) const; /** * Return the number of nonzero elements of this matrix. Actually, it * returns the number of entries in the sparsity pattern; if any of the * entries should happen to be zero, it is counted anyway. */ - unsigned int n_nonzero_elements () const; + size_type n_nonzero_elements () const; /** * Return the number of actually nonzero elements of this matrix. It is @@ -671,7 +681,7 @@ public: * count all entries of the sparsity pattern but only the ones that are * nonzero (or whose absolute value is greater than threshold). */ - unsigned int n_actually_nonzero_elements (const double threshold = 0.) const; + size_type n_actually_nonzero_elements (const double threshold = 0.) const; /** * Return a (constant) reference to the underlying sparsity pattern of this @@ -699,8 +709,8 @@ public: * entry does not exist or if value is not a finite number. Still, * it is allowed to store zero values in non-existent fields. */ - void set (const unsigned int i, - const unsigned int j, + void set (const size_type i, + const size_type j, const number value); /** @@ -719,7 +729,7 @@ public: * treated. */ template - void set (const std::vector &indices, + void set (const std::vector &indices, const FullMatrix &full_matrix, const bool elide_zero_values = false); @@ -729,10 +739,10 @@ public: * and columns, respectively. */ template - void set (const std::vector &row_indices, - const std::vector &col_indices, - const FullMatrix &full_matrix, - const bool elide_zero_values = false); + void set (const std::vector &row_indices, + const std::vector &col_indices, + const FullMatrix &full_matrix, + const bool elide_zero_values = false); /** * Set several elements in the specified row of the matrix with column @@ -745,10 +755,10 @@ public: * treated. */ template - void set (const unsigned int row, - const std::vector &col_indices, - const std::vector &values, - const bool elide_zero_values = false); + void set (const size_type row, + const std::vector &col_indices, + const std::vector &values, + const bool elide_zero_values = false); /** * Set several elements to values given by values in a given row in @@ -760,19 +770,19 @@ public: * inserted/replaced. */ template - void set (const unsigned int row, - const unsigned int n_cols, - const unsigned int *col_indices, - const number2 *values, - const bool elide_zero_values = false); + void set (const size_type row, + const size_type n_cols, + const size_type *col_indices, + const number2 *values, + const bool elide_zero_values = false); /** * Add value to the element (i,j). Throws an error if the * entry does not exist or if value is not a finite number. Still, * it is allowed to store zero values in non-existent fields. */ - void add (const unsigned int i, - const unsigned int j, + void add (const size_type i, + const size_type j, const number value); /** @@ -790,9 +800,9 @@ public: * i.e., zero values won't be added into the matrix. */ template - void add (const std::vector &indices, - const FullMatrix &full_matrix, - const bool elide_zero_values = true); + void add (const std::vector &indices, + const FullMatrix &full_matrix, + const bool elide_zero_values = true); /** * Same function as before, but now including the possibility to use @@ -800,10 +810,10 @@ public: * and columns, respectively. */ template - void add (const std::vector &row_indices, - const std::vector &col_indices, - const FullMatrix &full_matrix, - const bool elide_zero_values = true); + void add (const std::vector &row_indices, + const std::vector &col_indices, + const FullMatrix &full_matrix, + const bool elide_zero_values = true); /** * Set several elements in the specified row of the matrix with column @@ -815,10 +825,10 @@ public: * i.e., zero values won't be added into the matrix. */ template - void add (const unsigned int row, - const std::vector &col_indices, - const std::vector &values, - const bool elide_zero_values = true); + void add (const size_type row, + const std::vector &col_indices, + const std::vector &values, + const bool elide_zero_values = true); /** * Add an array of values given by values in the given global @@ -830,12 +840,12 @@ public: * i.e., zero values won't be added into the matrix. */ template - void add (const unsigned int row, - const unsigned int n_cols, - const unsigned int *col_indices, - const number2 *values, - const bool elide_zero_values = true, - const bool col_indices_are_sorted = false); + void add (const size_type row, + const size_type n_cols, + const size_type *col_indices, + const number2 *values, + const bool elide_zero_values = true, + const bool col_indices_are_sorted = false); /** * Multiply the entire matrix by a fixed factor. @@ -940,8 +950,8 @@ public: * classes instead, since they are tailored better to a sparse matrix * structure. */ - number operator () (const unsigned int i, - const unsigned int j) const; + number operator () (const size_type i, + const size_type j) const; /** * This function is mostly like operator()() in that it returns the value of @@ -955,8 +965,8 @@ public: * classes instead, since they are tailored better to a sparse matrix * structure. */ - number el (const unsigned int i, - const unsigned int j) const; + number el (const size_type i, + const size_type j) const; /** * Return the main diagonal element in the ith row. This function @@ -968,13 +978,13 @@ public: * each row and access therefore does not involve searching for the right * column number. */ - number diag_element (const unsigned int i) const; + number diag_element (const size_type i) const; /** * Same as above, but return a writeable reference. You're sure you know * what you do? */ - number &diag_element (const unsigned int i); + number &diag_element (const size_type i); /** * Access to values in internal mode. Returns the value of the @@ -984,8 +994,8 @@ public: * * @deprecated Use iterator or const_iterator instead! */ - number raw_entry (const unsigned int row, - const unsigned int index) const DEAL_II_DEPRECATED; + number raw_entry (const size_type row, + const size_type index) const DEAL_II_DEPRECATED; /** * This is for hackers. Get access to the ith element of this @@ -1000,14 +1010,14 @@ public: * * @internal @deprecated Use iterator or const_iterator instead! */ - number global_entry (const unsigned int i) const DEAL_II_DEPRECATED; + number global_entry (const size_type i) const DEAL_II_DEPRECATED; /** * Same as above, but with write access. You certainly know what you do? * * @internal @deprecated Use iterator or const_iterator instead! */ - number &global_entry (const unsigned int i) DEAL_II_DEPRECATED; + number &global_entry (const size_type i) DEAL_II_DEPRECATED; //@} /** @@ -1291,8 +1301,8 @@ public: */ template void PSOR (Vector &v, - const std::vector &permutation, - const std::vector &inverse_permutation, + const std::vector &permutation, + const std::vector &inverse_permutation, const number om = 1.) const; /** @@ -1307,8 +1317,8 @@ public: */ template void TPSOR (Vector &v, - const std::vector &permutation, - const std::vector &inverse_permutation, + const std::vector &permutation, + const std::vector &inverse_permutation, const number om = 1.) const; /** @@ -1393,7 +1403,7 @@ public: * Note also the discussion in the general documentation of this class about * the order in which elements are accessed. */ - const_iterator begin (const unsigned int r) const; + const_iterator begin (const size_type r) const; /** * Final iterator of row r. It points to the first element past the @@ -1404,7 +1414,7 @@ public: * particular the case if it is the end iterator for the last row of a * matrix. */ - const_iterator end (const unsigned int r) const; + const_iterator end (const size_type r) const; /** * STL-like iterator with the first entry of row r. This is the @@ -1418,7 +1428,7 @@ public: * Note the discussion in the general documentation of this class about * the order in which elements are accessed. */ - iterator begin (const unsigned int r); + iterator begin (const size_type r); /** * Final iterator of row r. It points to the first element past the @@ -1429,7 +1439,7 @@ public: * particular the case if it is the end iterator for the last row of a * matrix. */ - iterator end (const unsigned int r); + iterator end (const size_type r); //@} /** * @name Input/Output @@ -1615,7 +1625,7 @@ private: template inline -unsigned int SparseMatrix::m () const +typename SparseMatrix::size_type SparseMatrix::m () const { Assert (cols != 0, ExcNotInitialized()); return cols->rows; @@ -1624,7 +1634,7 @@ unsigned int SparseMatrix::m () const template inline -unsigned int SparseMatrix::n () const +typename SparseMatrix::size_type SparseMatrix::n () const { Assert (cols != 0, ExcNotInitialized()); return cols->cols; @@ -1635,13 +1645,13 @@ unsigned int SparseMatrix::n () const template inline void -SparseMatrix::set (const unsigned int i, - const unsigned int j, +SparseMatrix::set (const size_type i, + const size_type j, const number value) { Assert (numbers::is_finite(value), ExcNumberNotFinite()); - const unsigned int index = cols->operator()(i, j); + const size_type index = cols->operator()(i, j); // it is allowed to set elements of the matrix that are not part of the // sparsity pattern, if the value to which we set it is zero @@ -1662,15 +1672,15 @@ template template inline void -SparseMatrix::set (const std::vector &indices, - const FullMatrix &values, - const bool elide_zero_values) +SparseMatrix::set (const std::vector &indices, + const FullMatrix &values, + const bool elide_zero_values) { Assert (indices.size() == values.m(), ExcDimensionMismatch(indices.size(), values.m())); Assert (values.m() == values.n(), ExcNotQuadratic()); - for (unsigned int i=0; i template inline void -SparseMatrix::set (const std::vector &row_indices, - const std::vector &col_indices, - const FullMatrix &values, - const bool elide_zero_values) +SparseMatrix::set (const std::vector &row_indices, + const std::vector &col_indices, + const FullMatrix &values, + const bool elide_zero_values) { Assert (row_indices.size() == values.m(), ExcDimensionMismatch(row_indices.size(), values.m())); Assert (col_indices.size() == values.n(), ExcDimensionMismatch(col_indices.size(), values.n())); - for (unsigned int i=0; i template inline void -SparseMatrix::set (const unsigned int row, - const std::vector &col_indices, - const std::vector &values, - const bool elide_zero_values) +SparseMatrix::set (const size_type row, + const std::vector &col_indices, + const std::vector &values, + const bool elide_zero_values) { Assert (col_indices.size() == values.size(), ExcDimensionMismatch(col_indices.size(), values.size())); @@ -1719,16 +1729,16 @@ SparseMatrix::set (const unsigned int row, template inline void -SparseMatrix::add (const unsigned int i, - const unsigned int j, - const number value) +SparseMatrix::add (const size_type i, + const size_type j, + const number value) { Assert (numbers::is_finite(value), ExcNumberNotFinite()); if (value == 0) return; - const unsigned int index = cols->operator()(i, j); + const size_type index = cols->operator()(i, j); // it is allowed to add elements to the matrix that are not part of the // sparsity pattern, if the value to which we set it is zero @@ -1749,15 +1759,15 @@ template template inline void -SparseMatrix::add (const std::vector &indices, - const FullMatrix &values, - const bool elide_zero_values) +SparseMatrix::add (const std::vector &indices, + const FullMatrix &values, + const bool elide_zero_values) { Assert (indices.size() == values.m(), ExcDimensionMismatch(indices.size(), values.m())); Assert (values.m() == values.n(), ExcNotQuadratic()); - for (unsigned int i=0; i template inline void -SparseMatrix::add (const std::vector &row_indices, - const std::vector &col_indices, - const FullMatrix &values, - const bool elide_zero_values) +SparseMatrix::add (const std::vector &row_indices, + const std::vector &col_indices, + const FullMatrix &values, + const bool elide_zero_values) { Assert (row_indices.size() == values.m(), ExcDimensionMismatch(row_indices.size(), values.m())); Assert (col_indices.size() == values.n(), ExcDimensionMismatch(col_indices.size(), values.n())); - for (unsigned int i=0; i template inline void -SparseMatrix::add (const unsigned int row, - const std::vector &col_indices, - const std::vector &values, - const bool elide_zero_values) +SparseMatrix::add (const size_type row, + const std::vector &col_indices, + const std::vector &values, + const bool elide_zero_values) { Assert (col_indices.size() == values.size(), ExcDimensionMismatch(col_indices.size(), values.size())); @@ -1846,8 +1856,8 @@ SparseMatrix::operator /= (const number factor) template inline -number SparseMatrix::operator () (const unsigned int i, - const unsigned int j) const +number SparseMatrix::operator () (const size_type i, + const size_type j) const { Assert (cols != 0, ExcNotInitialized()); Assert (cols->operator()(i,j) != SparsityPattern::invalid_entry, @@ -1859,11 +1869,11 @@ number SparseMatrix::operator () (const unsigned int i, template inline -number SparseMatrix::el (const unsigned int i, - const unsigned int j) const +number SparseMatrix::el (const size_type i, + const size_type j) const { Assert (cols != 0, ExcNotInitialized()); - const unsigned int index = cols->operator()(i,j); + const size_type index = cols->operator()(i,j); if (index != SparsityPattern::invalid_entry) return val[index]; @@ -1875,7 +1885,7 @@ number SparseMatrix::el (const unsigned int i, template inline -number SparseMatrix::diag_element (const unsigned int i) const +number SparseMatrix::diag_element (const size_type i) const { Assert (cols != 0, ExcNotInitialized()); Assert (m() == n(), ExcNotQuadratic()); @@ -1890,7 +1900,7 @@ number SparseMatrix::diag_element (const unsigned int i) const template inline -number &SparseMatrix::diag_element (const unsigned int i) +number &SparseMatrix::diag_element (const size_type i) { Assert (cols != 0, ExcNotInitialized()); Assert (m() == n(), ExcNotQuadratic()); @@ -1906,8 +1916,8 @@ number &SparseMatrix::diag_element (const unsigned int i) template inline number -SparseMatrix::raw_entry (const unsigned int row, - const unsigned int index) const +SparseMatrix::raw_entry (const size_type row, + const size_type index) const { Assert(rowrows, ExcIndexRange(row,0,cols->rows)); Assert(indexrow_length(row), @@ -1921,7 +1931,7 @@ SparseMatrix::raw_entry (const unsigned int row, template inline -number SparseMatrix::global_entry (const unsigned int j) const +number SparseMatrix::global_entry (const size_type j) const { Assert (cols != 0, ExcNotInitialized()); Assert (j < cols->n_nonzero_elements(), @@ -1934,7 +1944,7 @@ number SparseMatrix::global_entry (const unsigned int j) const template inline -number &SparseMatrix::global_entry (const unsigned int j) +number &SparseMatrix::global_entry (const size_type j) { Assert (cols != 0, ExcNotInitialized()); Assert (j < cols->n_nonzero_elements(), @@ -1951,13 +1961,13 @@ void SparseMatrix::copy_from (const ForwardIterator begin, const ForwardIterator end) { - Assert (static_cast(std::distance (begin, end)) == m(), + Assert (static_cast(std::distance (begin, end)) == m(), ExcIteratorRange (std::distance (begin, end), m())); // for use in the inner loop, we define a typedef to the type of the inner // iterators typedef typename std::iterator_traits::value_type::const_iterator inner_iterator; - unsigned int row=0; + size_type row=0; for (ForwardIterator i=begin; i!=end; ++i, ++row) { const inner_iterator end_of_row = i->end(); @@ -1976,9 +1986,9 @@ namespace SparseMatrixIterators template inline Accessor:: - Accessor (const MatrixType *matrix, - const unsigned int row, - const unsigned int index) + Accessor (const MatrixType *matrix, + const size_type row, + const size_type index) : SparsityPatternIterators::Accessor (&matrix->get_sparsity_pattern(), row, index), @@ -2126,9 +2136,9 @@ namespace SparseMatrixIterators template inline Accessor:: - Accessor (MatrixType *matrix, - const unsigned int row, - const unsigned int index) + Accessor (MatrixType *matrix, + const size_type row, + const size_type index) : SparsityPatternIterators::Accessor (&matrix->get_sparsity_pattern(), row, index), @@ -2185,9 +2195,9 @@ namespace SparseMatrixIterators template inline Iterator:: - Iterator (MatrixType *matrix, - const unsigned int r, - const unsigned int i) + Iterator (MatrixType *matrix, + const size_type r, + const size_type i) : accessor(matrix, r, i) {} @@ -2325,10 +2335,10 @@ namespace SparseMatrixIterators inline Iterator Iterator:: - operator + (const unsigned int n) const + operator + (const size_type n) const { Iterator x = *this; - for (unsigned int i=0; i::end () template inline typename SparseMatrix::const_iterator -SparseMatrix::begin (const unsigned int r) const +SparseMatrix::begin (const size_type r) const { Assert (r::begin (const unsigned int r) const template inline typename SparseMatrix::const_iterator -SparseMatrix::end (const unsigned int r) const +SparseMatrix::end (const size_type r) const { Assert (r::end (const unsigned int r) const template inline typename SparseMatrix::iterator -SparseMatrix::begin (const unsigned int r) +SparseMatrix::begin (const size_type r) { Assert (r::begin (const unsigned int r) template inline typename SparseMatrix::iterator -SparseMatrix::end (const unsigned int r) +SparseMatrix::end (const size_type r) { Assert (r::print (STREAM &out, bool across) const if (across) { - for (unsigned int i=0; irows; ++i) - for (unsigned int j=cols->rowstart[i]; jrowstart[i+1]; ++j) + for (size_type i=0; irows; ++i) + for (size_type j=cols->rowstart[i]; jrowstart[i+1]; ++j) out << ' ' << i << ',' << cols->colnums[j] << ':' << val[j]; out << std::endl; } else - for (unsigned int i=0; irows; ++i) - for (unsigned int j=cols->rowstart[i]; jrowstart[i+1]; ++j) + for (size_type i=0; irows; ++i) + for (size_type j=cols->rowstart[i]; jrowstart[i+1]; ++j) out << "(" << i << "," << cols->colnums[j] << ") " << val[j] << std::endl; } diff --git a/deal.II/include/deal.II/lac/sparse_matrix.templates.h b/deal.II/include/deal.II/lac/sparse_matrix.templates.h index 30f7c18a67..c049fdb823 100644 --- a/deal.II/include/deal.II/lac/sparse_matrix.templates.h +++ b/deal.II/include/deal.II/lac/sparse_matrix.templates.h @@ -102,7 +102,7 @@ SparseMatrix::SparseMatrix (const SparsityPattern &c, Assert (c.n_cols() == id.n(), ExcDimensionMismatch (c.n_cols(), id.n())); reinit (c); - for (unsigned int i=0; iset(i,i,1.); } @@ -123,9 +123,11 @@ namespace internal { namespace SparseMatrix { + typedef types::global_dof_index size_type; + template - void zero_subrange (const unsigned int begin, - const unsigned int end, + void zero_subrange (const size_type begin, + const size_type end, T *dst) { std::memset (dst+begin,0,(end-begin)*sizeof(T)); @@ -151,8 +153,8 @@ SparseMatrix::operator = (const double d) // operator=. The grain size is chosen to reflect the number of rows in // minimum_parallel_grain_size, weighted by the number of nonzero entries // per row on average. - const unsigned int matrix_size = cols->n_nonzero_elements(); - const unsigned int grain_size = + const size_type matrix_size = cols->n_nonzero_elements(); + const size_type grain_size = internal::SparseMatrix::minimum_parallel_grain_size * (cols->n_nonzero_elements()+m()) / m(); if (matrix_size>grain_size) @@ -180,7 +182,7 @@ SparseMatrix::operator= (const IdentityMatrix &id) ExcDimensionMismatch (cols->n_cols(), id.n())); *this = 0; - for (unsigned int i=0; iset(i,i,1.); return *this; @@ -242,8 +244,8 @@ SparseMatrix::empty () const template -unsigned int -SparseMatrix::get_row_length (const unsigned int row) const +typename SparseMatrix::size_type +SparseMatrix::get_row_length (const size_type row) const { Assert (cols != 0, ExcNotInitialized()); return cols->row_length(row); @@ -252,7 +254,7 @@ SparseMatrix::get_row_length (const unsigned int row) const template -unsigned int +typename SparseMatrix::size_type SparseMatrix::n_nonzero_elements () const { Assert (cols != 0, ExcNotInitialized()); @@ -262,14 +264,14 @@ SparseMatrix::n_nonzero_elements () const template -unsigned int +typename SparseMatrix::size_type SparseMatrix::n_actually_nonzero_elements (const double threshold) const { Assert (cols != 0, ExcNotInitialized()); Assert (threshold >= 0, ExcMessage ("Negative threshold!")); - unsigned int nnz = 0; - const unsigned int nnz_alloc = n_nonzero_elements(); - for (unsigned int i=0; i threshold) ++nnz; return nnz; @@ -284,15 +286,15 @@ SparseMatrix::symmetrize () Assert (cols != 0, ExcNotInitialized()); Assert (cols->rows == cols->cols, ExcNotQuadratic()); - const unsigned int n_rows = m(); - for (unsigned int row=0; rowrowstart[row]]; if (m() == n()) ++val_ptr; - const unsigned int *colnum_ptr = &cols->colnums[cols->rowstart[row]+1]; - const number *const val_end_of_row = &val[cols->rowstart[row+1]]; + const size_type *colnum_ptr = &cols->colnums[cols->rowstart[row]+1]; + const number *const val_end_of_row = &val[cols->rowstart[row+1]]; // treat lower left triangle while ((val_ptr != val_end_of_row) && (*colnum_ptr::copy_from (const FullMatrix &matrix) *this = 0; // then copy old matrix - for (unsigned int row=0; row - void vmult_on_subrange (const unsigned int begin_row, - const unsigned int end_row, - const number *values, + void vmult_on_subrange (const size_type begin_row, + const size_type end_row, + const number *values, const std::size_t *rowstart, - const unsigned int *colnums, - const InVector &src, - OutVector &dst, - const bool add) + const size_type *colnums, + const InVector &src, + OutVector &dst, + const bool add) { - const number *val_ptr = &values[rowstart[begin_row]]; - const unsigned int *colnum_ptr = &colnums[rowstart[begin_row]]; + const number *val_ptr = &values[rowstart[begin_row]]; + const size_type *colnum_ptr = &colnums[rowstart[begin_row]]; typename OutVector::iterator dst_ptr = dst.begin() + begin_row; if (add == false) - for (unsigned int row=begin_row; row template void -SparseMatrix::add (const unsigned int row, - const unsigned int n_cols, - const unsigned int *col_indices, - const number2 *values, - const bool elide_zero_values, - const bool col_indices_are_sorted) +SparseMatrix::add (const size_type row, + const size_type n_cols, + const size_type *col_indices, + const number2 *values, + const bool elide_zero_values, + const bool col_indices_are_sorted) { Assert (cols != 0, ExcNotInitialized()); @@ -444,14 +446,14 @@ SparseMatrix::add (const unsigned int row, // check whether the given indices are // really sorted #ifdef DEBUG - for (unsigned int i=1; i col_indices[i-1], ExcMessage("List of indices is unsorted or contains duplicates.")); #endif - const unsigned int *this_cols = + const size_type *this_cols = &cols->colnums[cols->rowstart[row]]; - const unsigned int row_length_1 = cols->row_length(row)-1; + const size_type row_length_1 = cols->row_length(row)-1; number *val_ptr = &val[cols->rowstart[row]]; if (m() == n()) @@ -459,12 +461,12 @@ SparseMatrix::add (const unsigned int row, // find diagonal and add it if found Assert (this_cols[0] == row, ExcInternalError()); - const unsigned int *diag_pos = + const size_type *diag_pos = Utilities::lower_bound (col_indices, col_indices+n_cols, row); - const unsigned int diag = diag_pos - col_indices; - unsigned int post_diag = diag; + const size_type diag = diag_pos - col_indices; + size_type post_diag = diag; if (diag != n_cols && *diag_pos == row) { val_ptr[0] += *(values+(diag_pos-col_indices)); @@ -472,8 +474,8 @@ SparseMatrix::add (const unsigned int row, } // add indices before diagonal - unsigned int counter = 1; - for (unsigned int i=0; i::add (const unsigned int row, } // add indices after diagonal - for (unsigned int i=post_diag; i::add (const unsigned int row, } else { - unsigned int counter = 0; - for (unsigned int i=0; i::add (const unsigned int row, // unsorted case: first, search all the // indices to find out which values we // actually need to add. - const unsigned int *const my_cols = cols->colnums; - unsigned int index = cols->rowstart[row]; - const unsigned int next_row_index = cols->rowstart[row+1]; + const size_type *const my_cols = cols->colnums; + size_type index = cols->rowstart[row]; + const size_type next_row_index = cols->rowstart[row+1]; - for (unsigned int j=0; j template void -SparseMatrix::set (const unsigned int row, - const unsigned int n_cols, - const unsigned int *col_indices, - const number2 *values, - const bool elide_zero_values) +SparseMatrix::set (const size_type row, + const size_type n_cols, + const size_type *col_indices, + const number2 *values, + const bool elide_zero_values) { Assert (cols != 0, ExcNotInitialized()); Assert (row < m(), ExcInvalidIndex1(row)); @@ -580,13 +582,13 @@ SparseMatrix::set (const unsigned int row, // First, search all the indices to find // out which values we actually need to // set. - const unsigned int *my_cols = cols->colnums; + const size_type *my_cols = cols->colnums; std::size_t index = cols->rowstart[row], next_index = index; const std::size_t next_row_index = cols->rowstart[row+1]; if (elide_zero_values == true) { - for (unsigned int j=0; j::Tvmult (OutVector &dst, dst = 0; - for (unsigned int i=0; irowstart[i]; jrowstart[i+1] ; j++) + for (size_type j=cols->rowstart[i]; jrowstart[i+1] ; j++) { - const unsigned int p = cols->colnums[j]; + const size_type p = cols->colnums[j]; dst(p) += val[j] * src(i); } } @@ -744,10 +746,10 @@ SparseMatrix::Tvmult_add (OutVector &dst, Assert (!PointerComparison::equal(&src, &dst), ExcSourceEqualsDestination()); - for (unsigned int i=0; irowstart[i]; jrowstart[i+1] ; j++) + for (size_type i=0; irowstart[i]; jrowstart[i+1] ; j++) { - const unsigned int p = cols->colnums[j]; + const size_type p = cols->colnums[j]; dst(p) += val[j] * src(i); } } @@ -770,19 +772,19 @@ namespace internal */ template - number matrix_norm_sqr_on_subrange (const unsigned int begin_row, - const unsigned int end_row, - const number *values, + number matrix_norm_sqr_on_subrange (const size_type begin_row, + const size_type end_row, + const number *values, const std::size_t *rowstart, - const unsigned int *colnums, - const InVector &v) + const size_type *colnums, + const InVector &v) { number norm_sqr=0.; - for (unsigned int i=begin_row; i::conjugate(s); } @@ -833,20 +835,20 @@ namespace internal */ template - number matrix_scalar_product_on_subrange (const unsigned int begin_row, - const unsigned int end_row, - const number *values, + number matrix_scalar_product_on_subrange (const size_type begin_row, + const size_type end_row, + const number *values, const std::size_t *rowstart, - const unsigned int *colnums, - const InVector &u, - const InVector &v) + const size_type *colnums, + const InVector &u, + const InVector &v) { number norm_sqr=0.; - for (unsigned int i=begin_row; i::conjugate(s); } @@ -924,17 +926,17 @@ SparseMatrix::mmult (SparseMatrix &C, // CompressedSimpleSparsityPattern class. { CompressedSimpleSparsityPattern csp (m(), B.n()); - for (unsigned int i = 0; i < csp.n_rows(); ++i) + for (size_type i = 0; i < csp.n_rows(); ++i) { - const unsigned int *rows = &sp_A.colnums[sp_A.rowstart[i]]; - const unsigned int *const end_rows = + const size_type *rows = &sp_A.colnums[sp_A.rowstart[i]]; + const size_type *const end_rows = &sp_A.colnums[sp_A.rowstart[i+1]]; for (; rows != end_rows; ++rows) { - const unsigned int col = *rows; - unsigned int *new_cols = const_cast + const size_type col = *rows; + size_type *new_cols = const_cast (&sp_B.colnums[sp_B.rowstart[col]]); - unsigned int *end_new_cols = const_cast + size_type *end_new_cols = const_cast (&sp_B.colnums[sp_B.rowstart[col+1]]); // if B has a diagonal, need to add that manually. this way, @@ -961,8 +963,8 @@ SparseMatrix::mmult (SparseMatrix &C, // create an array that caches some // elements that are going to be written // into the new matrix. - unsigned int max_n_cols_B = 0; - for (unsigned int i=0; i new_entries(max_n_cols_B); @@ -970,15 +972,15 @@ SparseMatrix::mmult (SparseMatrix &C, // nested loops. One over the rows of A, for each row we then loop over all // the columns, and then we need to multiply each element with all the // elements in that row in B. - for (unsigned int i=0; i::Tmmult (SparseMatrix &C, // CompressedSimpleSparsityPattern class. { CompressedSimpleSparsityPattern csp (n(), B.n()); - for (unsigned int i = 0; i < sp_A.n_rows(); ++i) + for (size_type i = 0; i < sp_A.n_rows(); ++i) { - const unsigned int *rows = + const size_type *rows = &sp_A.colnums[sp_A.rowstart[i]]; - const unsigned int *const end_rows = + const size_type *const end_rows = &sp_A.colnums[sp_A.rowstart[i+1]]; // cast away constness to conform with csp.add_entries interface - unsigned int *new_cols = const_cast + size_type *new_cols = const_cast (&sp_B.colnums[sp_B.rowstart[i]]); - unsigned int *end_new_cols = const_cast + size_type *end_new_cols = const_cast (&sp_B.colnums[sp_B.rowstart[i+1]]); if (sp_B.n_rows() == sp_B.n_cols()) @@ -1068,7 +1070,7 @@ SparseMatrix::Tmmult (SparseMatrix &C, for (; rows != end_rows; ++rows) { - const unsigned int row = *rows; + const size_type row = *rows; // if B has a diagonal, need to add that manually. this way, // we maintain sortedness. @@ -1091,8 +1093,8 @@ SparseMatrix::Tmmult (SparseMatrix &C, // create an array that caches some // elements that are going to be written // into the new matrix. - unsigned int max_n_cols_B = 0; - for (unsigned int i=0; i new_entries(max_n_cols_B); @@ -1100,11 +1102,11 @@ SparseMatrix::Tmmult (SparseMatrix &C, // nested loops. One over the rows of A, for each row we then loop over all // the columns, and then we need to multiply each element with all the // elements in that row in B. - for (unsigned int i=0; i::Tmmult (SparseMatrix &C, for (; rows != end_rows; ++rows) { - const unsigned int row = *rows; + const size_type row = *rows; const double A_val = val[rows-&sp_A.colnums[sp_A.rowstart[0]]]; // special treatment for diagonal @@ -1146,9 +1148,9 @@ SparseMatrix::l1_norm () const Assert (val != 0, ExcNotInitialized()); Vector column_sums(n()); - const unsigned int n_rows = m(); - for (unsigned int row=0; rowrowstart[row]; jrowstart[row+1] ; ++j) + const size_type n_rows = m(); + for (size_type row=0; rowrowstart[row]; jrowstart[row+1] ; ++j) column_sums(cols->colnums[j]) += numbers::NumberTraits::abs(val[j]); return column_sums.linfty_norm(); @@ -1166,8 +1168,8 @@ SparseMatrix::linfty_norm () const const number *val_ptr = &val[cols->rowstart[0]]; real_type max=0; - const unsigned int n_rows = m(); - for (unsigned int row=0; rowrowstart[row+1]]; @@ -1189,7 +1191,7 @@ SparseMatrix::frobenius_norm () const // sparsity pattern, without taking any // reference to rows or columns real_type norm_sqr = 0; - const unsigned int n_rows = m(); + const size_type n_rows = m(); for (const number *ptr = &val[0]; ptr != &val[cols->rowstart[n_rows]]; ++ptr) norm_sqr += numbers::NumberTraits::abs_square(*ptr); @@ -1217,21 +1219,21 @@ namespace internal template - number residual_sqr_on_subrange (const unsigned int begin_row, - const unsigned int end_row, - const number *values, + number residual_sqr_on_subrange (const size_type begin_row, + const size_type end_row, + const number *values, const std::size_t *rowstart, - const unsigned int *colnums, - const InVector &u, - const InVector &b, - OutVector &dst) + const size_type *colnums, + const InVector &u, + const InVector &b, + OutVector &dst) { number norm_sqr=0.; - for (unsigned int i=begin_row; i::conjugate(s); @@ -1285,9 +1287,9 @@ SparseMatrix::precondition_Jacobi (Vector &dst, AssertDimension (dst.size(), n()); AssertDimension (src.size(), n()); - const unsigned int n = src.size(); - somenumber *dst_ptr = dst.begin(); - const somenumber *src_ptr = src.begin(); + const size_type n = src.size(); + somenumber *dst_ptr = dst.begin(); + const somenumber *src_ptr = src.begin(); const std::size_t *rowstart_ptr = &cols->rowstart[0]; // optimize the following loop for @@ -1302,10 +1304,10 @@ SparseMatrix::precondition_Jacobi (Vector &dst, // rowstart[i]. and we do have a // square matrix by above assertion if (om != 1.) - for (unsigned int i=0; i::precondition_SSOR (Vector &dst, AssertDimension (dst.size(), n()); AssertDimension (src.size(), n()); - const unsigned int n = src.size(); - const std::size_t *rowstart_ptr = &cols->rowstart[0]; - somenumber *dst_ptr = &dst(0); + const size_type n = src.size(); + const std::size_t *rowstart_ptr = &cols->rowstart[0]; + somenumber *dst_ptr = &dst(0); // case when we have stored the position // just right of the diagonal (then we @@ -1342,7 +1344,7 @@ SparseMatrix::precondition_SSOR (Vector &dst, ExcDimensionMismatch (pos_right_of_diagonal.size(), dst.size())); // forward sweep - for (unsigned int row=0; row::precondition_SSOR (Vector &dst, Assert (first_right_of_diagonal_index <= *(rowstart_ptr+1), ExcInternalError()); number s = 0; - for (unsigned int j=(*rowstart_ptr)+1; jcolnums[j]); // divide by diagonal element @@ -1369,11 +1371,11 @@ SparseMatrix::precondition_SSOR (Vector &dst, dst_ptr = &dst(n-1); for (int row=n-1; row>=0; --row, --rowstart_ptr, --dst_ptr) { - const unsigned int end_row = *(rowstart_ptr+1); - const unsigned int first_right_of_diagonal_index + const size_type end_row = *(rowstart_ptr+1); + const size_type first_right_of_diagonal_index = pos_right_of_diagonal[row]; number s = 0; - for (unsigned int j=first_right_of_diagonal_index; jcolnums[j]); *dst_ptr -= s * om; @@ -1387,7 +1389,7 @@ SparseMatrix::precondition_SSOR (Vector &dst, // of the first element right of the // diagonal manually for each sweep. // forward sweep - for (unsigned int row=0; row::precondition_SSOR (Vector &dst, // note: the first entry in each // line denotes the diagonal element, // which we need not check. - const unsigned int first_right_of_diagonal_index + const size_type first_right_of_diagonal_index = (Utilities::lower_bound (&cols->colnums[*rowstart_ptr+1], &cols->colnums[*(rowstart_ptr+1)], row) @@ -1405,7 +1407,7 @@ SparseMatrix::precondition_SSOR (Vector &dst, &cols->colnums[0]); number s = 0; - for (unsigned int j=(*rowstart_ptr)+1; jcolnums[j]); // divide by diagonal element @@ -1416,7 +1418,7 @@ SparseMatrix::precondition_SSOR (Vector &dst, rowstart_ptr = &cols->rowstart[0]; dst_ptr = &dst(0); - for (unsigned int row=0; row::precondition_SSOR (Vector &dst, dst_ptr = &dst(n-1); for (int row=n-1; row>=0; --row, --rowstart_ptr, --dst_ptr) { - const unsigned int end_row = *(rowstart_ptr+1); - const unsigned int first_right_of_diagonal_index + const size_type end_row = *(rowstart_ptr+1); + const size_type first_right_of_diagonal_index = (Utilities::lower_bound (&cols->colnums[*rowstart_ptr+1], &cols->colnums[end_row], - static_cast(row)) - + static_cast(row)) - &cols->colnums[0]); number s = 0; - for (unsigned int j=first_right_of_diagonal_index; jcolnums[j]); *dst_ptr -= s * om; Assert(val[*rowstart_ptr]!= 0., ExcDivideByZero()); @@ -1481,12 +1483,12 @@ SparseMatrix::SOR (Vector &dst, AssertDimension (m(), n()); AssertDimension (dst.size(), n()); - for (unsigned int row=0; rowrowstart[row]; jrowstart[row+1]; ++j) + for (size_type j=cols->rowstart[row]; jrowstart[row+1]; ++j) { - const unsigned int col = cols->colnums[j]; + const size_type col = cols->colnums[j]; if (col < row) s -= val[j] * dst(col); } @@ -1508,11 +1510,11 @@ SparseMatrix::TSOR (Vector &dst, AssertDimension (m(), n()); AssertDimension (dst.size(), n()); - unsigned int row=m()-1; + size_type row=m()-1; while (true) { somenumber s = dst(row); - for (unsigned int j=cols->rowstart[row]; jrowstart[row+1]; ++j) + for (size_type j=cols->rowstart[row]; jrowstart[row+1]; ++j) if (cols->colnums[j] > row) s -= val[j] * dst(cols->colnums[j]); @@ -1531,8 +1533,8 @@ template template void SparseMatrix::PSOR (Vector &dst, - const std::vector &permutation, - const std::vector &inverse_permutation, + const std::vector &permutation, + const std::vector &inverse_permutation, const number om) const { Assert (cols != 0, ExcNotInitialized()); @@ -1545,14 +1547,14 @@ SparseMatrix::PSOR (Vector &dst, Assert (m() == inverse_permutation.size(), ExcDimensionMismatch(m(), inverse_permutation.size())); - for (unsigned int urow=0; urowrowstart[row]; jrowstart[row+1]; ++j) + for (size_type j=cols->rowstart[row]; jrowstart[row+1]; ++j) { - const unsigned int col = cols->colnums[j]; + const size_type col = cols->colnums[j]; if (inverse_permutation[col] < urow) { s -= val[j] * dst(col); @@ -1569,8 +1571,8 @@ template template void SparseMatrix::TPSOR (Vector &dst, - const std::vector &permutation, - const std::vector &inverse_permutation, + const std::vector &permutation, + const std::vector &inverse_permutation, const number om) const { Assert (cols != 0, ExcNotInitialized()); @@ -1583,14 +1585,14 @@ SparseMatrix::TPSOR (Vector &dst, Assert (m() == inverse_permutation.size(), ExcDimensionMismatch(m(), inverse_permutation.size())); - for (unsigned int urow=m(); urow != 0;) + for (size_type urow=m(); urow != 0;) { --urow; - const unsigned int row = permutation[urow]; + const size_type row = permutation[urow]; somenumber s = dst(row); - for (unsigned int j=cols->rowstart[row]; jrowstart[row+1]; ++j) + for (size_type j=cols->rowstart[row]; jrowstart[row+1]; ++j) { - const unsigned int col = cols->colnums[j]; + const size_type col = cols->colnums[j]; if (inverse_permutation[col] > urow) s -= val[j] * dst(col); } @@ -1646,10 +1648,10 @@ SparseMatrix::SOR_step (Vector &v, Assert (m() == v.size(), ExcDimensionMismatch(m(),v.size())); Assert (m() == b.size(), ExcDimensionMismatch(m(),b.size())); - for (unsigned int row=0; rowrowstart[row]; jrowstart[row+1]; ++j) + for (size_type j=cols->rowstart[row]; jrowstart[row+1]; ++j) { s -= val[j] * v(cols->colnums[j]); } @@ -1676,7 +1678,7 @@ SparseMatrix::TSOR_step (Vector &v, for (int row=m()-1; row>=0; --row) { somenumber s = b(row); - for (unsigned int j=cols->rowstart[row]; jrowstart[row+1]; ++j) + for (size_type j=cols->rowstart[row]; jrowstart[row+1]; ++j) { s -= val[j] * v(cols->colnums[j]); } @@ -1714,16 +1716,16 @@ SparseMatrix::SSOR (Vector &dst, AssertDimension (m(), n()); Assert (m() == dst.size(), ExcDimensionMismatch(m(),dst.size())); - const unsigned int n = dst.size(); - unsigned int j; + const size_type n = dst.size(); + size_type j; somenumber s; - for (unsigned int i=0; irowstart[i]; jrowstart[i+1] ; j++) { - const unsigned int p = cols->colnums[j]; + const size_type p = cols->colnums[j]; if (p != SparsityPattern::invalid_entry) { if (i>j) s += val[j] * dst(p); @@ -1739,10 +1741,10 @@ SparseMatrix::SSOR (Vector &dst, s = 0.; for (j=cols->rowstart[i]; jrowstart[i+1] ; j++) { - const unsigned int p = cols->colnums[j]; + const size_type p = cols->colnums[j]; if (p != SparsityPattern::invalid_entry) { - if (static_cast(i)(i)rowstart[i]]!= 0., ExcDivideByZero()); @@ -1791,9 +1793,9 @@ void SparseMatrix::print_formatted (std::ostream &out, width = precision+2; } - for (unsigned int i=0; ioperator()(i,j)] * denominator << ' '; @@ -1817,9 +1819,9 @@ void SparseMatrix::print_pattern (std::ostream &out, Assert (cols != 0, ExcNotInitialized()); Assert (val != 0, ExcNotInitialized()); - for (unsigned int i=0; ioperator()(i,j)]) > threshold) diff --git a/deal.II/include/deal.II/lac/sparse_matrix_ez.h b/deal.II/include/deal.II/lac/sparse_matrix_ez.h index a7fa2e7f46..b1c1c8ca17 100644 --- a/deal.II/include/deal.II/lac/sparse_matrix_ez.h +++ b/deal.II/include/deal.II/lac/sparse_matrix_ez.h @@ -97,6 +97,11 @@ template class SparseMatrixEZ : public Subscriptor { public: + /** + * Declare type for container size. + */ + typedef types::global_dof_index size_type; + /** * The class for storing the * column number of an entry @@ -115,13 +120,13 @@ public: * Constructor. Fills column * and value. */ - Entry (const unsigned int column, + Entry (const size_type column, const number &value); /** * The column number. */ - unsigned int column; + size_type column; /** * The value there. @@ -131,7 +136,7 @@ public: /** * Non-existent column number. */ - static const unsigned int invalid = numbers::invalid_unsigned_int; + static const size_type invalid = numbers::invalid_size_type; }; /** @@ -145,13 +150,13 @@ public: /** * Constructor. */ - RowInfo (unsigned int start = Entry::invalid); + RowInfo (size_type start = Entry::invalid); /** * Index of first entry of * the row in the data field. */ - unsigned int start; + size_type start; /** * Number of entries in this * row. @@ -191,7 +196,7 @@ public: * pointer is sufficient. */ Accessor (const SparseMatrixEZ *matrix, - const unsigned int row, + const size_type row, const unsigned short index); /** @@ -199,7 +204,7 @@ public: * represented by this * object. */ - unsigned int row() const; + size_type row() const; /** * Index in row of the element @@ -213,7 +218,7 @@ public: * element represented by * this object. */ - unsigned int column() const; + size_type column() const; /** * Value of this matrix entry. @@ -229,7 +234,7 @@ public: /** * Current row number. */ - unsigned int a_row; + size_type a_row; /** * Current index in row. @@ -248,7 +253,7 @@ public: * Constructor. */ const_iterator(const SparseMatrixEZ *matrix, - const unsigned int row, + const size_type row, const unsigned short index); /** @@ -364,9 +369,9 @@ public: * efficient assembling of the * matrix. */ - explicit SparseMatrixEZ (const unsigned int n_rows, - const unsigned int n_columns, - const unsigned int default_row_length = 0, + explicit SparseMatrixEZ (const size_type n_rows, + const size_type n_columns, + const size_type default_row_length = 0, const unsigned int default_increment = 1); /** @@ -415,11 +420,11 @@ public: * efficient assembling of the * matrix. */ - void reinit (const unsigned int n_rows, - const unsigned int n_columns, - unsigned int default_row_length = 0, + void reinit (const size_type n_rows, + const size_type n_columns, + size_type default_row_length = 0, unsigned int default_increment = 1, - unsigned int reserve = 0); + size_type reserve = 0); /** * Release all memory and return @@ -447,7 +452,7 @@ public: * matrix is of dimension * $m \times n$. */ - unsigned int m () const; + size_type m () const; /** * Return the dimension of the @@ -455,19 +460,19 @@ public: * matrix is of dimension * $m \times n$. */ - unsigned int n () const; + size_type n () const; /** * Return the number of entries * in a specific row. */ - unsigned int get_row_length (const unsigned int row) const; + size_type get_row_length (const size_type row) const; /** * Return the number of nonzero * elements of this matrix. */ - unsigned int n_nonzero_elements () const; + size_type n_nonzero_elements () const; /** * Determine an estimate for the @@ -501,10 +506,10 @@ public: * the number of entries in each * line is printed as well. */ - void compute_statistics (unsigned int &used, - unsigned int &allocated, - unsigned int &reserved, - std::vector &used_by_line, + void compute_statistics (size_type &used, + size_type &allocated, + size_type &reserved, + std::vector &used_by_line, const bool compute_by_line) const; //@} /** @@ -520,7 +525,7 @@ public: * finite number an exception * is thrown. */ - void set (const unsigned int i, const unsigned int j, + void set (const size_type i, const size_type j, const number value); /** @@ -532,8 +537,8 @@ public: * finite number an exception * is thrown. */ - void add (const unsigned int i, - const unsigned int j, + void add (const size_type i, + const size_type j, const number value); /** @@ -564,9 +569,9 @@ public: * into the matrix. */ template - void add (const std::vector &indices, - const FullMatrix &full_matrix, - const bool elide_zero_values = true); + void add (const std::vector &indices, + const FullMatrix &full_matrix, + const bool elide_zero_values = true); /** * Same function as before, but now @@ -576,8 +581,8 @@ public: * on rows and columns, respectively. */ template - void add (const std::vector &row_indices, - const std::vector &col_indices, + void add (const std::vector &row_indices, + const std::vector &col_indices, const FullMatrix &full_matrix, const bool elide_zero_values = true); @@ -599,10 +604,10 @@ public: * into the matrix. */ template - void add (const unsigned int row, - const std::vector &col_indices, - const std::vector &values, - const bool elide_zero_values = true); + void add (const size_type row, + const std::vector &col_indices, + const std::vector &values, + const bool elide_zero_values = true); /** * Add an array of values given by @@ -622,12 +627,12 @@ public: * into the matrix. */ template - void add (const unsigned int row, - const unsigned int n_cols, - const unsigned int *col_indices, - const number2 *values, - const bool elide_zero_values = true, - const bool col_indices_are_sorted = false); + void add (const size_type row, + const size_type n_cols, + const size_type *col_indices, + const number2 *values, + const bool elide_zero_values = true, + const bool col_indices_are_sorted = false); /** * Copy the given matrix to this @@ -696,16 +701,16 @@ public: * matrix), use the @p el * function. */ - number operator () (const unsigned int i, - const unsigned int j) const; + number operator () (const size_type i, + const size_type j) const; /** * Return the value of the entry * (i,j). Returns zero for all * non-existing entries. */ - number el (const unsigned int i, - const unsigned int j) const; + number el (const size_type i, + const size_type j) const; //@} /** * @name Multiplications @@ -853,14 +858,14 @@ public: * is end(r), which does NOT * point into row @p r.. */ - const_iterator begin (const unsigned int r) const; + const_iterator begin (const size_type r) const; /** * Final iterator of row * @p r. The result may be * different from end()! */ - const_iterator end (const unsigned int r) const; + const_iterator end (const size_type r) const; //@} /** * @name Input/Output @@ -978,8 +983,8 @@ private: * zero-pointer if the entry does * not exist. */ - const Entry *locate (const unsigned int row, - const unsigned int col) const; + const Entry *locate (const size_type row, + const size_type col) const; /** * Find an entry and return a @@ -987,14 +992,14 @@ private: * zero-pointer if the entry does * not exist. */ - Entry *locate (const unsigned int row, - const unsigned int col); + Entry *locate (const size_type row, + const size_type col); /** * Find an entry or generate it. */ - Entry *allocate (const unsigned int row, - const unsigned int col); + Entry *allocate (const size_type row, + const size_type col); /** * Version of @p vmult which only @@ -1008,8 +1013,8 @@ private: template void threaded_vmult (Vector &dst, const Vector &src, - const unsigned int begin_row, - const unsigned int end_row) const; + const size_type begin_row, + const size_type end_row) const; /** * Version of @@ -1024,8 +1029,8 @@ private: */ template void threaded_matrix_norm_square (const Vector &v, - const unsigned int begin_row, - const unsigned int end_row, + const size_type begin_row, + const size_type end_row, somenumber *partial_sum) const; /** @@ -1042,8 +1047,8 @@ private: template void threaded_matrix_scalar_product (const Vector &u, const Vector &v, - const unsigned int begin_row, - const unsigned int end_row, + const size_type begin_row, + const size_type end_row, somenumber *partial_sum) const; /** @@ -1051,7 +1056,7 @@ private: * used to check vector * dimensions only. */ - unsigned int n_columns; + size_type n_columns; /** * Info structure for each row. @@ -1084,7 +1089,7 @@ private: template inline -SparseMatrixEZ::Entry::Entry(unsigned int column, +SparseMatrixEZ::Entry::Entry(size_type column, const number &value) : column(column), @@ -1104,7 +1109,7 @@ SparseMatrixEZ::Entry::Entry() template inline -SparseMatrixEZ::RowInfo::RowInfo(unsigned int start) +SparseMatrixEZ::RowInfo::RowInfo(size_type start) : start(start), length(0), @@ -1117,7 +1122,7 @@ template inline SparseMatrixEZ::const_iterator::Accessor:: Accessor (const SparseMatrixEZ *matrix, - const unsigned int r, + const size_type r, const unsigned short i) : matrix(matrix), @@ -1128,7 +1133,7 @@ Accessor (const SparseMatrixEZ *matrix, template inline -unsigned int +typename SparseMatrixEZ::size_type SparseMatrixEZ::const_iterator::Accessor::row() const { return a_row; @@ -1137,7 +1142,7 @@ SparseMatrixEZ::const_iterator::Accessor::row() const template inline -unsigned int +typename SparseMatrixEZ::size_type SparseMatrixEZ::const_iterator::Accessor::column() const { return matrix->data[matrix->row_info[a_row].start+a_index].column; @@ -1167,7 +1172,7 @@ template inline SparseMatrixEZ::const_iterator:: const_iterator(const SparseMatrixEZ *matrix, - const unsigned int r, + const size_type r, const unsigned short i) : accessor(matrix, r, i) @@ -1280,7 +1285,7 @@ operator < (const const_iterator &other) const //--------------------------------------------------------------------------- template inline -unsigned int SparseMatrixEZ::m () const +typename SparseMatrixEZ::size_type SparseMatrixEZ::m () const { return row_info.size(); } @@ -1288,7 +1293,7 @@ unsigned int SparseMatrixEZ::m () const template inline -unsigned int SparseMatrixEZ::n () const +typename SparseMatrixEZ::size_type SparseMatrixEZ::n () const { return n_columns; } @@ -1297,15 +1302,15 @@ unsigned int SparseMatrixEZ::n () const template inline typename SparseMatrixEZ::Entry * -SparseMatrixEZ::locate (const unsigned int row, - const unsigned int col) +SparseMatrixEZ::locate (const size_type row, + const size_type col) { Assert (rowcolumn == col) @@ -1321,8 +1326,8 @@ SparseMatrixEZ::locate (const unsigned int row, template inline const typename SparseMatrixEZ::Entry * -SparseMatrixEZ::locate (const unsigned int row, - const unsigned int col) const +SparseMatrixEZ::locate (const size_type row, + const size_type col) const { SparseMatrixEZ *t = const_cast*> (this); return t->locate(row,col); @@ -1332,16 +1337,16 @@ SparseMatrixEZ::locate (const unsigned int row, template inline typename SparseMatrixEZ::Entry * -SparseMatrixEZ::allocate (const unsigned int row, - const unsigned int col) +SparseMatrixEZ::allocate (const size_type row, + const size_type col) { Assert (row::allocate (const unsigned int row, data.insert(data.begin()+end, increment, Entry()); // Update starts of // following rows - for (unsigned int rn=row+1; rn::allocate (const unsigned int row, // Move all entries in this // row up by one - for (unsigned int j = i+1; j < end; ++j) + for (size_type j = i+1; j < end; ++j) { // There should be no invalid // entry below end @@ -1429,8 +1434,8 @@ SparseMatrixEZ::allocate (const unsigned int row, template inline -void SparseMatrixEZ::set (const unsigned int i, - const unsigned int j, +void SparseMatrixEZ::set (const size_type i, + const size_type j, const number value) { @@ -1456,8 +1461,8 @@ void SparseMatrixEZ::set (const unsigned int i, template inline -void SparseMatrixEZ::add (const unsigned int i, - const unsigned int j, +void SparseMatrixEZ::add (const size_type i, + const size_type j, const number value) { @@ -1477,13 +1482,13 @@ void SparseMatrixEZ::add (const unsigned int i, template template -void SparseMatrixEZ::add (const std::vector &indices, - const FullMatrix &full_matrix, - const bool elide_zero_values) +void SparseMatrixEZ::add (const std::vector &indices, + const FullMatrix &full_matrix, + const bool elide_zero_values) { //TODO: This function can surely be made more efficient - for (unsigned int i=0; i::add (const std::vector &indices, template template -void SparseMatrixEZ::add (const std::vector &row_indices, - const std::vector &col_indices, - const FullMatrix &full_matrix, - const bool elide_zero_values) +void SparseMatrixEZ::add (const std::vector &row_indices, + const std::vector &col_indices, + const FullMatrix &full_matrix, + const bool elide_zero_values) { //TODO: This function can surely be made more efficient - for (unsigned int i=0; i::add (const std::vector &row_indices, template template -void SparseMatrixEZ::add (const unsigned int row, - const std::vector &col_indices, - const std::vector &values, - const bool elide_zero_values) +void SparseMatrixEZ::add (const size_type row, + const std::vector &col_indices, + const std::vector &values, + const bool elide_zero_values) { //TODO: This function can surely be made more efficient - for (unsigned int j=0; j::add (const unsigned int row, template template -void SparseMatrixEZ::add (const unsigned int row, - const unsigned int n_cols, - const unsigned int *col_indices, - const number2 *values, - const bool elide_zero_values, - const bool /*col_indices_are_sorted*/) +void SparseMatrixEZ::add (const size_type row, + const size_type n_cols, + const size_type *col_indices, + const number2 *values, + const bool elide_zero_values, + const bool /*col_indices_are_sorted*/) { //TODO: This function can surely be made more efficient - for (unsigned int j=0; j::add (const unsigned int row, template inline -number SparseMatrixEZ::el (const unsigned int i, - const unsigned int j) const +number SparseMatrixEZ::el (const size_type i, + const size_type j) const { const Entry *entry = locate(i,j); if (entry) @@ -1555,8 +1560,8 @@ number SparseMatrixEZ::el (const unsigned int i, template inline -number SparseMatrixEZ::operator() (const unsigned int i, - const unsigned int j) const +number SparseMatrixEZ::operator() (const size_type i, + const size_type j) const { const Entry *entry = locate(i,j); if (entry) @@ -1586,7 +1591,7 @@ SparseMatrixEZ::end () const template inline typename SparseMatrixEZ::const_iterator -SparseMatrixEZ::begin (const unsigned int r) const +SparseMatrixEZ::begin (const size_type r) const { Assert (r::begin (const unsigned int r) const template inline typename SparseMatrixEZ::const_iterator -SparseMatrixEZ::end (const unsigned int r) const +SparseMatrixEZ::end (const size_type r) const { Assert (r::copy_from (const MATRIX &M) // loop over the elements of the argument matrix row by row, as suggested // in the documentation of the sparse matrix iterator class, and // copy them into the current object - for (unsigned int row = 0; row < M.m(); ++row) + for (size_type row = 0; row < M.m(); ++row) { const typename MATRIX::const_iterator end_row = M.end(row); for (typename MATRIX::const_iterator entry = M.begin(row); @@ -1642,7 +1647,7 @@ SparseMatrixEZ::add (const number factor, // loop over the elements of the argument matrix row by row, as suggested // in the documentation of the sparse matrix iterator class, and // add them into the current object - for (unsigned int row = 0; row < M.m(); ++row) + for (size_type row = 0; row < M.m(); ++row) { const typename MATRIX::const_iterator end_row = M.end(row); for (typename MATRIX::const_iterator entry = M.begin(row); @@ -1682,13 +1687,13 @@ SparseMatrixEZ::conjugate_add (const MATRIXA &A, if (transpose) while (b1 != b_final) { - const unsigned int i = b1->column(); - const unsigned int k = b1->row(); + const size_type i = b1->column(); + const size_type k = b1->row(); typename MATRIXB::const_iterator b2 = B.begin(); while (b2 != b_final) { - const unsigned int j = b2->column(); - const unsigned int l = b2->row(); + const size_type j = b2->column(); + const size_type l = b2->row(); const typename MATRIXA::value_type a = A.el(k,l); @@ -1704,11 +1709,11 @@ SparseMatrixEZ::conjugate_add (const MATRIXA &A, // maximal row for a column in // advance. - std::vector minrow(B.n(), B.m()); - std::vector maxrow(B.n(), 0); + std::vector minrow(B.n(), B.m()); + std::vector maxrow(B.n(), 0); while (b1 != b_final) { - const unsigned int r = b1->row(); + const size_type r = b1->row(); if (r < minrow[b1->column()]) minrow[b1->column()] = r; if (r > maxrow[b1->column()]) @@ -1745,7 +1750,7 @@ SparseMatrixEZ::conjugate_add (const MATRIXA &A, // the work if (b1->column() == ai->row() && (b1v != 0.)) { - const unsigned int i = b1->row(); + const size_type i = b1->row(); typename MATRIXB::const_iterator b2 = B.begin(minrow[ai->column()]); @@ -1753,7 +1758,7 @@ SparseMatrixEZ::conjugate_add (const MATRIXA &A, { if (b2->column() == ai->column()) { - const unsigned int j = b2->row(); + const size_type j = b2->row(); add (i, j, a * b1v * b2->value()); } ++b2; @@ -1773,10 +1778,10 @@ inline void SparseMatrixEZ::print_statistics(STREAM &out, bool full) { - unsigned int used; - unsigned int allocated; - unsigned int reserved; - std::vector used_by_line; + size_type used; + size_type allocated; + size_type reserved; + std::vector used_by_line; compute_statistics (used, allocated, reserved, used_by_line, full); @@ -1786,7 +1791,7 @@ SparseMatrixEZ::print_statistics(STREAM &out, bool full) if (full) { - for (unsigned int i=0; i< used_by_line.size(); ++i) + for (size_type i=0; i< used_by_line.size(); ++i) if (used_by_line[i] != 0) out << "SparseMatrixEZ:entries\t" << i << "\trows\t" << used_by_line[i] diff --git a/deal.II/include/deal.II/lac/sparse_matrix_ez.templates.h b/deal.II/include/deal.II/lac/sparse_matrix_ez.templates.h index 1c4ee5b8f6..4c1f6b7386 100644 --- a/deal.II/include/deal.II/lac/sparse_matrix_ez.templates.h +++ b/deal.II/include/deal.II/lac/sparse_matrix_ez.templates.h @@ -44,9 +44,9 @@ SparseMatrixEZ::SparseMatrixEZ(const SparseMatrixEZ &m) template -SparseMatrixEZ::SparseMatrixEZ(const unsigned int n_rows, - const unsigned int n_cols, - const unsigned int default_row_length, +SparseMatrixEZ::SparseMatrixEZ(const size_type n_rows, + const size_type n_cols, + const size_type default_row_length, const unsigned int default_increment) { reinit(n_rows, n_cols, default_row_length, default_increment); @@ -88,11 +88,11 @@ SparseMatrixEZ::operator = (const double d) template void -SparseMatrixEZ::reinit(const unsigned int n_rows, - const unsigned int n_cols, - unsigned int default_row_length, - unsigned int default_increment, - unsigned int reserve) +SparseMatrixEZ::reinit(const size_type n_rows, + const size_type n_cols, + size_type default_row_length, + unsigned int default_increment, + size_type reserve) { clear(); @@ -104,7 +104,7 @@ SparseMatrixEZ::reinit(const unsigned int n_rows, data.reserve(reserve); data.resize(default_row_length * n_rows); - for (unsigned int i=0; i::vmult (Vector &dst, Assert(m() == dst.size(), ExcDimensionMismatch(m(),dst.size())); Assert(n() == src.size(), ExcDimensionMismatch(n(),src.size())); - const unsigned int end_row = row_info.size(); - for (unsigned int row = 0; row < end_row; ++row) + const size_type end_row = row_info.size(); + for (size_type row = 0; row < end_row; ++row) { const RowInfo &ri = row_info[row]; typename std::vector::const_iterator @@ -193,8 +193,8 @@ SparseMatrixEZ::vmult_add (Vector &dst, Assert(m() == dst.size(), ExcDimensionMismatch(m(),dst.size())); Assert(n() == src.size(), ExcDimensionMismatch(n(),src.size())); - const unsigned int end_row = row_info.size(); - for (unsigned int row = 0; row < end_row; ++row) + const size_type end_row = row_info.size(); + for (size_type row = 0; row < end_row; ++row) { const RowInfo &ri = row_info[row]; typename std::vector::const_iterator @@ -219,8 +219,8 @@ SparseMatrixEZ::Tvmult_add (Vector &dst, Assert(n() == dst.size(), ExcDimensionMismatch(n(),dst.size())); Assert(m() == src.size(), ExcDimensionMismatch(m(),src.size())); - const unsigned int end_row = row_info.size(); - for (unsigned int row = 0; row < end_row; ++row) + const size_type end_row = row_info.size(); + for (size_type row = 0; row < end_row; ++row) { const RowInfo &ri = row_info[row]; typename std::vector::const_iterator @@ -280,8 +280,8 @@ SparseMatrixEZ::precondition_SOR (Vector &dst, { Assert (ri->diagonal != RowInfo::invalid_diagonal, ExcNoDiagonal()); number s = *src_ptr; - const unsigned int end_row = ri->start + ri->diagonal; - for (unsigned int i=ri->start; istart + ri->diagonal; + for (size_type i=ri->start; istart + ri->diagonal].value; @@ -312,8 +312,8 @@ SparseMatrixEZ::precondition_TSOR (Vector &dst, { Assert (ri->diagonal != RowInfo::invalid_diagonal, ExcNoDiagonal()); number s = *src_ptr; - const unsigned int end_row = ri->start + ri->length; - for (unsigned int i=ri->start+ri->diagonal+1; istart + ri->length; + for (size_type i=ri->start+ri->diagonal+1; istart + ri->diagonal].value; @@ -344,8 +344,8 @@ SparseMatrixEZ::precondition_SSOR (Vector &dst, { Assert (ri->diagonal != RowInfo::invalid_diagonal, ExcNoDiagonal()); number s = 0; - const unsigned int end_row = ri->start + ri->diagonal; - for (unsigned int i=ri->start; istart + ri->diagonal; + for (size_type i=ri->start; i::precondition_SSOR (Vector &dst, dst_ptr = dst.begin()+dst.size()-1; for (rri = row_info.rbegin(); rri != rend; --dst_ptr, ++rri) { - const unsigned int end_row = rri->start + rri->length; + const size_type end_row = rri->start + rri->length; number s = 0; - for (unsigned int i=rri->start+rri->diagonal+1; istart+rri->diagonal+1; i::memory_consumption() const { return sizeof (*this) - + sizeof(unsigned int) * row_info.capacity() + + sizeof(size_type) * row_info.capacity() + sizeof(typename SparseMatrixEZ::Entry) * data.capacity(); } template -unsigned int -SparseMatrixEZ::get_row_length (const unsigned int row) const +typename SparseMatrixEZ::size_type +SparseMatrixEZ::get_row_length (const size_type row) const { return row_info[row].length; } @@ -397,14 +397,14 @@ SparseMatrixEZ::get_row_length (const unsigned int row) const template -unsigned int +typename SparseMatrixEZ::size_type SparseMatrixEZ::n_nonzero_elements() const { typename std::vector::const_iterator row = row_info.begin(); const typename std::vector::const_iterator endrow = row_info.end(); // Add up entries actually used - unsigned int used = 0; + size_type used = 0; for (; row != endrow ; ++ row) used += row->length; return used; @@ -415,10 +415,10 @@ SparseMatrixEZ::n_nonzero_elements() const template void SparseMatrixEZ::compute_statistics( - unsigned int &used, - unsigned int &allocated, - unsigned int &reserved, - std::vector &used_by_line, + size_type &used, + size_type &allocated, + size_type &reserved, + std::vector &used_by_line, const bool full) const { typename std::vector::const_iterator row = row_info.begin(); @@ -426,7 +426,7 @@ SparseMatrixEZ::compute_statistics( // Add up entries actually used used = 0; - unsigned int max_length = 0; + size_type max_length = 0; for (; row != endrow ; ++ row) { used += row->length; @@ -503,9 +503,9 @@ SparseMatrixEZ::print_formatted ( std::ostream &out, } // TODO: Skip nonexisting entries - for (unsigned int i=0; i class SparseMIC : public SparseLUDecomposition { public: + /** + * Declare type for container size. + */ + typedef types::global_dof_index size_type; + /** * Constructor. Does nothing, so * you have to call @p decompose @@ -197,7 +202,7 @@ private: * Compute the row-th "inner * sum". */ - number get_rowsum (const unsigned int row) const; + number get_rowsum (const size_type row) const; }; /*@}*/ diff --git a/deal.II/include/deal.II/lac/sparse_mic.templates.h b/deal.II/include/deal.II/lac/sparse_mic.templates.h index 69034c07ba..c35d9cafa7 100644 --- a/deal.II/include/deal.II/lac/sparse_mic.templates.h +++ b/deal.II/include/deal.II/lac/sparse_mic.templates.h @@ -131,10 +131,10 @@ void SparseMIC::decompose (const SparseMatrix &matrix, inner_sums.resize (this->m()); // precalc sum(j=k+1, N, a[k][j])) - for (unsigned int row=0; rowm(); row++) + for (size_type row=0; rowm(); row++) inner_sums[row] = get_rowsum(row); - for (unsigned int row=0; rowm(); row++) + for (size_type row=0; rowm(); row++) { const number temp = this->begin(row)->value(); number temp1 = 0; @@ -158,7 +158,7 @@ void SparseMIC::decompose (const SparseMatrix &matrix, template inline number -SparseMIC::get_rowsum (const unsigned int row) const +SparseMIC::get_rowsum (const size_type row) const { Assert(this->m()==this->n(), ExcNotQuadratic()); @@ -184,13 +184,13 @@ SparseMIC::vmult (Vector &dst, Assert (dst.size() == src.size(), ExcDimensionMismatch(dst.size(), src.size())); Assert (dst.size() == this->m(), ExcDimensionMismatch(dst.size(), this->m())); - const unsigned int N=dst.size(); + const size_type N=dst.size(); // We assume the underlying matrix A is: A = X - L - U, where -L and -U are // strictly lower- and upper- diagonal parts of the system. // // Solve (X-L)X{-1}(X-U) x = b in 3 steps: dst = src; - for (unsigned int row=0; row::vmult (Vector &dst, } // Now: v = Xu - for (unsigned int row=0; row::vmult (Vector &dst, p = this->begin(row)+1; p != this->end(row); ++p) - if (p->column() > static_cast(row)) + if (p->column() > static_cast(row)) dst(row) -= p->value() * dst(p->column()); dst(row) *= inv_diag[row]; diff --git a/deal.II/include/deal.II/lac/sparse_vanka.h b/deal.II/include/deal.II/lac/sparse_vanka.h index 0989a77bc7..0ae7bcb75c 100644 --- a/deal.II/include/deal.II/lac/sparse_vanka.h +++ b/deal.II/include/deal.II/lac/sparse_vanka.h @@ -129,6 +129,11 @@ template class SparseVanka { public: + /** + * Declare type for container size. + */ + typedef types::global_dof_index size_type; + /** * Constructor. Gets the matrix * for preconditioning and a bit @@ -309,8 +314,8 @@ private: * mode, several copies of this * function are spawned. */ - void compute_inverses (const unsigned int begin, - const unsigned int end); + void compute_inverses (const size_type begin, + const size_type end); /** * Compute the inverse of the @@ -326,8 +331,8 @@ private: * the case where this function * re-creates it each time. */ - void compute_inverse (const unsigned int row, - std::vector &local_indices); + void compute_inverse (const size_type row, + std::vector &local_indices); /** * Make the derived class a @@ -510,6 +515,11 @@ template class SparseBlockVanka : public SparseVanka { public: + /** + * Declate type for container size. + */ + typedef types::global_dof_index size_type; + /** * Enumeration of the different * methods by which the DoFs are diff --git a/deal.II/include/deal.II/lac/sparse_vanka.templates.h b/deal.II/include/deal.II/lac/sparse_vanka.templates.h index afa510530d..519cfceabb 100644 --- a/deal.II/include/deal.II/lac/sparse_vanka.templates.h +++ b/deal.II/include/deal.II/lac/sparse_vanka.templates.h @@ -66,12 +66,11 @@ SparseVanka::compute_inverses () compute_inverses (0, matrix->m()); else { - const unsigned int n_inverses = std::count (selected.begin(), - selected.end(), - true); + const size_type n_inverses = std::count (selected.begin(), + selected.end(), + true); - const unsigned int n_inverses_per_thread = std::max(n_inverses / n_threads, - 1U); + const size_type n_inverses_per_thread = std::max(n_inverses / n_threads, 1U); // set up start and end index // for each of the @@ -89,13 +88,13 @@ SparseVanka::compute_inverses () // consecutive, with other // consecutive regions where we // do not have to do something - std::vector > blocking (n_threads); + std::vector > blocking (n_threads); unsigned int c = 0; unsigned int thread = 0; blocking[0].first = 0; - for (unsigned int i=0; (im()) && (thread+1m()) && (thread+1::compute_inverses () }; blocking[n_threads-1].second = matrix->m(); - typedef void (SparseVanka::*FunPtr)(const unsigned int, - const unsigned int); + typedef void (SparseVanka::*FunPtr)(const size_type, + const size_type); const FunPtr fun_ptr = &SparseVanka::compute_inverses; // Now spawn the threads @@ -127,17 +126,17 @@ SparseVanka::compute_inverses () template void -SparseVanka::compute_inverses (const unsigned int begin, - const unsigned int end) +SparseVanka::compute_inverses (const size_type begin, + const size_type end) { // set-up the vector that will be used // by the functions which we call // below. - std::vector local_indices; + std::vector local_indices; // traverse all rows of the matrix // which are selected - for (unsigned int row=begin; row::compute_inverses (const unsigned int begin, template void -SparseVanka::compute_inverse (const unsigned int row, - std::vector &local_indices) +SparseVanka::compute_inverse (const size_type row, + std::vector &local_indices) { // first define an alias to the sparsity // pattern of the matrix, since this @@ -155,14 +154,14 @@ SparseVanka::compute_inverse (const unsigned int row, const SparsityPattern &structure = matrix->get_sparsity_pattern(); - const unsigned int row_length = structure.row_length(row); + const size_type row_length = structure.row_length(row); inverses[row] = new FullMatrix (row_length, row_length); // collect the dofs that couple // with @p row local_indices.resize (row_length); - for (unsigned int i=0; i::apply_preconditioner (Vector &dst, Vector b (structure.max_entries_per_row()); Vector x (structure.max_entries_per_row()); - std::map local_index; + std::map local_index; // traverse all rows of the matrix // which are selected - const unsigned int n = matrix->m(); - for (unsigned int row=0; rowm(); + for (size_type row=0; row::apply_preconditioner (Vector &dst, // all degrees of freedom that // couple with @p row. local_index.clear (); - for (unsigned int i=0; i + for (size_type i=0; i (structure.column_number(row, i), i)); // Build local matrix and rhs - for (std::map::const_iterator is=local_index.begin(); + for (std::map::const_iterator is=local_index.begin(); is!=local_index.end(); ++is) { // irow loops over all DoFs that // couple with the present DoF - const unsigned int irow = is->first; + const size_type irow = is->first; // index of DoF irow in the matrix // row corresponding to DoF @p row. // runs between 0 and row_length - const unsigned int i = is->second; + const size_type i = is->second; // copy rhs b(i) = src(irow); @@ -296,7 +295,7 @@ SparseVanka::apply_preconditioner (Vector &dst, // which itself couples with // @p row) also couples with // @p row. - const std::map::const_iterator js + const std::map::const_iterator js = local_index.find(p->column()); // if not, then still use // this dof to modify the rhs @@ -325,11 +324,11 @@ SparseVanka::apply_preconditioner (Vector &dst, inverses[row]->vmult(x,b); // Distribute new values - for (std::map::const_iterator is=local_index.begin(); + for (std::map::const_iterator is=local_index.begin(); is!=local_index.end(); ++is) { - const unsigned int irow = is->first; - const unsigned int i = is->second; + const size_type irow = is->first; + const size_type i = is->second; if (!range_is_restricted || ((*dof_mask)[irow] == true)) @@ -354,7 +353,7 @@ SparseVanka::memory_consumption () const { std::size_t mem = (sizeof(*this) + MemoryConsumption::memory_consumption (selected)); - for (unsigned int i=0; i::compute_dof_masks (const SparseMatrix &M, { Assert (n_blocks > 0, ExcInternalError()); - const unsigned int n_inverses = std::count (selected.begin(), - selected.end(), - true); + const size_type n_inverses = std::count (selected.begin(), + selected.end(), + true); - const unsigned int n_inverses_per_block = std::max(n_inverses / n_blocks, 1U); + const size_type n_inverses_per_block = std::max(n_inverses / n_blocks, 1U); // precompute the splitting points - std::vector > intervals (n_blocks); + std::vector > intervals (n_blocks); // set up start and end index for // each of the blocks. note that @@ -417,7 +416,7 @@ SparseBlockVanka::compute_dof_masks (const SparseMatrix &M, unsigned int block = 0; intervals[0].first = 0; - for (unsigned int i=0; (i::compute_dof_masks (const SparseMatrix &M, // Lagrange dofs of each // block access the different // dofs - Table<2,unsigned int> access_count (n_blocks, M.m()); + Table<2,size_type> access_count (n_blocks, M.m()); // set-up the map that will // be used to store the // indices each Lagrange dof // accesses - std::map local_index; + std::map local_index; const SparsityPattern &structure = M.get_sparsity_pattern(); - for (unsigned int row=0; row::compute_dof_masks (const SparseMatrix &M, // dofs number the // present index wants // to write - const unsigned int row_length = structure.row_length(row); - for (unsigned int i=0; i::compute_dof_masks (const SparseMatrix &M, // the of course we leave it // to the block we put it // into in the first place - for (unsigned int row=0; row::compute_dof_masks (const SparseMatrix &M, // find out which block // accesses this dof // the most often - unsigned int max_accesses = 0; + size_type max_accesses = 0; unsigned int max_access_block = 0; for (unsigned int block=0; block max_accesses) @@ -599,7 +598,7 @@ std::size_t SparseBlockVanka::memory_consumption () const { std::size_t mem = SparseVanka::memory_consumption(); - for (unsigned int i=0; i - unsigned int - get_column_index_from_iterator (const std::pair &i); + size_type + get_column_index_from_iterator (const std::pair &i); /** * Likewise, but sometimes needed for certain types of containers that @@ -74,8 +79,8 @@ namespace internals * std::map). */ template - unsigned int - get_column_index_from_iterator (const std::pair &i); + size_type + get_column_index_from_iterator (const std::pair &i); } } @@ -89,6 +94,11 @@ namespace SparsityPatternIterators // forward declaration class Iterator; + /** + * Declare type for container size. + */ + typedef types::global_dof_index size_type; + /** * Accessor class for iterators into sparsity patterns. This class is * also the base class for both const and non-const accessor classes @@ -112,8 +122,8 @@ namespace SparsityPatternIterators * with a global index instead. */ Accessor (const SparsityPattern *matrix, - const unsigned int row, - const unsigned int index) DEAL_II_DEPRECATED; + const size_type row, + const size_type index) DEAL_II_DEPRECATED; /** * Constructor. @@ -130,19 +140,19 @@ namespace SparsityPatternIterators * Row number of the element represented by this object. This function can * only be called for entries for which is_valid_entry() is true. */ - unsigned int row () const; + size_type row () const; /** * Index within the current row of the element represented by this object. This function * can only be called for entries for which is_valid_entry() is true. */ - unsigned int index () const; + size_type index () const; /** * Column number of the element represented by this object. This function * can only be called for entries for which is_valid_entry() is true. */ - unsigned int column () const; + size_type column () const; /** * Return whether the sparsity pattern entry pointed to by this iterator @@ -237,8 +247,8 @@ namespace SparsityPatternIterators * with a global index instead. */ Iterator (const SparsityPattern *sp, - const unsigned int row, - const unsigned int index) DEAL_II_DEPRECATED; + const size_type row, + const size_type index) DEAL_II_DEPRECATED; /** * Constructor. Create an iterator into the sparsity pattern @p sp for the @@ -334,6 +344,11 @@ namespace SparsityPatternIterators class SparsityPattern : public Subscriptor { public: + /** + * Declare type for container size. + */ + typedef types::global_dof_index size_type; + /** * Typedef an iterator class that allows to walk over all nonzero elements * of a sparsity pattern. @@ -349,7 +364,7 @@ public: * @deprecated This typedef is deprecated. Use proper iterators instead. */ typedef - const unsigned int *row_iterator; + const size_type *row_iterator; /** * Typedef an iterator class that allows to walk over all nonzero elements @@ -377,7 +392,7 @@ public: * perform some optimizations, but the actual value of the variable may * change over time. */ - static const unsigned int invalid_entry = numbers::invalid_unsigned_int; + static const size_type invalid_entry = numbers::invalid_size_type; /** * @name Construction and setup @@ -419,9 +434,9 @@ public: * @deprecated Use the constructor without the last argument since * it is ignored. */ - SparsityPattern (const unsigned int m, - const unsigned int n, - const unsigned int max_per_row, + SparsityPattern (const size_type m, + const size_type n, + const size_type max_per_row, const bool optimize_diagonal) DEAL_II_DEPRECATED; /** @@ -431,9 +446,9 @@ public: * @arg n number of columns * @arg max_per_row maximum number of nonzero entries per row */ - SparsityPattern (const unsigned int m, - const unsigned int n, - const unsigned int max_per_row); + SparsityPattern (const size_type m, + const size_type n, + const size_type max_per_row); /** * Initialize a rectangular matrix. @@ -447,9 +462,9 @@ public: * @deprecated Use the constructor without the last argument since * it is ignored. */ - SparsityPattern (const unsigned int m, - const unsigned int n, - const std::vector &row_lengths, + SparsityPattern (const size_type m, + const size_type n, + const std::vector &row_lengths, const bool optimize_diagonal) DEAL_II_DEPRECATED; /** @@ -460,9 +475,9 @@ public: * @arg row_lengths possible number of nonzero entries for each row. This * vector must have one entry for each row. */ - SparsityPattern (const unsigned int m, - const unsigned int n, - const std::vector &row_lengths); + SparsityPattern (const size_type m, + const size_type n, + const std::vector &row_lengths); /** * Initialize a quadratic matrix of dimension n with at most @@ -472,8 +487,8 @@ public: * elements. To avoid this, use the constructor taking row and column * numbers separately. */ - SparsityPattern (const unsigned int n, - const unsigned int max_per_row); + SparsityPattern (const size_type n, + const size_type max_per_row); /** * Initialize a quadratic matrix. @@ -486,8 +501,8 @@ public: * @deprecated Use the constructor without the last argument since * it is ignored. */ - SparsityPattern (const unsigned int m, - const std::vector &row_lengths, + SparsityPattern (const size_type m, + const std::vector &row_lengths, const bool optimize_diagonal) DEAL_II_DEPRECATED; /** @@ -497,8 +512,8 @@ public: * @arg row_lengths possible number of nonzero entries for each row. This * vector must have one entry for each row. */ - SparsityPattern (const unsigned int m, - const std::vector &row_lengths); + SparsityPattern (const size_type m, + const std::vector &row_lengths); /** * Make a copy with extra off-diagonals. @@ -523,8 +538,8 @@ public: * compressed after this function finishes. */ SparsityPattern (const SparsityPattern &original, - const unsigned int max_per_row, - const unsigned int extra_off_diagonals); + const size_type max_per_row, + const size_type extra_off_diagonals); /** * Destructor. @@ -549,9 +564,9 @@ public: * @deprecated The last argument of this function is ignored. Use the * version of this function without the last argument. */ - void reinit (const unsigned int m, - const unsigned int n, - const unsigned int max_per_row, + void reinit (const size_type m, + const size_type n, + const size_type max_per_row, const bool optimize_diagonal) DEAL_II_DEPRECATED; /** @@ -562,9 +577,9 @@ public: * This function simply maps its operations to the other reinit * function. */ - void reinit (const unsigned int m, - const unsigned int n, - const unsigned int max_per_row); + void reinit (const size_type m, + const size_type n, + const size_type max_per_row); /** * Reallocate memory for a matrix of size m x n. The number of @@ -583,9 +598,9 @@ public: * @deprecated The last argument of this function is ignored. Use the * version of this function without the last argument. */ - void reinit (const unsigned int m, - const unsigned int n, - const std::vector &row_lengths, + void reinit (const size_type m, + const size_type n, + const std::vector &row_lengths, const bool optimize_diagonal) DEAL_II_DEPRECATED; /** @@ -602,9 +617,9 @@ public: * is true, diagonal elements are stored first in each row to allow * optimized access in relaxation methods of SparseMatrix. */ - void reinit (const unsigned int m, - const unsigned int n, - const std::vector &row_lengths); + void reinit (const size_type m, + const size_type n, + const std::vector &row_lengths); /** * Same as above, but with a VectorSlice argument instead. @@ -612,17 +627,17 @@ public: * @deprecated The last argument of this function is ignored. Use the * version of this function without the last argument. */ - void reinit (const unsigned int m, - const unsigned int n, - const VectorSlice > &row_lengths, + void reinit (const size_type m, + const size_type n, + const VectorSlice > &row_lengths, const bool optimize_diagonal) DEAL_II_DEPRECATED; /** * Same as above, but with a VectorSlice argument instead. */ - void reinit (const unsigned int m, - const unsigned int n, - const VectorSlice > &row_lengths); + void reinit (const size_type m, + const size_type n, + const VectorSlice > &row_lengths); /** * This function compresses the sparsity structure that this object @@ -718,8 +733,8 @@ public: * version of this function without the last argument. */ template - void copy_from (const unsigned int n_rows, - const unsigned int n_cols, + void copy_from (const size_type n_rows, + const size_type n_cols, const ForwardIterator begin, const ForwardIterator end, const bool optimize_diagonal) DEAL_II_DEPRECATED; @@ -801,8 +816,8 @@ public: * iterators that point to such pairs. */ template - void copy_from (const unsigned int n_rows, - const unsigned int n_cols, + void copy_from (const size_type n_rows, + const size_type n_cols, const ForwardIterator begin, const ForwardIterator end); @@ -867,8 +882,8 @@ public: * * If the entry already exists, nothing bad happens. */ - void add (const unsigned int i, - const unsigned int j); + void add (const size_type i, + const size_type j); /** * Add several nonzero entries to the specified matrix row. This function @@ -877,10 +892,10 @@ public: * If some of the entries already exist, nothing bad happens. */ template - void add_entries (const unsigned int row, - ForwardIterator begin, - ForwardIterator end, - const bool indices_are_sorted = false); + void add_entries (const size_type row, + ForwardIterator begin, + ForwardIterator end, + const bool indices_are_sorted = false); // @} /** @@ -914,7 +929,7 @@ public: * Note also the discussion in the general documentation of this class about * the order in which elements are accessed. */ - iterator begin (const unsigned int r) const; + iterator begin (const size_type r) const; /** * Final iterator of row r. It points to the first element past the @@ -924,7 +939,7 @@ public: * particular the case if it is the end iterator for the last row of a * matrix. */ - iterator end (const unsigned int r) const; + iterator end (const size_type r) const; /** * STL-like iterator with the first entry of row r. @@ -937,7 +952,7 @@ public: * @deprecated Use the iterators provided by the begin() and end() * functions instead. */ - row_iterator row_begin (const unsigned int r) const DEAL_II_DEPRECATED; + row_iterator row_begin (const size_type r) const DEAL_II_DEPRECATED; /** * Final iterator of row r. It points to the first element past the @@ -950,7 +965,7 @@ public: * @deprecated Use the iterators provided by the begin() and end() * functions instead. */ - row_iterator row_end (const unsigned int r) const DEAL_II_DEPRECATED; + row_iterator row_end (const size_type r) const DEAL_II_DEPRECATED; // @} /** @@ -973,7 +988,7 @@ public: * equals the number given to the constructor, while after compression, it * equals the maximum number of entries actually allocated by the user. */ - unsigned int max_entries_per_row () const; + size_type max_entries_per_row () const; /** * Compute the bandwidth of the matrix represented by this structure. The @@ -981,7 +996,7 @@ public: * represents a nonzero entry of the matrix. Consequently, the maximum * bandwidth a $n\times m$ matrix can have is $\max\{n-1,m-1\}$. */ - unsigned int bandwidth () const; + size_type bandwidth () const; /** * Return the number of nonzero elements of this matrix. Actually, it @@ -991,7 +1006,7 @@ public: * This function may only be called if the matrix struct is compressed. It * does not make too much sense otherwise anyway. */ - std::size_t n_nonzero_elements () const; + size_type n_nonzero_elements () const; /** * Return whether the structure is compressed or not. @@ -1002,18 +1017,18 @@ public: * Return number of rows of this matrix, which equals the dimension of the * image space. */ - unsigned int n_rows () const; + size_type n_rows () const; /** * Return number of columns of this matrix, which equals the dimension of * the range space. */ - unsigned int n_cols () const; + size_type n_cols () const; /** * Number of entries in a specific row. */ - unsigned int row_length (const unsigned int row) const; + size_type row_length (const size_type row) const; /** * Determine whether the matrix uses the special convention for quadratic @@ -1071,8 +1086,8 @@ public: * single row. In such cases, it is more efficient to use iterators over * the elements of the sparsity pattern or of the sparse matrix. */ - unsigned int operator() (const unsigned int i, - const unsigned int j) const; + size_type operator() (const size_type i, + const size_type j) const; /** * This is the inverse operation to operator()(): given a global index, find @@ -1085,14 +1100,14 @@ public: * If N is the number of rows of this matrix, then the complexity * of this function is log(N). */ - std::pair - matrix_position (const unsigned int global_index) const; + std::pair + matrix_position (const size_type global_index) const; /** * Check if a value at a certain position may be non-zero. */ - bool exists (const unsigned int i, - const unsigned int j) const; + bool exists (const size_type i, + const size_type j) const; /** * The index of a global matrix entry in its row. @@ -1101,8 +1116,8 @@ public: * with respect to the total field, but only with respect to the row * j. */ - unsigned int row_position(const unsigned int i, - const unsigned int j) const; + size_type row_position(const size_type i, + const size_type j) const; /** * Access to column number field. Return the column number of the @@ -1115,8 +1130,8 @@ public: * i.e. column_number(row,i) < * column_number(row,i+1). */ - unsigned int column_number (const unsigned int row, - const unsigned int index) const; + size_type column_number (const size_type row, + const size_type index) const; // @} @@ -1268,7 +1283,7 @@ public: * yourself, you should also rename this function to avoid programs relying * on outdated information! */ - const unsigned int *get_column_numbers () const DEAL_II_DEPRECATED; + const size_type *get_column_numbers () const DEAL_II_DEPRECATED; BOOST_SERIALIZATION_SPLIT_MEMBER() /** @addtogroup Exceptions @@ -1326,24 +1341,24 @@ private: * be larger than #rows and in this case #rowstart has more elements than * are used. */ - unsigned int max_dim; + size_type max_dim; /** * Number of rows that this sparsity structure shall represent. */ - unsigned int rows; + size_type rows; /** * Number of columns that this sparsity structure shall represent. */ - unsigned int cols; + size_type cols; /** * Size of the actually allocated array #colnums. Here, the same applies as * for the #rowstart array, i.e. it may be larger than the actually used * part of the array. */ - std::size_t max_vec_len; + size_type max_vec_len; /** * Maximum number of elements per row. This is set to the value given to the @@ -1352,7 +1367,7 @@ private: * reinit versions are called. Its value is more or less meaningless after * compress() has been called. */ - unsigned int max_row_length; + size_type max_row_length; /** * Array which hold for each row which is the first element in #colnums @@ -1391,7 +1406,7 @@ private: * sorted, such that finding whether an element exists and determining its * position can be done by a binary search. */ - unsigned int *colnums; + size_type *colnums; /** * Store whether the compress() function was called for this object. @@ -1433,8 +1448,8 @@ namespace SparsityPatternIterators inline Accessor:: Accessor (const SparsityPattern *sparsity_pattern, - const unsigned int r, - const unsigned int i) + const size_type r, + const size_type i) : sparsity_pattern(sparsity_pattern), index_within_sparsity(sparsity_pattern->rowstart[r]+i) @@ -1472,7 +1487,7 @@ namespace SparsityPatternIterators inline - unsigned int + size_type Accessor::row() const { Assert (is_valid_entry() == true, ExcInvalidIterator()); @@ -1486,7 +1501,7 @@ namespace SparsityPatternIterators inline - unsigned int + size_type Accessor::column() const { Assert (is_valid_entry() == true, ExcInvalidIterator()); @@ -1496,7 +1511,7 @@ namespace SparsityPatternIterators inline - unsigned int + size_type Accessor::index() const { Assert (is_valid_entry() == true, ExcInvalidIterator()); @@ -1541,8 +1556,8 @@ namespace SparsityPatternIterators inline Iterator::Iterator (const SparsityPattern *sparsity_pattern, - const unsigned int r, - const unsigned int i) + const size_type r, + const size_type i) : accessor(sparsity_pattern, sparsity_pattern->rowstart[r]+i) {} @@ -1653,7 +1668,7 @@ SparsityPattern::end () const inline SparsityPattern::iterator -SparsityPattern::begin (const unsigned int r) const +SparsityPattern::begin (const size_type r) const { Assert (r inline void -SparsityPattern::save (Archive &ar, const unsigned int) const +SparsityPattern::save (Archive &ar, const size_type) const { // forward to serialization function in the base class. ar &static_cast(*this); @@ -1802,15 +1817,15 @@ SparsityPattern::save (Archive &ar, const unsigned int) const template inline void -SparsityPattern::load (Archive &ar, const unsigned int) +SparsityPattern::load (Archive &ar, const size_type) { // forward to serialization function in the base class. ar &static_cast(*this); ar &max_dim &rows &cols &max_vec_len &max_row_length &compressed &store_diagonal_first_in_row; - rowstart = new std::size_t [max_dim + 1]; - colnums = new unsigned int [max_vec_len]; + rowstart = new size_type [max_dim + 1]; + colnums = new size_type [max_vec_len]; ar &boost::serialization::make_array(rowstart, max_dim + 1); ar &boost::serialization::make_array(colnums, max_vec_len); @@ -1832,11 +1847,11 @@ SparsityPattern::operator == (const SparsityPattern &sp2) const store_diagonal_first_in_row != sp2.store_diagonal_first_in_row) return false; - for (unsigned int i = 0; i < rows+1; ++i) + for (size_type i = 0; i < rows+1; ++i) if (rowstart[i] != sp2.rowstart[i]) return false; - for (unsigned int i = 0; i < rowstart[rows]; ++i) + for (size_type i = 0; i < rowstart[rows]; ++i) if (colnums[i] != sp2.colnums[i]) return false; @@ -1848,10 +1863,15 @@ SparsityPattern::operator == (const SparsityPattern &sp2) const namespace internal { namespace SparsityPatternTools - { + { + /** + * Declare type for container size. + */ + typedef types::global_dof_index size_type; + inline - unsigned int - get_column_index_from_iterator (const unsigned int i) + size_type + get_column_index_from_iterator (const size_type i) { return i; } @@ -1860,8 +1880,8 @@ namespace internal template inline - unsigned int - get_column_index_from_iterator (const std::pair &i) + size_type + get_column_index_from_iterator (const std::pair &i) { return i.first; } @@ -1870,8 +1890,8 @@ namespace internal template inline - unsigned int - get_column_index_from_iterator (const std::pair &i) + size_type + get_column_index_from_iterator (const std::pair &i) { return i.first; } @@ -1882,8 +1902,8 @@ namespace internal template void -SparsityPattern::copy_from (const unsigned int n_rows, - const unsigned int n_cols, +SparsityPattern::copy_from (const size_type n_rows, + const size_type n_cols, const ForwardIterator begin, const ForwardIterator end, const bool) @@ -1895,12 +1915,12 @@ SparsityPattern::copy_from (const unsigned int n_rows, template void -SparsityPattern::copy_from (const unsigned int n_rows, - const unsigned int n_cols, +SparsityPattern::copy_from (const size_type n_rows, + const size_type n_cols, const ForwardIterator begin, const ForwardIterator end) { - Assert (static_cast(std::distance (begin, end)) == n_rows, + Assert (static_cast(std::distance (begin, end)) == n_rows, ExcIteratorRange (std::distance (begin, end), n_rows)); // first determine row lengths for each row. if the matrix is quadratic, @@ -1908,7 +1928,7 @@ SparsityPattern::copy_from (const unsigned int n_rows, // is not yet present. as we have to call compress anyway later on, don't // bother to check whether that diagonal entry is in a certain row or not const bool is_square = (n_rows == n_cols); - std::vector row_lengths; + std::vector row_lengths; row_lengths.reserve(n_rows); for (ForwardIterator i=begin; i!=end; ++i) row_lengths.push_back (std::distance (i->begin(), i->end()) @@ -1921,15 +1941,15 @@ SparsityPattern::copy_from (const unsigned int n_rows, // // for use in the inner loop, we define a typedef to the type of the inner // iterators - unsigned int row = 0; + size_type row = 0; typedef typename std::iterator_traits::value_type::const_iterator inner_iterator; for (ForwardIterator i=begin; i!=end; ++i, ++row) { - unsigned int *cols = &colnums[rowstart[row]] + (is_square ? 1 : 0); + size_type *cols = &colnums[rowstart[row]] + (is_square ? 1 : 0); const inner_iterator end_of_row = i->end(); for (inner_iterator j=i->begin(); j!=end_of_row; ++j) { - const unsigned int col + const size_type col = internal::SparsityPatternTools::get_column_index_from_iterator(*j); Assert (col < n_cols, ExcIndexRange(col,0,n_cols)); diff --git a/deal.II/include/deal.II/lac/sparsity_tools.h b/deal.II/include/deal.II/lac/sparsity_tools.h index e65cd32405..5f572a16f5 100644 --- a/deal.II/include/deal.II/lac/sparsity_tools.h +++ b/deal.II/include/deal.II/lac/sparsity_tools.h @@ -41,6 +41,11 @@ class SparsityPattern; */ namespace SparsityTools { + /** + * Declare type for container size. + */ + typedef types::global_dof_index size_type; + /** * Use the METIS partitioner to generate * a partitioning of the degrees of @@ -191,8 +196,8 @@ namespace SparsityTools */ void reorder_Cuthill_McKee (const SparsityPattern &sparsity, - std::vector &new_indices, - const std::vector &starting_indices = std::vector()); + std::vector &new_indices, + const std::vector &starting_indices = std::vector()); #ifdef DEAL_II_COMPILER_SUPPORTS_MPI @@ -237,7 +242,7 @@ namespace SparsityTools */ template void distribute_sparsity_pattern(CSP_t &csp, - const std::vector &rows_per_cpu, + const std::vector &rows_per_cpu, const MPI_Comm &mpi_comm, const IndexSet &myrange); #endif diff --git a/deal.II/source/grid/grid_generator.cc b/deal.II/source/grid/grid_generator.cc index 1c59e4b543..fa4125060e 100644 --- a/deal.II/source/grid/grid_generator.cc +++ b/deal.II/source/grid/grid_generator.cc @@ -182,7 +182,7 @@ void GridGenerator::hyper_cube (Triangulation &tria, void GridGenerator::moebius ( Triangulation<3> &tria, - const unsigned int n_cells, + const size_type n_cells, const unsigned int n_rotations, const double R, const double r) @@ -197,7 +197,7 @@ GridGenerator::moebius ( double beta_step=n_rotations*numbers::PI/2.0/n_cells; double alpha_step=2.0*numbers::PI/n_cells; - for (unsigned int i=0; i > cells (n_cells); - for (unsigned int i=0; i &tria, template void GridGenerator::subdivided_parallelepiped (Triangulation &tria, - const unsigned int n_subdivisions, + const size_type n_subdivisions, const Point (&corners) [dim], const bool colorize) { // Equalise number of subdivisions in each dim-direction, heir // validity will be checked later - unsigned int (n_subdivisions_) [dim]; + size_type (n_subdivisions_) [dim]; for (unsigned int i=0; i &tria, template void GridGenerator::subdivided_parallelepiped (Triangulation &tria, - const unsigned int ( n_subdivisions) [dim], + const size_type ( n_subdivisions) [dim], const Point (&corners) [dim], const bool colorize) { @@ -525,20 +525,20 @@ GridGenerator::subdivided_parallelepiped (Triangulation &tria, switch (dim) { case 1: - for (unsigned int x=0; x<=n_subdivisions[0]; ++x) + for (size_type x=0; x<=n_subdivisions[0]; ++x) points.push_back (Point (x*delta[0])); break; case 2: - for (unsigned int y=0; y<=n_subdivisions[1]; ++y) - for (unsigned int x=0; x<=n_subdivisions[0]; ++x) + for (size_type y=0; y<=n_subdivisions[1]; ++y) + for (size_type x=0; x<=n_subdivisions[0]; ++x) points.push_back (Point (x*delta[0] + y*delta[1])); break; case 3: - for (unsigned int z=0; z<=n_subdivisions[2]; ++z) - for (unsigned int y=0; y<=n_subdivisions[1]; ++y) - for (unsigned int x=0; x<=n_subdivisions[0]; ++x) + for (size_type z=0; z<=n_subdivisions[2]; ++z) + for (size_type y=0; y<=n_subdivisions[1]; ++y) + for (size_type x=0; x<=n_subdivisions[0]; ++x) points.push_back (Point (x*delta[0] + y*delta[1] + z*delta[2])); break; @@ -547,7 +547,7 @@ GridGenerator::subdivided_parallelepiped (Triangulation &tria, } // Prepare cell data - unsigned int n_cells = 1; + size_type n_cells = 1; for (unsigned int i=0; i > cells (n_cells); @@ -556,7 +556,7 @@ GridGenerator::subdivided_parallelepiped (Triangulation &tria, switch (dim) { case 1: - for (unsigned int x=0; x &tria, case 2: { // Shorthand - const unsigned int n_dy = n_subdivisions[1]; - const unsigned int n_dx = n_subdivisions[0]; + const size_type n_dy = n_subdivisions[1]; + const size_type n_dx = n_subdivisions[0]; - for (unsigned int y=0; y &tria, case 3: { // Shorthand - const unsigned int n_dz = n_subdivisions[2]; - const unsigned int n_dy = n_subdivisions[1]; - const unsigned int n_dx = n_subdivisions[0]; + const size_type n_dz = n_subdivisions[2]; + const size_type n_dy = n_subdivisions[1]; + const size_type n_dx = n_subdivisions[0]; - for (unsigned int z=0; z (p1[0]+x)); @@ -967,10 +967,10 @@ GridGenerator::subdivided_hyper_rectangle( case 2: { double y=0; - for (unsigned int j=0; ; ++j) + for (size_type j=0; ; ++j) { double x=0; - for (unsigned int i=0; ; ++i) + for (size_type i=0; ; ++i) { points.push_back (Point (p1[0]+x, p1[1]+y)); @@ -991,13 +991,13 @@ GridGenerator::subdivided_hyper_rectangle( case 3: { double z=0; - for (unsigned int k=0; ; ++k) + for (size_type k=0; ; ++k) { double y=0; - for (unsigned int j=0; ; ++j) + for (size_type j=0; ; ++j) { double x=0; - for (unsigned int i=0; ; ++i) + for (size_type i=0; ; ++i) { points.push_back (Point (p1[0]+x, p1[1]+y, @@ -1034,7 +1034,7 @@ GridGenerator::subdivided_hyper_rectangle( case 1: { cells.resize (step_sizes[0].size()); - for (unsigned int x=0; x::max(); - for (unsigned int i=0; i= 0, ExcInvalidRepetitions(-1)); delta = std::min (delta, spacing[0][i]); @@ -1145,20 +1145,20 @@ GridGenerator::subdivided_hyper_rectangle ( // generate the necessary points std::vector > points; double ax = p[0]; - for (unsigned int x=0; x<=n_cells; ++x) + for (size_type x=0; x<=n_cells; ++x) { points.push_back (Point<1> (ax)); if (x > cells(n_val_cells); - unsigned int id = 0; - for (unsigned int x=0; x repetitions(2); - unsigned int n_cells = 1; + std::vector repetitions(2); + size_type n_cells = 1; double delta = std::numeric_limits::max(); for (unsigned int i=0; i<2; i++) { repetitions[i] = spacing[i].size(); n_cells *= repetitions[i]; - for (unsigned int j=0; j= 0, ExcInvalidRepetitions(-1)); delta = std::min (delta, spacing[i][j]); @@ -1210,10 +1210,10 @@ GridGenerator::subdivided_hyper_rectangle ( // generate the necessary points std::vector > points; double ay = p[1]; - for (unsigned int y=0; y<=repetitions[1]; ++y) + for (size_type y=0; y<=repetitions[1]; ++y) { double ax = p[0]; - for (unsigned int x=0; x<=repetitions[0]; ++x) + for (size_type x=0; x<=repetitions[0]; ++x) { points.push_back (Point<2> (ax,ay)); if (x > cells(n_val_cells); - unsigned int id = 0; - for (unsigned int y=0; y repetitions(dim); - unsigned int n_cells = 1; + std::vector repetitions(dim); + size_type n_cells = 1; double delta = std::numeric_limits::max(); for (unsigned int i=0; i= 0, ExcInvalidRepetitions(-1)); delta = std::min (delta, spacing[i][j]); @@ -1310,13 +1310,13 @@ GridGenerator::subdivided_hyper_rectangle ( // generate the necessary points std::vector > points; double az = p[2]; - for (unsigned int z=0; z<=repetitions[2]; ++z) + for (size_type z=0; z<=repetitions[2]; ++z) { double ay = p[1]; - for (unsigned int y=0; y<=repetitions[1]; ++y) + for (size_type y=0; y<=repetitions[1]; ++y) { double ax = p[0]; - for (unsigned int x=0; x<=repetitions[0]; ++x) + for (size_type x=0; x<=repetitions[0]; ++x) { points.push_back (Point (ax,ay,az)); if (x > cells(n_val_cells); - unsigned int id = 0; - const unsigned int n_x = (repetitions[0]+1); - const unsigned int n_xy = (repetitions[0]+1)*(repetitions[1]+1); - for (unsigned int z=0; z &, const Point<1> &, const double, const double, - const unsigned int, + const size_type , const bool) { Assert (false, ExcNotImplemented()); @@ -1554,8 +1554,8 @@ void GridGenerator::cylinder_shell (Triangulation<1> &, const double, const double, const double, - const unsigned int, - const unsigned int) + const size_type , + const size_type ) { Assert (false, ExcNotImplemented()); } @@ -1577,7 +1577,7 @@ GridGenerator::half_hyper_shell (Triangulation<1> &, const Point<1> &, const double, const double, - const unsigned int, + const size_type , const bool) { Assert (false, ExcNotImplemented()); @@ -1588,7 +1588,7 @@ void GridGenerator::quarter_hyper_shell (Triangulation<1> &, const Point<1> &, const double, const double, - const unsigned int, + const size_type , const bool) { Assert (false, ExcNotImplemented()); @@ -1834,11 +1834,11 @@ GridGenerator::colorize_hyper_shell ( template <> -void GridGenerator::hyper_shell (Triangulation<2> &tria, - const Point<2> ¢er, - const double inner_radius, - const double outer_radius, - const unsigned int n_cells, +void GridGenerator::hyper_shell (Triangulation<2> &tria, + const Point<2> ¢er, + const double inner_radius, + const double outer_radius, + const size_type n_cells, const bool colorize) { Assert ((inner_radius > 0) && (inner_radius < outer_radius), @@ -1855,11 +1855,11 @@ void GridGenerator::hyper_shell (Triangulation<2> &tria, // radial extent (which is the // difference between the two // radii) - const unsigned int N = (n_cells == 0 ? - static_cast - (std::ceil((2*pi* (outer_radius + inner_radius)/2) / - (outer_radius - inner_radius))) : - n_cells); + const size_type N = (n_cells == 0 ? + static_cast + (std::ceil((2*pi* (outer_radius + inner_radius)/2) / + (outer_radius - inner_radius))) : + n_cells); // set up N vertices on the // outer and N vertices on @@ -1868,7 +1868,7 @@ void GridGenerator::hyper_shell (Triangulation<2> &tria, // outer one, and all are // numbered counter-clockwise std::vector > vertices(2*N); - for (unsigned int i=0; i( std::cos(2*pi * i/N), std::sin(2*pi * i/N)) * outer_radius; @@ -1880,7 +1880,7 @@ void GridGenerator::hyper_shell (Triangulation<2> &tria, std::vector > cells (N, CellData<2>()); - for (unsigned int i=0; i &, const double, const double, const double, - const unsigned int, - const unsigned int) + const size_type, + const size_type) { Assert (false, ExcNotImplemented()); } @@ -2009,11 +2009,11 @@ GridGenerator::half_hyper_ball (Triangulation<2> &tria, // Implementation for 2D only template <> void -GridGenerator::half_hyper_shell (Triangulation<2> &tria, - const Point<2> ¢er, - const double inner_radius, - const double outer_radius, - const unsigned int n_cells, +GridGenerator::half_hyper_shell (Triangulation<2> &tria, + const Point<2> ¢er, + const double inner_radius, + const double outer_radius, + const size_type n_cells, const bool colorize) { Assert ((inner_radius > 0) && (inner_radius < outer_radius), @@ -2029,11 +2029,11 @@ GridGenerator::half_hyper_shell (Triangulation<2> &tria, // radial extent (which is the // difference between the two // radii) - const unsigned int N = (n_cells == 0 ? - static_cast - (std::ceil((pi* (outer_radius + inner_radius)/2) / - (outer_radius - inner_radius))) : - n_cells); + const size_type N = (n_cells == 0 ? + static_cast + (std::ceil((pi* (outer_radius + inner_radius)/2) / + (outer_radius - inner_radius))) : + n_cells); // set up N+1 vertices on the // outer and N+1 vertices on @@ -2042,7 +2042,7 @@ GridGenerator::half_hyper_shell (Triangulation<2> &tria, // outer one, and all are // numbered counter-clockwise std::vector > vertices(2*(N+1)); - for (unsigned int i=0; i<=N; ++i) + for (size_type i=0; i<=N; ++i) { // enforce that the x-coordinates // of the first and last point of @@ -2063,7 +2063,7 @@ GridGenerator::half_hyper_shell (Triangulation<2> &tria, std::vector > cells (N, CellData<2>()); - for (unsigned int i=0; i &tria, template <> -void GridGenerator::quarter_hyper_shell (Triangulation<2> &tria, - const Point<2> ¢er, - const double inner_radius, - const double outer_radius, - const unsigned int n_cells, +void GridGenerator::quarter_hyper_shell (Triangulation<2> &tria, + const Point<2> ¢er, + const double inner_radius, + const double outer_radius, + const size_type n_cells, const bool colorize) { Assert ((inner_radius > 0) && (inner_radius < outer_radius), @@ -2110,11 +2110,11 @@ void GridGenerator::quarter_hyper_shell (Triangulation<2> &tria, // radial extent (which is the // difference between the two // radii) - const unsigned int N = (n_cells == 0 ? - static_cast - (std::ceil((pi* (outer_radius + inner_radius)/4) / - (outer_radius - inner_radius))) : - n_cells); + const size_type N = (n_cells == 0 ? + static_cast + (std::ceil((pi* (outer_radius + inner_radius)/4) / + (outer_radius - inner_radius))) : + n_cells); // set up N+1 vertices on the // outer and N+1 vertices on @@ -2123,7 +2123,7 @@ void GridGenerator::quarter_hyper_shell (Triangulation<2> &tria, // outer one, and all are // numbered counter-clockwise std::vector > vertices(2*(N+1)); - for (unsigned int i=0; i<=N; ++i) + for (size_type i=0; i<=N; ++i) { // enforce that the x-coordinates // of the last point is exactly @@ -2143,7 +2143,7 @@ void GridGenerator::quarter_hyper_shell (Triangulation<2> &tria, std::vector > cells (N, CellData<2>()); - for (unsigned int i=0; i &triangulation, const double half_length) { // Determine number of cells and vertices - const unsigned int - n_cells = static_cast(std::floor (half_length / + const size_type + n_cells = static_cast(std::floor (half_length / std::max (radius_0, radius_1) + 0.5)); - const unsigned int n_vertices = 4 * (n_cells + 1); + const size_type n_vertices = 4 * (n_cells + 1); std::vector > vertices_tmp(n_vertices); vertices_tmp[0] = Point<3> (-half_length, 0, -radius_0); @@ -2317,7 +2317,7 @@ void GridGenerator::truncated_cone (Triangulation<3> &triangulation, const double dx = 2 * half_length / n_cells; - for (unsigned int i = 0; i < n_cells; ++i) + for (size_type i = 0; i < n_cells; ++i) { vertices_tmp[4 * (i + 1)] = vertices_tmp[4 * i] + @@ -2337,13 +2337,13 @@ void GridGenerator::truncated_cone (Triangulation<3> &triangulation, vertices_tmp.end()); Table<2,unsigned int> cell_vertices(n_cells,GeometryInfo<3>::vertices_per_cell); - for (unsigned int i = 0; i < n_cells; ++i) + for (size_type i = 0; i < n_cells; ++i) for (unsigned int j = 0; j < GeometryInfo<3>::vertices_per_cell; ++j) cell_vertices[i][j] = 4 * i + j; std::vector > cells (n_cells, CellData<3> ()); - for (unsigned int i = 0; i < n_cells; ++i) + for (size_type i = 0; i < n_cells; ++i) { for (unsigned int j = 0; j < GeometryInfo<3>::vertices_per_cell; ++j) cells[i].vertices[j] = cell_vertices[i][j]; @@ -3243,12 +3243,12 @@ void GridGenerator::quarter_hyper_shell (Triangulation<3> &tria, // Implementation for 3D only template <> -void GridGenerator::cylinder_shell (Triangulation<3> &tria, - const double length, - const double inner_radius, - const double outer_radius, - const unsigned int n_radial_cells, - const unsigned int n_axial_cells) +void GridGenerator::cylinder_shell (Triangulation<3> &tria, + const double length, + const double inner_radius, + const double outer_radius, + const size_type n_radial_cells, + const size_type n_axial_cells) { Assert ((inner_radius > 0) && (inner_radius < outer_radius), ExcInvalidRadii ()); @@ -3264,16 +3264,16 @@ void GridGenerator::cylinder_shell (Triangulation<3> &tria, // radial extent (which is the // difference between the two // radii) - const unsigned int N_r = (n_radial_cells == 0 ? - static_cast - (std::ceil((2*pi* (outer_radius + inner_radius)/2) / - (outer_radius - inner_radius))) : - n_radial_cells); - const unsigned int N_z = (n_axial_cells == 0 ? - static_cast - (std::ceil (length / - (2*pi*(outer_radius + inner_radius)/2/N_r))) : - n_axial_cells); + const size_type N_r = (n_radial_cells == 0 ? + static_cast + (std::ceil((2*pi* (outer_radius + inner_radius)/2) / + (outer_radius - inner_radius))) : + n_radial_cells); + const size_type N_z = (n_axial_cells == 0 ? + static_cast + (std::ceil (length / + (2*pi*(outer_radius + inner_radius)/2/N_r))) : + n_axial_cells); // set up N vertices on the // outer and N vertices on @@ -3282,7 +3282,7 @@ void GridGenerator::cylinder_shell (Triangulation<3> &tria, // outer one, and all are // numbered counter-clockwise std::vector > vertices_2d(2*N_r); - for (unsigned int i=0; i( std::cos(2*pi * i/N_r), std::sin(2*pi * i/N_r)) * outer_radius; @@ -3291,8 +3291,8 @@ void GridGenerator::cylinder_shell (Triangulation<3> &tria, std::vector > vertices_3d; vertices_3d.reserve (2*N_r*(N_z+1)); - for (unsigned int j=0; j<=N_z; ++j) - for (unsigned int i=0; i<2*N_r; ++i) + for (size_type j=0; j<=N_z; ++j) + for (size_type i=0; i<2*N_r; ++i) { const Point<3> v (vertices_2d[i][0], vertices_2d[i][1], @@ -3302,8 +3302,8 @@ void GridGenerator::cylinder_shell (Triangulation<3> &tria, std::vector > cells (N_r*N_z, CellData<3>()); - for (unsigned int j=0; j &triangulation_1, // throw out duplicated vertices from the two meshes // and create the triangulation SubCellData subcell_data; - std::vector considered_vertices; + std::vector considered_vertices; GridTools::delete_duplicated_vertices (vertices, cells, subcell_data, considered_vertices); result.clear (); result.create_triangulation (vertices, cells, subcell_data); @@ -3379,7 +3379,7 @@ merge_triangulations (const Triangulation &triangulation_1, void GridGenerator:: extrude_triangulation(const Triangulation<2, 2> & input, - const unsigned int n_slices, + const size_type n_slices, const double height, Triangulation<3,3> &result) { @@ -3393,9 +3393,9 @@ extrude_triangulation(const Triangulation<2, 2> & input, std::vector > cells; cells.reserve((n_slices-1)*input.n_active_cells()); - for (unsigned int slice=0;slice & v = input.get_vertices()[i]; @@ -3408,7 +3408,7 @@ extrude_triangulation(const Triangulation<2, 2> & input, for (Triangulation<2,2>::cell_iterator cell = input.begin(); cell != input.end(); ++cell) { - for (unsigned int slice=0;slice this_cell; for (unsigned int v=0; v::vertices_per_cell; ++v) @@ -3436,7 +3436,7 @@ extrude_triangulation(const Triangulation<2, 2> & input, { quad.boundary_id = cell->face(f)->boundary_indicator(); bid = std::max(bid, quad.boundary_id); - for (unsigned int slice=0;sliceface(f)->vertex_index(0)+slice*input.n_vertices(); quad.vertices[1] = cell->face(f)->vertex_index(1)+slice*input.n_vertices(); @@ -3480,10 +3480,10 @@ extrude_triangulation(const Triangulation<2, 2> & input, // this is not necessary here as this is an internal only function. inline void GridGenerator::laplace_solve (const SparseMatrix &S, - const std::map &m, + const std::map &m, Vector &u) { - const unsigned int n_dofs=S.n(); + const size_type n_dofs=S.n(); FilteredMatrix > SF (S); PreconditionJacobi > prec; prec.initialize(S, 1.2); @@ -3504,7 +3504,7 @@ void GridGenerator::laplace_solve (const SparseMatrix &S, // Implementation for 1D only template <> void GridGenerator::laplace_transformation (Triangulation<1> &, - const std::map > &) + const std::map > &) { Assert(false, ExcNotImplemented()); } @@ -3513,7 +3513,7 @@ void GridGenerator::laplace_transformation (Triangulation<1> &, // Implementation for dimensions except 1 template void GridGenerator::laplace_transformation (Triangulation &tria, - const std::map > &new_points) + const std::map > &new_points) { // first provide everything that is // needed for solving a Laplace @@ -3541,9 +3541,9 @@ void GridGenerator::laplace_transformation (Triangulation &tria, // set up the boundary values for // the laplace problem - std::vector > m(dim); - typename std::map >::const_iterator map_iter; - typename std::map >::const_iterator map_end=new_points.end(); + std::vector > m(dim); + typename std::map >::const_iterator map_iter; + typename std::map >::const_iterator map_end=new_points.end(); // fill these maps using the data // given by new_points @@ -3560,12 +3560,12 @@ void GridGenerator::laplace_transformation (Triangulation &tria, for (unsigned int vertex_no=0; vertex_no::vertices_per_face; ++vertex_no) { - const unsigned int vertex_index=face->vertex_index(vertex_no); + const size_type vertex_index=face->vertex_index(vertex_no); map_iter=new_points.find(vertex_index); if (map_iter!=map_end) for (unsigned int i=0; i ( + m[i].insert(std::pair ( face->vertex_dof_index(vertex_no, 0), map_iter->second(i))); } } @@ -3588,11 +3588,11 @@ void GridGenerator::laplace_transformation (Triangulation &tria, // points of the triangulation // according to the computed values for (cell=dof_handler.begin_active(); cell!=endc; ++cell) - for (unsigned int vertex_no=0; + for (size_type vertex_no=0; vertex_no::vertices_per_cell; ++vertex_no) { Point &v=cell->vertex(vertex_no); - const unsigned int dof_index=cell->vertex_dof_index(vertex_no, 0); + const size_type dof_index=cell->vertex_dof_index(vertex_no, 0); for (unsigned int i=0; i &, const double, const double, const double, - const unsigned int, + const size_type, bool) { Assert(false, ExcNotImplemented()); @@ -3619,7 +3619,7 @@ GridGenerator::hyper_cube_with_cylindrical_hole (Triangulation<2> &triangulation const double inner_radius, const double outer_radius, const double, // width, - const unsigned int, // width_repetition, + const size_type, // width_repetition, bool colorize) { const int dim = 2; @@ -3643,7 +3643,7 @@ GridGenerator::hyper_cube_with_cylindrical_hole (Triangulation<2> &triangulation { for (unsigned int v=0; v < GeometryInfo::vertices_per_face; ++v) { - unsigned int vv = cell->face(f)->vertex_index(v); + size_type vv = cell->face(f)->vertex_index(v); if (treated_vertices[vv] == false) { treated_vertices[vv] = true; @@ -3706,7 +3706,7 @@ void GridGenerator::hyper_cube_with_cylindrical_hole(Triangulation<3> &triangula const double inner_radius, const double outer_radius, const double L, - const unsigned int Nz, + const size_type Nz, bool colorize) { const int dim = 3; @@ -3733,11 +3733,11 @@ void GridGenerator::hyper_cube_with_cylindrical_hole(Triangulation<3> &triangula { for (unsigned int v=0; v < GeometryInfo::vertices_per_face; ++v) { - unsigned int vv = cell->face(f)->vertex_index(v); + size_type vv = cell->face(f)->vertex_index(v); if (treated_vertices[vv] == false) { treated_vertices[vv] = true; - for (unsigned int i=0; i<=Nz; ++i) + for (size_type i=0; i<=Nz; ++i) { double d = ((double) i)*L/((double) Nz); switch (vv-i*16) diff --git a/deal.II/source/lac/slepc_solver.cc b/deal.II/source/lac/slepc_solver.cc index fc3996e06e..2f6637ae38 100644 --- a/deal.II/source/lac/slepc_solver.cc +++ b/deal.II/source/lac/slepc_solver.cc @@ -95,7 +95,7 @@ namespace SLEPcWrappers } void - SolverBase::solve (const unsigned int n_eigenvectors, unsigned int *n_converged) + SolverBase::solve (const size_type n_eigenvectors, size_type *n_converged) { int ierr; @@ -204,7 +204,7 @@ namespace SLEPcWrappers } void - SolverBase::get_eigenpair (const unsigned int index, + SolverBase::get_eigenpair (const size_type index, #ifndef PETSC_USE_COMPLEX double &kr, #else diff --git a/deal.II/source/lac/sparse_direct.cc b/deal.II/source/lac/sparse_direct.cc index 8585f4cba4..c585b15296 100644 --- a/deal.II/source/lac/sparse_direct.cc +++ b/deal.II/source/lac/sparse_direct.cc @@ -49,16 +49,18 @@ namespace HSL { namespace MA27 { + typedef types::global_dof_index size_type; + extern "C" - void ma27ad_ (const unsigned int *, - const unsigned int *, - const unsigned int *, - const unsigned int *, - unsigned int *, - const unsigned int *, - unsigned int *, - unsigned int *, - unsigned int *, + void ma27ad_ (const size_type *, + const size_type *, + const size_type *, + const size_type *, + size_type *, + const size_type *, + size_type *, + size_type *, + size_type *, int *) { AssertThrow (false, @@ -69,18 +71,18 @@ namespace HSL extern "C" - void ma27bd_ (const unsigned int *, - const unsigned int *, - const unsigned int *, - const unsigned int *, + void ma27bd_ (const size_type *, + const size_type *, + const size_type *, + const size_type *, double *, - const unsigned int *, - unsigned int *, - const unsigned int *, - const unsigned int *, - const unsigned int *, - unsigned int *, - unsigned int *, + const size_type *, + size_type *, + const size_type *, + const size_type *, + const size_type *, + size_type *, + size_type *, int *) { AssertThrow (false, @@ -91,16 +93,16 @@ namespace HSL extern "C" - void ma27cd_ (const unsigned int *, + void ma27cd_ (const size_type *, const double *, - const unsigned int *, - const unsigned int *, - const unsigned int *, + const size_type *, + const size_type *, + const size_type *, double *, - const unsigned int *, + const size_type *, double *, - const unsigned int *, - const unsigned int *) + const size_type *, + const size_type *) { AssertThrow (false, ExcMessage("You can only use the HSL functions after putting " @@ -109,7 +111,7 @@ namespace HSL } - extern "C" void ma27x1_ (unsigned int *) + extern "C" void ma27x1_ (size_type *) { AssertThrow (false, ExcMessage("You can only use the HSL functions after putting " @@ -118,7 +120,7 @@ namespace HSL } - extern "C" void ma27x2_ (unsigned int *) + extern "C" void ma27x2_ (size_type *) { AssertThrow (false, ExcMessage("You can only use the HSL functions after putting " @@ -127,7 +129,7 @@ namespace HSL } - extern "C" void ma27x3_ (const unsigned int *) + extern "C" void ma27x3_ (const size_type *) { AssertThrow (false, ExcMessage("You can only use the HSL functions after putting " @@ -144,9 +146,11 @@ namespace HSL { namespace MA47 { + typedef types::global_dof_index size_type; + extern "C" void ma47id_ (double *, - unsigned int *) + size_type *) { AssertThrow (false, ExcMessage("You can only use the HSL functions after putting " @@ -156,14 +160,14 @@ namespace HSL extern "C" - void ma47ad_ (const unsigned int *, - const unsigned int *, - unsigned int *, - unsigned int *, - unsigned int *, - const unsigned int *, - unsigned int *, - const unsigned int *, + void ma47ad_ (const size_type *, + const size_type *, + size_type *, + size_type *, + size_type *, + const size_type *, + size_type *, + const size_type *, double *, int *) { @@ -175,17 +179,17 @@ namespace HSL extern "C" - void ma47bd_ (const unsigned int *, - const unsigned int *, - const unsigned int *, + void ma47bd_ (const size_type *, + const size_type *, + const size_type *, double *, - const unsigned int *, - unsigned int *, - const unsigned int *, - const unsigned int *, + const size_type *, + size_type *, + const size_type *, + const size_type *, const double *, - const unsigned int *, - unsigned int *, + const size_type *, + size_type *, double *, int *) { @@ -197,15 +201,15 @@ namespace HSL extern "C" - void ma47cd_ (const unsigned int *, + void ma47cd_ (const size_type *, const double *, - const unsigned int *, - const unsigned int *, - const unsigned int *, + const size_type *, + const size_type *, + const size_type *, double *, double *, - unsigned int *, - const unsigned int *) + size_type *, + const size_type *) { AssertThrow (false, ExcMessage("You can only use the HSL functions after putting " @@ -293,7 +297,7 @@ struct SparseDirectMA27::DetachedModeData const std::size_t N, const char * /*debug_info*/) const { - unsigned int count = 0; + size_type count = 0; while (count < sizeof(T)*N) { // repeat writing until @@ -332,7 +336,7 @@ struct SparseDirectMA27::DetachedModeData const std::size_t N, const char * /*debug_info*/) const { - unsigned int count = 0; + size_type count = 0; while (count < sizeof(T)*N) { int ret = -1; @@ -532,19 +536,19 @@ SparseDirectMA27::initialize (const SparsityPattern &sp) // requested if (suppress_output) { - const unsigned int LP = 0; + const size_type LP = 0; call_ma27x3 (&LP); }; sparsity_pattern = &sp; - const unsigned int + const size_type n_rows = sparsity_pattern->n_rows(); // first count number of nonzero elements in the upper right part. the // matrix is symmetric, so this suffices n_nonzero_elements = 0; - for (unsigned int row=0; rowbegin(row); col < sparsity_pattern->end(row); ++col) if (row <= col->column()) @@ -557,8 +561,8 @@ SparseDirectMA27::initialize (const SparsityPattern &sp) row_numbers.resize (n_nonzero_elements); column_numbers.resize (n_nonzero_elements); - unsigned int global_index = 0; - for (unsigned int row=0; rowbegin(row); col < sparsity_pattern->end(row); ++col) // note that the matrix must be @@ -576,7 +580,7 @@ SparseDirectMA27::initialize (const SparsityPattern &sp) // initialize scratch arrays and // variables - LIW = static_cast((2*n_nonzero_elements + 3*n_rows + 1) * + LIW = static_cast((2*n_nonzero_elements + 3*n_rows + 1) * LIW_factor_1); IW.resize (detached_mode_set() ? 0 : LIW); IKEEP.resize (detached_mode_set() ? 0 : 3*n_rows); @@ -604,7 +608,7 @@ SparseDirectMA27::initialize (const SparsityPattern &sp) break; // otherwise: increase LIW and retry - LIW = static_cast(LIW * LIW_increase_factor_1); + LIW = static_cast(LIW * LIW_increase_factor_1); IW.resize (LIW); } while (true); @@ -652,11 +656,11 @@ SparseDirectMA27::factorize (const SparseMatrix &matrix) // if necessary extend IW if (LIW < NIRNEC * LIW_factor_2) { - LIW = static_cast(NIRNEC * LIW_factor_2); + LIW = static_cast(NIRNEC * LIW_factor_2); IW.resize (LIW); }; - const unsigned int n_rows = matrix.get_sparsity_pattern().n_rows(); + const size_type n_rows = matrix.get_sparsity_pattern().n_rows(); // loop until memory requirements // are satisfied or we are not @@ -678,7 +682,7 @@ SparseDirectMA27::factorize (const SparseMatrix &matrix) // more used if (call_succeeded) { - std::vector tmp1, tmp2, tmp3; + std::vector tmp1, tmp2, tmp3; row_numbers.swap (tmp1); column_numbers.swap (tmp2); IKEEP.swap (tmp3); @@ -697,7 +701,7 @@ SparseDirectMA27::factorize (const SparseMatrix &matrix) if (LIW_increase_factor_2 <= 1) goto exit_loop; - LIW = static_cast(LIW * LIW_increase_factor_2); + LIW = static_cast(LIW * LIW_increase_factor_2); IW.resize (LIW); break; }; @@ -739,7 +743,7 @@ SparseDirectMA27::factorize (const SparseMatrix &matrix) // allocation. std::cout << "<*>" << std::flush; - LA = static_cast(LA * LA_increase_factor); + LA = static_cast(LA * LA_increase_factor); if (true) { std::vector tmp; @@ -783,7 +787,7 @@ SparseDirectMA27::solve (Vector &rhs_and_solution) const { Assert (factorize_called == true, ExcFactorizeNotCalled()); - const unsigned int n_rows = rhs_and_solution.size(); + const size_type n_rows = rhs_and_solution.size(); call_ma27cd (&n_rows, &A[0], &LA, &IW[0], &LIW, &MAXFRT, &rhs_and_solution(0), &IW1[0], &NSTEPS); @@ -802,7 +806,7 @@ SparseDirectMA27::solve (Vector &rhs_and_solution) const Vector tmp (rhs_and_solution.size()); tmp = rhs_and_solution; - const unsigned int n_rows = rhs_and_solution.size(); + const size_type n_rows = rhs_and_solution.size(); call_ma27cd (&n_rows, &A[0], &LA, &IW[0], &LIW, &MAXFRT, &tmp(0), &IW1[0], &NSTEPS); @@ -858,10 +862,10 @@ SparseDirectMA27::fill_A (const SparseMatrix &matrix) const SparsityPattern &sparsity_pattern = matrix.get_sparsity_pattern (); - const unsigned int n_rows = sparsity_pattern.n_rows(); + const size_type n_rows = sparsity_pattern.n_rows(); - unsigned int global_index = 0; - for (unsigned int row=0; row::const_iterator col=matrix.begin(row); col < matrix.end(row); ++col) // note that the matrix must be @@ -898,16 +902,16 @@ SparseDirectMA27::fill_A (const SparseMatrix &matrix) -void SparseDirectMA27::call_ma27ad (const unsigned int *N, - const unsigned int *NZ, - const unsigned int *IRN, - const unsigned int *ICN, - unsigned int *IW, - const unsigned int *LIW, - unsigned int *IKEEP, - unsigned int *IW1, - unsigned int *NSTEPS, - int *IFLAG) +void SparseDirectMA27::call_ma27ad (const size_type *N, + const size_type *NZ, + const size_type *IRN, + const size_type *ICN, + size_type *IW, + const size_type *LIW, + size_type *IKEEP, + size_type *IW1, + size_type *NSTEPS, + int *IFLAG) { if (detached_mode_set() == false) HSL::MA27::ma27ad_ (N, NZ, IRN, ICN, IW, LIW, @@ -942,19 +946,19 @@ void SparseDirectMA27::call_ma27ad (const unsigned int *N, -void SparseDirectMA27::call_ma27bd (const unsigned int *N, - const unsigned int *NZ, - const unsigned int *IRN, - const unsigned int *ICN, - double *A, - const unsigned int *LA, - unsigned int *IW, - const unsigned int *LIW, - const unsigned int *IKEEP, - const unsigned int *NSTEPS, - unsigned int *MAXFRT, - unsigned int *IW1, - int *IFLAG) +void SparseDirectMA27::call_ma27bd (const size_type *N, + const size_type *NZ, + const size_type *IRN, + const size_type *ICN, + double *A, + const size_type *LA, + size_type *IW, + const size_type *LIW, + const size_type *IKEEP, + const size_type *NSTEPS, + size_type *MAXFRT, + size_type *IW1, + int *IFLAG) { if (detached_mode_set() == false) HSL::MA27::ma27bd_ (N, NZ, IRN, ICN, A, LA, IW, LIW, @@ -978,15 +982,15 @@ void SparseDirectMA27::call_ma27bd (const unsigned int *N, -void SparseDirectMA27::call_ma27cd (const unsigned int *N, - const double *A, - const unsigned int *LA, - const unsigned int *IW, - const unsigned int *LIW, - const unsigned int *MAXFRT, - double *RHS, - const unsigned int *IW1, - const unsigned int *NSTEPS) const +void SparseDirectMA27::call_ma27cd (const size_type *N, + const double *A, + const size_type *LA, + const size_type *IW, + const size_type *LIW, + const size_type *MAXFRT, + double *RHS, + const size_type *IW1, + const size_type *NSTEPS) const { if (detached_mode_set() == false) { @@ -1006,7 +1010,7 @@ void SparseDirectMA27::call_ma27cd (const unsigned int *N, -void SparseDirectMA27::call_ma27x1 (unsigned int *NRLNEC) +void SparseDirectMA27::call_ma27x1 (size_type *NRLNEC) { if (detached_mode_set() == false) HSL::MA27::ma27x1_ (NRLNEC); @@ -1023,7 +1027,7 @@ void SparseDirectMA27::call_ma27x1 (unsigned int *NRLNEC) -void SparseDirectMA27::call_ma27x2 (unsigned int *NIRNEC) +void SparseDirectMA27::call_ma27x2 (size_type *NIRNEC) { if (detached_mode_set() == false) HSL::MA27::ma27x2_ (NIRNEC); @@ -1040,7 +1044,7 @@ void SparseDirectMA27::call_ma27x2 (unsigned int *NIRNEC) -void SparseDirectMA27::call_ma27x3 (const unsigned int *LP) +void SparseDirectMA27::call_ma27x3 (const size_type *LP) { if (detached_mode_set() == false) HSL::MA27::ma27x3_ (LP); @@ -1101,7 +1105,7 @@ SparseDirectMA47::initialize (const SparseMatrix &m) matrix = &m; const SparsityPattern &sparsity_pattern = matrix->get_sparsity_pattern(); - const unsigned int + const size_type n_rows = sparsity_pattern.n_rows(); // first count number of nonzero @@ -1109,7 +1113,7 @@ SparseDirectMA47::initialize (const SparseMatrix &m) // part. the matrix is symmetric, // so this suffices n_nonzero_elements = 0; - for (unsigned int row=0; row::const_iterator col = m.begin(row); col < m.end(row); ++col) // skip zero elements, as required by the docs of MA47 @@ -1126,8 +1130,8 @@ SparseDirectMA47::initialize (const SparseMatrix &m) row_numbers.resize (n_nonzero_elements); column_numbers.resize (n_nonzero_elements); - unsigned int global_index = 0; - for (unsigned int row=0; row::const_iterator col = m.begin(row); col < m.end(row); ++col) // note that the matrix must be @@ -1145,7 +1149,7 @@ SparseDirectMA47::initialize (const SparseMatrix &m) // initialize scratch arrays and // variables - LIW = static_cast((2*n_nonzero_elements + 5*n_rows + 4) * + LIW = static_cast((2*n_nonzero_elements + 5*n_rows + 4) * LIW_factor_1); IW.resize (LIW); KEEP.resize (n_nonzero_elements + 5*n_rows + 2); @@ -1166,7 +1170,7 @@ SparseDirectMA47::initialize (const SparseMatrix &m) break; // otherwise: increase LIW and retry - LIW = static_cast(LIW * LIW_increase_factor_1); + LIW = static_cast(LIW * LIW_increase_factor_1); IW.resize (LIW); } while (true); @@ -1205,11 +1209,11 @@ SparseDirectMA47::factorize (const SparseMatrix &m) // if necessary extend IW if (LIW < INFO[6] * LIW_factor_2) { - LIW = static_cast(INFO[6] * LIW_factor_2); + LIW = static_cast(INFO[6] * LIW_factor_2); IW.resize (LIW); }; - const unsigned int n_rows = m.get_sparsity_pattern().n_rows(); + const size_type n_rows = m.get_sparsity_pattern().n_rows(); IW1.resize (2*n_rows+2); // output info flags @@ -1237,7 +1241,7 @@ SparseDirectMA47::factorize (const SparseMatrix &m) if (LIW_increase_factor_2 <= 1) goto exit_loop; - LIW = static_cast(LIW * LIW_increase_factor_2); + LIW = static_cast(LIW * LIW_increase_factor_2); IW.resize (LIW); break; }; @@ -1279,7 +1283,7 @@ SparseDirectMA47::factorize (const SparseMatrix &m) // allocation. std::cout << "<*>" << std::flush; - LA = static_cast(LA * LA_increase_factor); + LA = static_cast(LA * LA_increase_factor); if (true) { std::vector tmp; @@ -1319,7 +1323,7 @@ SparseDirectMA47::solve (Vector &rhs_and_solution) { Assert (factorize_called == true, ExcFactorizeNotCalled()); - const unsigned int n_rows = rhs_and_solution.size(); + const size_type n_rows = rhs_and_solution.size(); call_ma47cd (&n_rows, &A[0], &LA, &IW[0], &LIW, &rhs_and_solution(0), &IW1[0], &ICNTL[0]); @@ -1367,10 +1371,10 @@ SparseDirectMA47::fill_A (const SparseMatrix &matrix) const SparsityPattern &sparsity_pattern = matrix.get_sparsity_pattern (); - const unsigned int n_rows = sparsity_pattern.n_rows(); + const size_type n_rows = sparsity_pattern.n_rows(); - unsigned int global_index = 0; - for (unsigned int row=0; row::const_iterator col=matrix.begin(row); col < matrix.end(row); ++col) // note that the matrix must be @@ -1415,13 +1419,13 @@ SparseDirectMA47::call_ma47id (double *CNTL, // length 2 void SparseDirectMA47:: -call_ma47ad (const unsigned int *n_rows, //scalar - const unsigned int *n_nonzero_elements, //scalar - unsigned int *row_numbers, //length n_nonzero - unsigned int *column_numbers, //length n_nonzero - unsigned int *IW, //length LIW - const unsigned int *LIW, //scalar - unsigned int *KEEP, //n_nonzero+5*n_rows+2 +call_ma47ad (const size_type *n_rows, //scalar + const size_type *n_nonzero_elements, //scalar + size_type *row_numbers, //length n_nonzero + size_type *column_numbers, //length n_nonzero + size_type *IW, //length LIW + const size_type *LIW, //scalar + size_type *KEEP, //n_nonzero+5*n_rows+2 const unsigned int *ICNTL, //length 7 int *INFO) //length 24 { @@ -1436,17 +1440,17 @@ call_ma47ad (const unsigned int *n_rows, //scalar void SparseDirectMA47:: -call_ma47bd (const unsigned int *n_rows, //scalar - const unsigned int *n_nonzero_elements, //scalar - const unsigned int *column_numbers, //length n_nonzero +call_ma47bd (const size_type *n_rows, //scalar + const size_type *n_nonzero_elements, //scalar + const size_type *column_numbers, //length n_nonzero double *A, //length LA - const unsigned int *LA, //scalar - unsigned int *IW, //length LIW - const unsigned int *LIW, //scalar - const unsigned int *KEEP, //n_nonzero+5*n_rows+2 + const size_type *LA, //scalar + size_type *IW, //length LIW + const size_type *LIW, //scalar + const size_type *KEEP, //n_nonzero+5*n_rows+2 const double *CNTL, //length 2 const unsigned int *ICNTL, //length 7 - unsigned int *IW1, //2*n_rows+2 + size_type *IW1, //2*n_rows+2 int *INFO) //length 24 { double RINFO[4]; @@ -1460,13 +1464,13 @@ call_ma47bd (const unsigned int *n_rows, //scalar void SparseDirectMA47:: -call_ma47cd (const unsigned int *n_rows, //scalar +call_ma47cd (const size_type *n_rows, //scalar const double *A, //length LA - const unsigned int *LA, //scalar - const unsigned int *IW, //length LIW - const unsigned int *LIW, //scalar + const size_type *LA, //scalar + const size_type *IW, //length LIW + const size_type *LIW, //scalar double *rhs_and_solution, //length n_rows - unsigned int *IW1, //length 2*n_rows+2 + size_type *IW1, //length 2*n_rows+2 const unsigned int *ICNTL) //length 7 { std::vector W(*n_rows); @@ -1555,7 +1559,7 @@ sort_arrays (const SparseMatrix &matrix) // second entry in a row // // ignore rows with only one or no entry - for (unsigned int row=0; row &matrix) { //same thing for SparseMatrixEZ - for (unsigned int row=0; row &matrix) // columns. we can do the same // thing as above, but we have to // do it multiple times - for (unsigned int row=0; row(Ap.back()) == Ai.size(), + Assert (static_cast(Ap.back()) == Ai.size(), ExcInternalError()); // then copy over matrix @@ -1728,7 +1732,7 @@ factorize (const Matrix &matrix) // loop over the elements of the matrix row by row, as suggested // in the documentation of the sparse matrix iterator class - for (unsigned int row = 0; row < matrix.m(); ++row) + for (size_type row = 0; row < matrix.m(); ++row) { for (typename Matrix::const_iterator p=matrix.begin(row); p!=matrix.end(row); ++p) @@ -1745,7 +1749,7 @@ factorize (const Matrix &matrix) // at the end, we should have // written all rows completely - for (unsigned int i=0; i &vector) // Copy solution into the given vector if (Utilities::MPI::this_mpi_process (MPI_COMM_WORLD) == 0) { - for (unsigned int i=0; i &dst, // Object denoting a MUMPS data structure: rhs = new double[n]; - for (unsigned int i = 0; i < n; ++i) + for (size_type i = 0; i < n; ++i) rhs[i] = src (i); id.rhs = rhs; diff --git a/deal.II/source/lac/sparsity_pattern.cc b/deal.II/source/lac/sparsity_pattern.cc index 5fa9044356..26fbeb23ea 100644 --- a/deal.II/source/lac/sparsity_pattern.cc +++ b/deal.II/source/lac/sparsity_pattern.cc @@ -32,7 +32,7 @@ DEAL_II_NAMESPACE_OPEN #ifdef DEAL_II_MSVC __declspec(selectany) // Weak extern binding due to multiple link error #endif -const unsigned int SparsityPattern::invalid_entry; +const SparsityPattern::size_type SparsityPattern::invalid_entry; @@ -70,9 +70,9 @@ SparsityPattern::SparsityPattern (const SparsityPattern &s) -SparsityPattern::SparsityPattern (const unsigned int m, - const unsigned int n, - const unsigned int max_per_row, +SparsityPattern::SparsityPattern (const size_type m, + const size_type n, + const size_type max_per_row, const bool) : max_dim(0), @@ -87,9 +87,9 @@ SparsityPattern::SparsityPattern (const unsigned int m, -SparsityPattern::SparsityPattern (const unsigned int m, - const unsigned int n, - const unsigned int max_per_row) +SparsityPattern::SparsityPattern (const size_type m, + const size_type n, + const size_type max_per_row) : max_dim(0), max_vec_len(0), @@ -103,9 +103,9 @@ SparsityPattern::SparsityPattern (const unsigned int m, -SparsityPattern::SparsityPattern (const unsigned int m, - const unsigned int n, - const std::vector &row_lengths, +SparsityPattern::SparsityPattern (const size_type m, + const size_type n, + const std::vector &row_lengths, const bool) : max_dim(0), @@ -118,9 +118,9 @@ SparsityPattern::SparsityPattern (const unsigned int m, } -SparsityPattern::SparsityPattern (const unsigned int m, - const unsigned int n, - const std::vector &row_lengths) +SparsityPattern::SparsityPattern (const size_type m, + const size_type n, + const std::vector &row_lengths) : max_dim(0), max_vec_len(0), @@ -133,8 +133,8 @@ SparsityPattern::SparsityPattern (const unsigned int m, -SparsityPattern::SparsityPattern (const unsigned int n, - const unsigned int max_per_row) +SparsityPattern::SparsityPattern (const size_type n, + const size_type max_per_row) : max_dim(0), max_vec_len(0), @@ -146,8 +146,8 @@ SparsityPattern::SparsityPattern (const unsigned int n, -SparsityPattern::SparsityPattern (const unsigned int m, - const std::vector &row_lengths, +SparsityPattern::SparsityPattern (const size_type m, + const std::vector &row_lengths, const bool) : max_dim(0), @@ -159,8 +159,8 @@ SparsityPattern::SparsityPattern (const unsigned int m, } -SparsityPattern::SparsityPattern (const unsigned int m, - const std::vector &row_lengths) +SparsityPattern::SparsityPattern (const size_type m, + const std::vector &row_lengths) : max_dim(0), max_vec_len(0), @@ -173,8 +173,8 @@ SparsityPattern::SparsityPattern (const unsigned int m, SparsityPattern::SparsityPattern (const SparsityPattern &original, - const unsigned int max_per_row, - const unsigned int extra_off_diagonals) + const size_type max_per_row, + const size_type extra_off_diagonals) : max_dim(0), max_vec_len(0), @@ -188,7 +188,7 @@ SparsityPattern::SparsityPattern (const SparsityPattern &original, // now copy the entries from // the other object - for (unsigned int row=0; row extra_off_diagonals ? Utilities::lower_bound (original_row_start, @@ -230,7 +230,7 @@ SparsityPattern::SparsityPattern (const SparsityPattern &original, row-extra_off_diagonals) : original_row_start); - const unsigned int *const + const size_type *const original_first_after_side_diagonals = (row < rows-extra_off_diagonals-1 ? std::upper_bound (original_row_start, @@ -241,7 +241,7 @@ SparsityPattern::SparsityPattern (const SparsityPattern &original, // find first free slot. the // first slot in each row is // the diagonal element - unsigned int *next_free_slot = &colnums[rowstart[row]] + 1; + size_type *next_free_slot = &colnums[rowstart[row]] + 1; // copy elements before side-diagonals next_free_slot = std::copy (original_row_start, @@ -249,10 +249,10 @@ SparsityPattern::SparsityPattern (const SparsityPattern &original, next_free_slot); // insert left and right side-diagonals - for (unsigned int i=1; i<=std::min(row,extra_off_diagonals); + for (size_type i=1; i<=std::min(row,extra_off_diagonals); ++i, ++next_free_slot) *next_free_slot = row-i; - for (unsigned int i=1; i<=std::min(extra_off_diagonals, rows-row-1); + for (size_type i=1; i<=std::min(extra_off_diagonals, rows-row-1); ++i, ++next_free_slot) *next_free_slot = row+i; @@ -301,36 +301,36 @@ SparsityPattern::operator = (const SparsityPattern &s) void -SparsityPattern::reinit (const unsigned int m, - const unsigned int n, - const unsigned int max_per_row, +SparsityPattern::reinit (const size_type m, + const size_type n, + const size_type max_per_row, const bool) { // simply map this function to the // other @p{reinit} function - const std::vector row_lengths (m, max_per_row); + const std::vector row_lengths (m, max_per_row); reinit (m, n, row_lengths); } void -SparsityPattern::reinit (const unsigned int m, - const unsigned int n, - const unsigned int max_per_row) +SparsityPattern::reinit (const size_type m, + const size_type n, + const size_type max_per_row) { // simply map this function to the // other @p{reinit} function - const std::vector row_lengths (m, max_per_row); + const std::vector row_lengths (m, max_per_row); reinit (m, n, row_lengths); } void -SparsityPattern::reinit (const unsigned int m, - const unsigned int n, - const VectorSlice > &row_lengths, +SparsityPattern::reinit (const size_type m, + const size_type n, + const VectorSlice > &row_lengths, const bool) { reinit (m, n, row_lengths); @@ -339,9 +339,9 @@ SparsityPattern::reinit (const unsigned int m, void -SparsityPattern::reinit (const unsigned int m, - const unsigned int n, - const VectorSlice > &row_lengths) +SparsityPattern::reinit (const size_type m, + const size_type n, + const VectorSlice > &row_lengths) { AssertDimension (row_lengths.size(), m); @@ -382,7 +382,7 @@ SparsityPattern::reinit (const unsigned int m, // per row is bounded by the number // of columns std::size_t vec_len = 0; - for (unsigned int i=0; i(), invalid_entry)); + std::bind2nd(std::not_equal_to(), invalid_entry)); // now allocate the respective memory - unsigned int *new_colnums = new unsigned int[nonzero_elements]; + size_type *new_colnums = new size_type[nonzero_elements]; // reserve temporary storage to // store the entries of one row - std::vector tmp_entries (max_row_length); + std::vector tmp_entries (max_row_length); // Traverse all rows - for (unsigned int line=0; line row_lengths (csp.n_rows()); - for (unsigned int i=0; i row_lengths (csp.n_rows()); + for (size_type i=0; i &matrix) // also have to allocate memory for the // diagonal entry, unless we have already // counted it - std::vector entries_per_row (matrix.m(), 0); - for (unsigned int row=0; row entries_per_row (matrix.m(), 0); + for (size_type row=0; row &matrix) reinit (matrix.m(), matrix.n(), entries_per_row); // now set entries - for (unsigned int row=0; row &matrix) void -SparsityPattern::reinit (const unsigned int m, - const unsigned int n, - const std::vector &row_lengths, +SparsityPattern::reinit (const size_type m, + const size_type n, + const std::vector &row_lengths, const bool) { reinit(m, n, make_slice(row_lengths)); @@ -732,9 +732,9 @@ SparsityPattern::reinit (const unsigned int m, void -SparsityPattern::reinit (const unsigned int m, - const unsigned int n, - const std::vector &row_lengths) +SparsityPattern::reinit (const size_type m, + const size_type n, + const std::vector &row_lengths) { reinit(m, n, make_slice(row_lengths)); } @@ -769,7 +769,7 @@ SparsityPattern::empty () const -unsigned int +SparsityPattern::size_type SparsityPattern::max_entries_per_row () const { // if compress() has not yet been @@ -782,18 +782,18 @@ SparsityPattern::max_entries_per_row () const // if compress() was called, we // use a better algorithm which // gives us a sharp bound - unsigned int m = 0; - for (unsigned int i=1; i(rowstart[i]-rowstart[i-1])); + size_type m = 0; + for (size_type i=1; i(rowstart[i]-rowstart[i-1])); return m; } -unsigned int -SparsityPattern::operator () (const unsigned int i, - const unsigned int j) const +SparsityPattern::size_type +SparsityPattern::operator () (const size_type i, + const size_type j) const { Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject()); Assert (i (sorted_region_start, + const size_type *sorted_region_start = (store_diagonal_first_in_row ? + &colnums[rowstart[i]+1] : + &colnums[rowstart[i]]); + const size_type *const p + = Utilities::lower_bound (sorted_region_start, &colnums[rowstart[i+1]], j); if ((p != &colnums[rowstart[i+1]]) && (*p == j)) @@ -840,8 +840,8 @@ SparsityPattern::operator () (const unsigned int i, void -SparsityPattern::add (const unsigned int i, - const unsigned int j) +SparsityPattern::add (const size_type i, + const size_type j) { Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject()); Assert (i void -SparsityPattern::add_entries (const unsigned int row, - ForwardIterator begin, - ForwardIterator end, - const bool indices_are_sorted) +SparsityPattern::add_entries (const size_type row, + ForwardIterator begin, + ForwardIterator end, + const bool indices_are_sorted) { if (indices_are_sorted == true) { @@ -913,13 +913,13 @@ SparsityPattern::add_entries (const unsigned int row, bool -SparsityPattern::exists (const unsigned int i, const unsigned int j) const +SparsityPattern::exists (const size_type i, const size_type j) const { Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject()); Assert (i -SparsityPattern::matrix_position (const unsigned int global_index) const +std::pair +SparsityPattern::matrix_position (const size_type global_index) const { Assert (compressed == true, ExcNotCompressed()); Assert (global_index < n_nonzero_elements(), @@ -962,14 +962,14 @@ SparsityPattern::matrix_position (const unsigned int global_index) const // for the one-past-last row, we // can simply use a bisection // search on it - const unsigned int row + const size_type row = (std::upper_bound (&rowstart[0], &rowstart[rows], global_index) - &rowstart[0] - 1); // now, the column index is simple // since that is what the colnums // array stores: - const unsigned int col = colnums[global_index]; + const size_type col = colnums[global_index]; // so return the respective pair return std::make_pair (row,col); @@ -998,8 +998,8 @@ SparsityPattern::symmetrize () // 2. that the @p{add} function can // be called on elements that // already exist without any harm - for (unsigned int row=0; row(std::abs(static_cast(i-colnums[j]))) > b) + if (static_cast(std::abs(static_cast(i-colnums[j]))) > b) b = std::abs(static_cast(i-colnums[j])); } else @@ -1144,7 +1144,7 @@ SparsityPattern::block_read (std::istream &in) delete[] colnums; rowstart = new std::size_t[max_dim+1]; - colnums = new unsigned int[max_vec_len]; + colnums = new size_type[max_vec_len]; // then read data in.read (reinterpret_cast(&rowstart[0]), @@ -1166,9 +1166,9 @@ SparsityPattern::block_read (std::istream &in) std::size_t SparsityPattern::memory_consumption () const { - return (max_dim * sizeof(unsigned int) + + return (max_dim * sizeof(size_type) + sizeof(*this) + - max_vec_len * sizeof(unsigned int)); + max_vec_len * sizeof(size_type)); } @@ -1195,21 +1195,21 @@ template void SparsityPattern::copy_from (const template void SparsityPattern::copy_from (const FullMatrix &); template void SparsityPattern::copy_from (const FullMatrix &); -template void SparsityPattern::add_entries (const unsigned int, - const unsigned int *, - const unsigned int *, +template void SparsityPattern::add_entries (const size_type , + const size_type *, + const size_type *, const bool); #ifndef DEAL_II_VECTOR_ITERATOR_IS_POINTER -template void SparsityPattern::add_entries::const_iterator> -(const unsigned int, - std::vector::const_iterator, - std::vector::const_iterator, +template void SparsityPattern::add_entries::const_iterator> +(const size_type, + std::vector::const_iterator, + std::vector::const_iterator, const bool); #endif -template void SparsityPattern::add_entries::iterator> -(const unsigned int, - std::vector::iterator, - std::vector::iterator, +template void SparsityPattern::add_entries::iterator> +(const size_type, + std::vector::iterator, + std::vector::iterator, const bool); DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/lac/sparsity_tools.cc b/deal.II/source/lac/sparsity_tools.cc index 99e69a582e..bb82de0bde 100644 --- a/deal.II/source/lac/sparsity_tools.cc +++ b/deal.II/source/lac/sparsity_tools.cc @@ -89,7 +89,7 @@ namespace SparsityTools int_rowstart.reserve(sparsity_pattern.n_rows()+1); std::vector int_colnums; int_colnums.reserve(sparsity_pattern.n_nonzero_elements()); - for (unsigned int row=0; row &new_indices) + const std::vector &new_indices) { { - unsigned int starting_point = numbers::invalid_unsigned_int; - unsigned int min_coordination = sparsity.n_rows(); - for (unsigned int row=0; row(j-sparsity.begin(row)) < + if (static_cast(j-sparsity.begin(row)) < min_coordination) { min_coordination = j-sparsity.begin(row); @@ -178,7 +178,7 @@ namespace SparsityTools // starting point, e.g. the first unnumbered one if (starting_point == numbers::invalid_unsigned_int) { - for (unsigned int i=0; i &new_indices, - const std::vector &starting_indices) + std::vector &new_indices, + const std::vector &starting_indices) { Assert (sparsity.n_rows() == sparsity.n_cols(), ExcDimensionMismatch (sparsity.n_rows(), sparsity.n_cols())); @@ -206,26 +206,26 @@ namespace SparsityTools ExcDimensionMismatch (sparsity.n_rows(), new_indices.size())); Assert (starting_indices.size() <= sparsity.n_rows(), ExcMessage ("You can't specify more starting indices than there are rows")); - for (unsigned int i=0; i last_round_dofs (starting_indices); + std::vector last_round_dofs (starting_indices); // initialize the new_indices array with invalid values std::fill (new_indices.begin(), new_indices.end(), numbers::invalid_unsigned_int); // delete disallowed elements - for (unsigned int i=0; i=sparsity.n_rows())) last_round_dofs[i] = numbers::invalid_unsigned_int; std::remove_if (last_round_dofs.begin(), last_round_dofs.end(), - std::bind2nd(std::equal_to(), + std::bind2nd(std::equal_to(), numbers::invalid_unsigned_int)); // now if no valid points remain: find dof with lowest coordination number @@ -235,10 +235,10 @@ namespace SparsityTools new_indices)); // store next free dof index - unsigned int next_free_number = 0; + size_type next_free_number = 0; // enumerate the first round dofs - for (unsigned int i=0; i!=last_round_dofs.size(); ++i) + for (size_type i=0; i!=last_round_dofs.size(); ++i) new_indices[last_round_dofs[i]] = next_free_number++; // now do as many steps as needed to @@ -247,12 +247,12 @@ namespace SparsityTools { // store the indices of the dofs to be // renumbered in the next round - std::vector next_round_dofs; + std::vector next_round_dofs; // find all neighbors of the // dofs numbered in the last // round - for (unsigned int i=0; iis_valid_entry() == false) @@ -264,7 +264,7 @@ namespace SparsityTools std::sort (next_round_dofs.begin(), next_round_dofs.end()); // delete multiple entries - std::vector::iterator end_sorted; + std::vector::iterator end_sorted; end_sorted = std::unique (next_round_dofs.begin(), next_round_dofs.end()); next_round_dofs.erase (end_sorted, next_round_dofs.end()); @@ -327,14 +327,14 @@ namespace SparsityTools // store for each coordination // number the dofs with these // coordination number - std::multimap dofs_by_coordination; + std::multimap dofs_by_coordination; // find coordination number for // each of these dofs - for (std::vector::iterator s=next_round_dofs.begin(); + for (std::vector::iterator s=next_round_dofs.begin(); s!=next_round_dofs.end(); ++s) { - unsigned int coordination = 0; + size_type coordination = 0; for (SparsityPattern::iterator j=sparsity.begin(*s); jis_valid_entry() == false) @@ -344,14 +344,14 @@ namespace SparsityTools // insert this dof at its // coordination number - const std::pair new_entry (coordination, *s); + const std::pair new_entry (coordination, *s); dofs_by_coordination.insert (new_entry); } // assign new DoF numbers to // the elements of the present // front: - std::multimap::iterator i; + std::multimap::iterator i; for (i = dofs_by_coordination.begin(); i!=dofs_by_coordination.end(); ++i) new_indices[i->second] = next_free_number++; @@ -377,27 +377,27 @@ namespace SparsityTools #ifdef DEAL_II_COMPILER_SUPPORTS_MPI template void distribute_sparsity_pattern(CSP_t &csp, - const std::vector &rows_per_cpu, + const std::vector &rows_per_cpu, const MPI_Comm &mpi_comm, const IndexSet &myrange) { - unsigned int myid = Utilities::MPI::this_mpi_process(mpi_comm); - std::vector start_index(rows_per_cpu.size()+1); + size_type myid = Utilities::MPI::this_mpi_process(mpi_comm); + std::vector start_index(rows_per_cpu.size()+1); start_index[0]=0; - for (unsigned int i=0; i > map_vec_t; + typedef std::map > map_vec_t; map_vec_t send_data; { unsigned int dest_cpu=0; - unsigned int n_local_rel_rows = myrange.n_elements(); - for (unsigned int row_idx=0; row_idx=start_index[dest_cpu+1]) @@ -410,21 +410,21 @@ namespace SparsityTools continue; } - unsigned int rlen = csp.row_length(row); + size_type rlen = csp.row_length(row); //skip empty lines if (!rlen) continue; //save entries - std::vector &dst = send_data[dest_cpu]; + std::vector &dst = send_data[dest_cpu]; dst.push_back(rlen); // number of entries dst.push_back(row); // row index - for (unsigned int c=0; c