From fd41d47860f113916772b39cbf637173fa8d45bf Mon Sep 17 00:00:00 2001 From: "Roy H. Stogner" Date: Tue, 9 Apr 2013 17:56:40 -0500 Subject: [PATCH] Add LIBMESH_CAN_DEFAULT_TO_COMMWORLD macro And reorder new method args as necessary to support it. Because I just redid our examples to use the new methods on Mesh classes and because that was one of the necessary reorderings, this won't pass "make check" yet; a subsequent commit should fix that. --- include/mesh/boundary_mesh.h | 16 +++++- include/mesh/mesh.h | 18 ++++-- include/mesh/mesh_base.h | 14 ++++- include/mesh/parallel_mesh.h | 16 +++++- include/mesh/serial_mesh.h | 16 +++++- include/mesh/unstructured_mesh.h | 14 ++++- include/numerics/distributed_vector.h | 61 ++++++++++---------- include/numerics/eigen_sparse_vector.h | 61 ++++++++++---------- include/numerics/laspack_vector.h | 59 ++++++++++---------- include/numerics/numeric_vector.h | 62 ++++++++++++--------- include/numerics/petsc_matrix.h | 2 + include/numerics/petsc_vector.h | 68 +++++++++++------------ include/numerics/sparse_matrix.h | 1 + include/numerics/trilinos_epetra_vector.h | 68 +++++++++++------------ src/mesh/boundary_mesh.C | 16 +++++- src/mesh/mesh_base.C | 23 +++++++- src/mesh/parallel_mesh.C | 23 +++++++- src/mesh/serial_mesh.C | 16 +++++- src/mesh/unstructured_mesh.C | 16 +++++- src/numerics/distributed_vector.C | 2 +- src/numerics/numeric_vector.C | 21 +++++-- src/numerics/petsc_vector.C | 2 +- src/numerics/trilinos_epetra_vector.C | 2 +- tests/numerics/numeric_vector_test.h | 4 +- 24 files changed, 373 insertions(+), 228 deletions(-) diff --git a/include/mesh/boundary_mesh.h b/include/mesh/boundary_mesh.h index ef187829538..14f2fb05090 100644 --- a/include/mesh/boundary_mesh.h +++ b/include/mesh/boundary_mesh.h @@ -46,8 +46,20 @@ class BoundaryMesh : public Mesh /** * Constructor. Initializes dimenstion and processor id. */ - BoundaryMesh (unsigned int d, const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + explicit + BoundaryMesh (const Parallel::Communicator &comm, + unsigned int dim=1); + +#ifndef LIBMESH_DISABLE_COMMWORLD + /** + * Deprecated constructor. Takes \p dim, the dimension of the mesh. + * The mesh dimension can be changed (and may automatically be + * changed by mesh generation/loading) later. + */ + explicit + BoundaryMesh (unsigned int dim=1); +#endif + /** * Destructor. diff --git a/include/mesh/mesh.h b/include/mesh/mesh.h index 11eeed407a1..45a62ed7f81 100644 --- a/include/mesh/mesh.h +++ b/include/mesh/mesh.h @@ -57,10 +57,20 @@ class Mesh : public DefaultMesh * changed by mesh generation/loading) later. */ explicit - Mesh (unsigned int dim=1, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD) - : DefaultMesh(dim,comm) {} + Mesh (const Parallel::Communicator &comm, + unsigned int dim=1) + : DefaultMesh(comm,dim) {} + +#ifndef LIBMESH_DISABLE_COMMWORLD + /** + * Deprecated constructor. Takes \p dim, the dimension of the mesh. + * The mesh dimension can be changed (and may automatically be + * changed by mesh generation/loading) later. + */ + explicit + Mesh (unsigned int dim=1) + : DefaultMesh(dim) {} +#endif /** * Copy-constructor. This should be able to take a diff --git a/include/mesh/mesh_base.h b/include/mesh/mesh_base.h index 380c627d64c..ac7b58e070b 100644 --- a/include/mesh/mesh_base.h +++ b/include/mesh/mesh_base.h @@ -75,9 +75,17 @@ class MeshBase : public ParallelObject * The mesh dimension can be changed (and may automatically be * changed by mesh generation/loading) later. */ - MeshBase (unsigned int dim=1, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + MeshBase (const Parallel::Communicator &comm, + unsigned int dim=1); + +#ifndef LIBMESH_DISABLE_COMMWORLD + /** + * Deprecated constructor. Takes \p dim, the dimension of the mesh. + * The mesh dimension can be changed (and may automatically be + * changed by mesh generation/loading) later. + */ + MeshBase (unsigned int dim=1); +#endif /** * Copy-constructor. diff --git a/include/mesh/parallel_mesh.h b/include/mesh/parallel_mesh.h index b3f74724678..2541b97b068 100644 --- a/include/mesh/parallel_mesh.h +++ b/include/mesh/parallel_mesh.h @@ -56,9 +56,19 @@ class ParallelMesh : public UnstructuredMesh * changed by mesh generation/loading) later. */ explicit - ParallelMesh (unsigned int dim=1, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + ParallelMesh (const Parallel::Communicator &comm, + unsigned int dim=1); + +#ifndef LIBMESH_DISABLE_COMMWORLD + /** + * Deprecated constructor. Takes \p dim, the dimension of the mesh. + * The mesh dimension can be changed (and may automatically be + * changed by mesh generation/loading) later. + */ + explicit + ParallelMesh (unsigned int dim=1); +#endif + /** * Copy-constructor. This should be able to take a diff --git a/include/mesh/serial_mesh.h b/include/mesh/serial_mesh.h index 00e81317805..cfde7412e2a 100644 --- a/include/mesh/serial_mesh.h +++ b/include/mesh/serial_mesh.h @@ -54,9 +54,19 @@ class SerialMesh : public UnstructuredMesh * changed by mesh generation/loading) later. */ explicit - SerialMesh (unsigned int dim=1, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + SerialMesh (const Parallel::Communicator &comm, + unsigned int dim=1); + +#ifndef LIBMESH_DISABLE_COMMWORLD + /** + * Deprecated constructor. Takes \p dim, the dimension of the mesh. + * The mesh dimension can be changed (and may automatically be + * changed by mesh generation/loading) later. + */ + explicit + SerialMesh (unsigned int dim=1); +#endif + /** * Copy-constructor. This should be able to take a diff --git a/include/mesh/unstructured_mesh.h b/include/mesh/unstructured_mesh.h index 93f7e863bf9..1d81ee15cee 100644 --- a/include/mesh/unstructured_mesh.h +++ b/include/mesh/unstructured_mesh.h @@ -58,9 +58,17 @@ class UnstructuredMesh : public MeshBase * changed by mesh generation/loading) later. */ explicit - UnstructuredMesh (unsigned int dim=1, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + UnstructuredMesh (const Parallel::Communicator &comm, + unsigned int dim=1); + +#ifndef LIBMESH_DISABLE_COMMWORLD + /** + * Deprecated constructor. Takes \p dim, the dimension of the mesh. + * The mesh dimension can be changed (and may automatically be + * changed by mesh generation/loading) later. + */ + UnstructuredMesh (unsigned int dim=1); +#endif /** * Destructor. diff --git a/include/numerics/distributed_vector.h b/include/numerics/distributed_vector.h index f427cf91635..f0faa1ac0a4 100644 --- a/include/numerics/distributed_vector.h +++ b/include/numerics/distributed_vector.h @@ -57,40 +57,36 @@ class DistributedVector : public NumericVector * Dummy-Constructor. Dimension=0 */ explicit - DistributedVector (const ParallelType = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + DistributedVector (const Parallel::Communicator &comm, + const ParallelType = AUTOMATIC); /** * Constructor. Set dimension to \p n and initialize all elements with zero. */ explicit - DistributedVector (const numeric_index_type n, - const ParallelType ptype = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + DistributedVector (const Parallel::Communicator &comm, + const numeric_index_type n, + const ParallelType ptype = AUTOMATIC); /** * Constructor. Set local dimension to \p n_local, the global dimension * to \p n, and initialize all elements with zero. */ - DistributedVector (const numeric_index_type n, + DistributedVector (const Parallel::Communicator &comm, + const numeric_index_type n, const numeric_index_type n_local, - const ParallelType ptype = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + const ParallelType ptype = AUTOMATIC); /** * Constructor. Set local dimension to \p n_local, the global * dimension to \p n, but additionally reserve memory for the * indices specified by the \p ghost argument. */ - DistributedVector (const numeric_index_type N, + DistributedVector (const Parallel::Communicator &comm, + const numeric_index_type N, const numeric_index_type n_local, const std::vector& ghost, - const ParallelType ptype = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + const ParallelType ptype = AUTOMATIC); /** * Destructor, deallocates memory. Made virtual to allow @@ -484,8 +480,9 @@ class DistributedVector : public NumericVector // DistributedVector inline methods template inline -DistributedVector::DistributedVector (const ParallelType ptype, const Parallel::Communicator &comm) - : NumericVector(ptype, comm), +DistributedVector::DistributedVector (const Parallel::Communicator &comm, + const ParallelType ptype) + : NumericVector(comm, ptype), _global_size (0), _local_size (0), _first_local_index(0), @@ -498,10 +495,10 @@ DistributedVector::DistributedVector (const ParallelType ptype, const Paralle template inline -DistributedVector::DistributedVector (const numeric_index_type n, - const ParallelType ptype, - const Parallel::Communicator &comm) - : NumericVector(ptype, comm) +DistributedVector::DistributedVector (const Parallel::Communicator &comm, + const numeric_index_type n, + const ParallelType ptype) + : NumericVector(comm, ptype) { this->init(n, n, false, ptype); } @@ -510,11 +507,11 @@ DistributedVector::DistributedVector (const numeric_index_type n, template inline -DistributedVector::DistributedVector (const numeric_index_type n, +DistributedVector::DistributedVector (const Parallel::Communicator &comm, + const numeric_index_type n, const numeric_index_type n_local, - const ParallelType ptype, - const Parallel::Communicator &comm) - : NumericVector(ptype, comm) + const ParallelType ptype) + : NumericVector(comm, ptype) { this->init(n, n_local, false, ptype); } @@ -523,12 +520,12 @@ DistributedVector::DistributedVector (const numeric_index_type n, template inline -DistributedVector::DistributedVector (const numeric_index_type n, +DistributedVector::DistributedVector (const Parallel::Communicator &comm, + const numeric_index_type n, const numeric_index_type n_local, const std::vector& ghost, - const ParallelType ptype, - const Parallel::Communicator &comm) - : NumericVector(ptype, comm) + const ParallelType ptype) + : NumericVector(comm, ptype) { this->init(n, n_local, ghost, false, ptype); } @@ -712,7 +709,8 @@ template inline AutoPtr > DistributedVector::zero_clone () const { - AutoPtr > cloned_vector (new DistributedVector); + AutoPtr > cloned_vector + (new DistributedVector(this->communicator())); cloned_vector->init(*this); @@ -725,7 +723,8 @@ template inline AutoPtr > DistributedVector::clone () const { - AutoPtr > cloned_vector (new DistributedVector); + AutoPtr > cloned_vector + (new DistributedVector(this->communicator())); cloned_vector->init(*this, true); diff --git a/include/numerics/eigen_sparse_vector.h b/include/numerics/eigen_sparse_vector.h index fefad534baa..e44aff02c2c 100644 --- a/include/numerics/eigen_sparse_vector.h +++ b/include/numerics/eigen_sparse_vector.h @@ -61,40 +61,36 @@ class EigenSparseVector : public NumericVector * Dummy-Constructor. Dimension=0 */ explicit - EigenSparseVector (const ParallelType = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + EigenSparseVector (const Parallel::Communicator &comm, + const ParallelType = AUTOMATIC); /** * Constructor. Set dimension to \p n and initialize all elements with zero. */ explicit - EigenSparseVector (const numeric_index_type n, - const ParallelType = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + EigenSparseVector (const Parallel::Communicator &comm, + const numeric_index_type n, + const ParallelType = AUTOMATIC); /** * Constructor. Set local dimension to \p n_local, the global dimension * to \p n, and initialize all elements with zero. */ - EigenSparseVector (const numeric_index_type n, + EigenSparseVector (const Parallel::Communicator &comm, + const numeric_index_type n, const numeric_index_type n_local, - const ParallelType = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + const ParallelType = AUTOMATIC); /** * Constructor. Set local dimension to \p n_local, the global * dimension to \p n, but additionally reserve memory for the * indices specified by the \p ghost argument. */ - EigenSparseVector (const numeric_index_type N, + EigenSparseVector (const Parallel::Communicator &comm, + const numeric_index_type N, const numeric_index_type n_local, const std::vector& ghost, - const ParallelType = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + const ParallelType = AUTOMATIC); /** * Destructor, deallocates memory. Made virtual to allow @@ -482,8 +478,9 @@ class EigenSparseVector : public NumericVector // EigenSparseVector inline methods template inline -EigenSparseVector::EigenSparseVector (const ParallelType ptype, const Parallel::Communicator &comm) - : NumericVector(ptype, comm) +EigenSparseVector::EigenSparseVector (const Parallel::Communicator &comm, + const ParallelType ptype) + : NumericVector(comm, ptype) { this->_type = ptype; } @@ -492,10 +489,10 @@ EigenSparseVector::EigenSparseVector (const ParallelType ptype, const Paralle template inline -EigenSparseVector::EigenSparseVector (const numeric_index_type n, - const ParallelType ptype, - const Parallel::Communicator &comm) - : NumericVector(ptype, comm) +EigenSparseVector::EigenSparseVector (const Parallel::Communicator &comm, + const numeric_index_type n, + const ParallelType ptype) + : NumericVector(comm, ptype) { this->init(n, n, false, ptype); } @@ -504,11 +501,11 @@ EigenSparseVector::EigenSparseVector (const numeric_index_type n, template inline -EigenSparseVector::EigenSparseVector (const numeric_index_type n, +EigenSparseVector::EigenSparseVector (const Parallel::Communicator &comm, + const numeric_index_type n, const numeric_index_type n_local, - const ParallelType ptype, - const Parallel::Communicator &comm) - : NumericVector(ptype, comm) + const ParallelType ptype) + : NumericVector(comm, ptype) { this->init(n, n_local, false, ptype); } @@ -517,12 +514,12 @@ EigenSparseVector::EigenSparseVector (const numeric_index_type n, template inline -EigenSparseVector::EigenSparseVector (const numeric_index_type N, +EigenSparseVector::EigenSparseVector (const Parallel::Communicator &comm, + const numeric_index_type N, const numeric_index_type n_local, const std::vector& ghost, - const ParallelType ptype, - const Parallel::Communicator &comm) - : NumericVector(ptype, comm) + const ParallelType ptype) + : NumericVector(comm, ptype) { this->init(N, n_local, ghost, false, ptype); } @@ -648,7 +645,8 @@ template inline AutoPtr > EigenSparseVector::zero_clone () const { - AutoPtr > cloned_vector (new EigenSparseVector); + AutoPtr > cloned_vector + (new EigenSparseVector(this->communicator())); cloned_vector->init(*this); @@ -661,7 +659,8 @@ template inline AutoPtr > EigenSparseVector::clone () const { - AutoPtr > cloned_vector (new EigenSparseVector); + AutoPtr > cloned_vector + (new EigenSparseVector(this->communicator())); cloned_vector->init(*this, true); diff --git a/include/numerics/laspack_vector.h b/include/numerics/laspack_vector.h index eac61ab0dda..777dbbda6d1 100644 --- a/include/numerics/laspack_vector.h +++ b/include/numerics/laspack_vector.h @@ -62,37 +62,36 @@ class LaspackVector : public NumericVector * Dummy-Constructor. Dimension=0 */ explicit - LaspackVector (const ParallelType = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + LaspackVector (const Parallel::Communicator &comm, + const ParallelType = AUTOMATIC); /** * Constructor. Set dimension to \p n and initialize all elements with zero. */ explicit - LaspackVector (const numeric_index_type n, - const ParallelType = AUTOMATIC, - const Parallel::Communicator &comm = libMesh::CommWorld); + LaspackVector (const Parallel::Communicator &comm, + const numeric_index_type n, + const ParallelType = AUTOMATIC); /** * Constructor. Set local dimension to \p n_local, the global dimension * to \p n, and initialize all elements with zero. */ - LaspackVector (const numeric_index_type n, + LaspackVector (const Parallel::Communicator &comm, + const numeric_index_type n, const numeric_index_type n_local, - const ParallelType = AUTOMATIC, - const Parallel::Communicator &comm = libMesh::CommWorld); + const ParallelType = AUTOMATIC); /** * Constructor. Set local dimension to \p n_local, the global * dimension to \p n, but additionally reserve memory for the * indices specified by the \p ghost argument. */ - LaspackVector (const numeric_index_type N, + LaspackVector (const Parallel::Communicator &comm, + const numeric_index_type N, const numeric_index_type n_local, const std::vector& ghost, - const ParallelType = AUTOMATIC, - const Parallel::Communicator &comm = libMesh::CommWorld); + const ParallelType = AUTOMATIC); /** * Destructor, deallocates memory. Made virtual to allow @@ -468,9 +467,9 @@ class LaspackVector : public NumericVector // LaspackVector inline methods template inline -LaspackVector::LaspackVector (const ParallelType ptype, - const Parallel::Communicator &comm) - : NumericVector(ptype, comm) +LaspackVector::LaspackVector (const Parallel::Communicator &comm, + const ParallelType ptype) + : NumericVector(comm, ptype) { this->_type = ptype; } @@ -479,10 +478,10 @@ LaspackVector::LaspackVector (const ParallelType ptype, template inline -LaspackVector::LaspackVector (const numeric_index_type n, - const ParallelType ptype, - const Parallel::Communicator &comm) - : NumericVector(ptype, comm) +LaspackVector::LaspackVector (const Parallel::Communicator &comm, + const numeric_index_type n, + const ParallelType ptype) + : NumericVector(comm, ptype) { this->init(n, n, false, ptype); } @@ -491,11 +490,11 @@ LaspackVector::LaspackVector (const numeric_index_type n, template inline -LaspackVector::LaspackVector (const numeric_index_type n, +LaspackVector::LaspackVector (const Parallel::Communicator &comm, + const numeric_index_type n, const numeric_index_type n_local, - const ParallelType ptype, - const Parallel::Communicator &comm) - : NumericVector(ptype, comm) + const ParallelType ptype) + : NumericVector(comm, ptype) { this->init(n, n_local, false, ptype); } @@ -504,12 +503,12 @@ LaspackVector::LaspackVector (const numeric_index_type n, template inline -LaspackVector::LaspackVector (const numeric_index_type N, +LaspackVector::LaspackVector (const Parallel::Communicator &comm, + const numeric_index_type N, const numeric_index_type n_local, const std::vector& ghost, - const ParallelType ptype, - const Parallel::Communicator &comm) - : NumericVector(ptype, comm) + const ParallelType ptype) + : NumericVector(comm, ptype) { this->init(N, n_local, ghost, false, ptype); } @@ -644,7 +643,8 @@ template inline AutoPtr > LaspackVector::zero_clone () const { - AutoPtr > cloned_vector (new LaspackVector); + AutoPtr > cloned_vector + (new LaspackVector(this->communicator())); cloned_vector->init(*this); @@ -657,7 +657,8 @@ template inline AutoPtr > LaspackVector::clone () const { - AutoPtr > cloned_vector (new LaspackVector); + AutoPtr > cloned_vector + (new LaspackVector(this->communicator())); cloned_vector->init(*this, true); diff --git a/include/numerics/numeric_vector.h b/include/numerics/numeric_vector.h index ddcba42ecc5..5fda66925c8 100644 --- a/include/numerics/numeric_vector.h +++ b/include/numerics/numeric_vector.h @@ -64,40 +64,36 @@ class NumericVector : public ReferenceCountedObject >, * Dummy-Constructor. Dimension=0 */ explicit - NumericVector (const ParallelType ptype = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + NumericVector (const Parallel::Communicator &comm, + const ParallelType ptype = AUTOMATIC); /** * Constructor. Set dimension to \p n and initialize all elements with zero. */ explicit - NumericVector (const numeric_index_type n, - const ParallelType ptype = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + NumericVector (const Parallel::Communicator &comm, + const numeric_index_type n, + const ParallelType ptype = AUTOMATIC); /** * Constructor. Set local dimension to \p n_local, the global dimension * to \p n, and initialize all elements with zero. */ - NumericVector (const numeric_index_type n, + NumericVector (const Parallel::Communicator &comm, + const numeric_index_type n, const numeric_index_type n_local, - const ParallelType ptype = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + const ParallelType ptype = AUTOMATIC); /** * Constructor. Set local dimension to \p n_local, the global * dimension to \p n, but additionally reserve memory for the * indices specified by the \p ghost argument. */ - NumericVector (const numeric_index_type N, + NumericVector (const Parallel::Communicator &comm, + const numeric_index_type N, const numeric_index_type n_local, const std::vector& ghost, - const ParallelType ptype = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + const ParallelType ptype = AUTOMATIC); public: @@ -108,13 +104,24 @@ class NumericVector : public ReferenceCountedObject >, virtual ~NumericVector (); /** - * Builds a \p NumericVector using the linear solver package specified by + * Builds a \p NumericVector on the processors in communicator + * \p comm using the linear solver package specified by * \p solver_package */ static AutoPtr > - build(const Parallel::Communicator &comm LIBMESH_CAN_DEFAULT_TO_COMMWORLD, + build(const Parallel::Communicator &comm, const SolverPackage solver_package = libMesh::default_solver_package()); +#ifndef LIBMESH_DISABLE_COMMWORLD + /** + * Builds a \p NumericVector on the processors in communicator + * CommWorld using the linear solver package specified by \p + * solver_package. Deprecated. + */ + static AutoPtr > + build(const SolverPackage solver_package = libMesh::default_solver_package()); +#endif + /** * @returns true if the vector has been initialized, * false otherwise. @@ -657,7 +664,8 @@ class NumericVector : public ReferenceCountedObject >, template inline -NumericVector::NumericVector (const ParallelType ptype, const Parallel::Communicator &comm) : +NumericVector::NumericVector (const Parallel::Communicator &comm, + const ParallelType ptype) : ParallelObject(comm), _is_closed(false), _is_initialized(false), @@ -669,9 +677,9 @@ NumericVector::NumericVector (const ParallelType ptype, const Parallel::Commu template inline -NumericVector::NumericVector (const numeric_index_type /*n*/, - const ParallelType ptype, - const Parallel::Communicator &comm) : +NumericVector::NumericVector (const Parallel::Communicator &comm, + const numeric_index_type /*n*/, + const ParallelType ptype) : ParallelObject(comm), _is_closed(false), _is_initialized(false), @@ -685,10 +693,10 @@ NumericVector::NumericVector (const numeric_index_type /*n*/, template inline -NumericVector::NumericVector (const numeric_index_type /*n*/, +NumericVector::NumericVector (const Parallel::Communicator &comm, + const numeric_index_type /*n*/, const numeric_index_type /*n_local*/, - const ParallelType ptype, - const Parallel::Communicator &comm) : + const ParallelType ptype) : ParallelObject(comm), _is_closed(false), _is_initialized(false), @@ -702,11 +710,11 @@ NumericVector::NumericVector (const numeric_index_type /*n*/, template inline -NumericVector::NumericVector (const numeric_index_type /*n*/, +NumericVector::NumericVector (const Parallel::Communicator &comm, + const numeric_index_type /*n*/, const numeric_index_type /*n_local*/, const std::vector& /*ghost*/, - const ParallelType ptype, - const Parallel::Communicator &comm) : + const ParallelType ptype) : ParallelObject(comm), _is_closed(false), _is_initialized(false), diff --git a/include/numerics/petsc_matrix.h b/include/numerics/petsc_matrix.h index bddfea1f217..2547c5e6f9d 100644 --- a/include/numerics/petsc_matrix.h +++ b/include/numerics/petsc_matrix.h @@ -92,6 +92,7 @@ class PetscMatrix : public SparseMatrix * the matrix before usage with * \p init(...). */ + explicit PetscMatrix (const Parallel::Communicator &comm LIBMESH_CAN_DEFAULT_TO_COMMWORLD); @@ -102,6 +103,7 @@ class PetscMatrix : public SparseMatrix * This allows ownership of m to remain with the original creator, * and to simply provide additional functionality with the PetscMatrix. */ + explicit PetscMatrix (Mat m, const Parallel::Communicator &comm LIBMESH_CAN_DEFAULT_TO_COMMWORLD); diff --git a/include/numerics/petsc_vector.h b/include/numerics/petsc_vector.h index fb183e6e3a4..df531fa05d9 100644 --- a/include/numerics/petsc_vector.h +++ b/include/numerics/petsc_vector.h @@ -66,40 +66,36 @@ class PetscVector : public NumericVector * Dummy-Constructor. Dimension=0 */ explicit - PetscVector (const ParallelType type = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + PetscVector (const Parallel::Communicator &comm, + const ParallelType type = AUTOMATIC); /** * Constructor. Set dimension to \p n and initialize all elements with zero. */ explicit - PetscVector (const numeric_index_type n, - const ParallelType type = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + PetscVector (const Parallel::Communicator &comm, + const numeric_index_type n, + const ParallelType type = AUTOMATIC); /** * Constructor. Set local dimension to \p n_local, the global dimension * to \p n, and initialize all elements with zero. */ - PetscVector (const numeric_index_type n, + PetscVector (const Parallel::Communicator &comm, + const numeric_index_type n, const numeric_index_type n_local, - const ParallelType type = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + const ParallelType type = AUTOMATIC); /** * Constructor. Set local dimension to \p n_local, the global * dimension to \p n, but additionally reserve memory for the * indices specified by the \p ghost argument. */ - PetscVector (const numeric_index_type N, + PetscVector (const Parallel::Communicator &comm, + const numeric_index_type N, const numeric_index_type n_local, const std::vector& ghost, - const ParallelType type = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + const ParallelType type = AUTOMATIC); /** * Constructor. Creates a PetscVector assuming you already have a @@ -108,7 +104,8 @@ class PetscVector : public NumericVector * This allows ownership of \p v to remain with the original creator, * and to simply provide additional functionality with the PetscVector. */ - PetscVector(Vec v, const Parallel::Communicator &comm + PetscVector(Vec v, + const Parallel::Communicator &comm LIBMESH_CAN_DEFAULT_TO_COMMWORLD); /** @@ -607,8 +604,8 @@ class PetscVector : public NumericVector template inline -PetscVector::PetscVector (const ParallelType ptype, const Parallel::Communicator &comm) - : NumericVector(ptype, comm), +PetscVector::PetscVector (const Parallel::Communicator &comm, const ParallelType ptype) + : NumericVector(comm, ptype), _array_is_present(false), _local_form(NULL), _values(NULL), @@ -622,10 +619,10 @@ PetscVector::PetscVector (const ParallelType ptype, const Parallel::Communica template inline -PetscVector::PetscVector (const numeric_index_type n, - const ParallelType ptype, - const Parallel::Communicator &comm) - : NumericVector(ptype, comm), +PetscVector::PetscVector (const Parallel::Communicator &comm, + const numeric_index_type n, + const ParallelType ptype) + : NumericVector(comm, ptype), _array_is_present(false), _local_form(NULL), _values(NULL), @@ -639,11 +636,11 @@ PetscVector::PetscVector (const numeric_index_type n, template inline -PetscVector::PetscVector (const numeric_index_type n, +PetscVector::PetscVector (const Parallel::Communicator &comm, + const numeric_index_type n, const numeric_index_type n_local, - const ParallelType ptype, - const Parallel::Communicator &comm) - : NumericVector(ptype, comm), + const ParallelType ptype) + : NumericVector(comm, ptype), _array_is_present(false), _local_form(NULL), _values(NULL), @@ -657,12 +654,12 @@ PetscVector::PetscVector (const numeric_index_type n, template inline -PetscVector::PetscVector (const numeric_index_type n, +PetscVector::PetscVector (const Parallel::Communicator &comm, + const numeric_index_type n, const numeric_index_type n_local, const std::vector& ghost, - const ParallelType ptype, - const Parallel::Communicator &comm) - : NumericVector(ptype, comm), + const ParallelType ptype) + : NumericVector(comm, ptype), _array_is_present(false), _local_form(NULL), _values(NULL), @@ -678,8 +675,9 @@ PetscVector::PetscVector (const numeric_index_type n, template inline -PetscVector::PetscVector (Vec v, const Parallel::Communicator &comm) - : NumericVector(AUTOMATIC, comm), +PetscVector::PetscVector (Vec v, + const Parallel::Communicator &comm) + : NumericVector(comm, AUTOMATIC), _array_is_present(false), _local_form(NULL), _values(NULL), @@ -1042,7 +1040,8 @@ template inline AutoPtr > PetscVector::zero_clone () const { - AutoPtr > cloned_vector (new PetscVector(this->type(), this->communicator())); + AutoPtr > cloned_vector + (new PetscVector(this->communicator(), this->type())); cloned_vector->init(*this); @@ -1055,7 +1054,8 @@ template inline AutoPtr > PetscVector::clone () const { - AutoPtr > cloned_vector (new PetscVector(this->type(), this->communicator())); + AutoPtr > cloned_vector + (new PetscVector(this->communicator(), this->type())); cloned_vector->init(*this, true); diff --git a/include/numerics/sparse_matrix.h b/include/numerics/sparse_matrix.h index 532509bae26..a751ab7ed8b 100644 --- a/include/numerics/sparse_matrix.h +++ b/include/numerics/sparse_matrix.h @@ -81,6 +81,7 @@ class SparseMatrix : public ReferenceCountedObject >, * the matrix before usage with * \p init(...). */ + explicit SparseMatrix (const Parallel::Communicator &comm LIBMESH_CAN_DEFAULT_TO_COMMWORLD); diff --git a/include/numerics/trilinos_epetra_vector.h b/include/numerics/trilinos_epetra_vector.h index c765657dd13..7520fe1faa9 100644 --- a/include/numerics/trilinos_epetra_vector.h +++ b/include/numerics/trilinos_epetra_vector.h @@ -65,40 +65,36 @@ class EpetraVector : public NumericVector * Dummy-Constructor. Dimension=0 */ explicit - EpetraVector (const ParallelType type = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + EpetraVector (const Parallel::Communicator &comm, + const ParallelType type = AUTOMATIC); /** * Constructor. Set dimension to \p n and initialize all elements with zero. */ explicit - EpetraVector (const numeric_index_type n, - const ParallelType type = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + EpetraVector (const Parallel::Communicator &comm, + const numeric_index_type n, + const ParallelType type = AUTOMATIC); /** * Constructor. Set local dimension to \p n_local, the global dimension * to \p n, and initialize all elements with zero. */ - EpetraVector (const numeric_index_type n, + EpetraVector (const Parallel::Communicator &comm, + const numeric_index_type n, const numeric_index_type n_local, - const ParallelType type = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + const ParallelType type = AUTOMATIC); /** * Constructor. Set local dimension to \p n_local, the global * dimension to \p n, but additionally reserve memory for the * indices specified by the \p ghost argument. */ - EpetraVector (const numeric_index_type N, + EpetraVector (const Parallel::Communicator &comm, + const numeric_index_type N, const numeric_index_type n_local, const std::vector& ghost, - const ParallelType type = AUTOMATIC, - const Parallel::Communicator &comm - LIBMESH_CAN_DEFAULT_TO_COMMWORLD); + const ParallelType type = AUTOMATIC); /** * Constructor. Creates a EpetraVector assuming you already have a @@ -108,7 +104,7 @@ class EpetraVector : public NumericVector * and to simply provide additional functionality with the EpetraVector. */ EpetraVector(Epetra_Vector & v, - const Parallel::Communicator &comm + const Parallel::Communicator &comm LIBMESH_CAN_DEFAULT_TO_COMMWORLD); /** @@ -630,9 +626,9 @@ class EpetraVector : public NumericVector template inline -EpetraVector::EpetraVector (const ParallelType type, - const Parallel::Communicator &comm) -: NumericVector(type, comm), +EpetraVector::EpetraVector (const Parallel::Communicator &comm, + const ParallelType type) +: NumericVector(comm, type), _destroy_vec_on_exit(true), myFirstID_(0), myNumIDs_(0), @@ -652,10 +648,10 @@ EpetraVector::EpetraVector (const ParallelType type, template inline -EpetraVector::EpetraVector (const numeric_index_type n, - const ParallelType type, - const Parallel::Communicator &comm) -: NumericVector(type, comm), +EpetraVector::EpetraVector (const Parallel::Communicator &comm, + const numeric_index_type n, + const ParallelType type) +: NumericVector(comm, type), _destroy_vec_on_exit(true), myFirstID_(0), myNumIDs_(0), @@ -676,11 +672,11 @@ EpetraVector::EpetraVector (const numeric_index_type n, template inline -EpetraVector::EpetraVector (const numeric_index_type n, +EpetraVector::EpetraVector (const Parallel::Communicator &comm, + const numeric_index_type n, const numeric_index_type n_local, - const ParallelType type, - const Parallel::Communicator &comm) -: NumericVector(type, comm), + const ParallelType type) +: NumericVector(comm, type), _destroy_vec_on_exit(true), myFirstID_(0), myNumIDs_(0), @@ -702,8 +698,8 @@ EpetraVector::EpetraVector (const numeric_index_type n, template inline EpetraVector::EpetraVector(Epetra_Vector & v, - const Parallel::Communicator &comm) - : NumericVector(AUTOMATIC, comm), + const Parallel::Communicator &comm) + : NumericVector(comm, AUTOMATIC), _destroy_vec_on_exit(false), myFirstID_(0), myNumIDs_(0), @@ -736,12 +732,12 @@ EpetraVector::EpetraVector(Epetra_Vector & v, template inline -EpetraVector::EpetraVector (const numeric_index_type n, +EpetraVector::EpetraVector (const Parallel::Communicator &comm, + const numeric_index_type n, const numeric_index_type n_local, const std::vector& ghost, - const ParallelType type, - const Parallel::Communicator &comm) -: NumericVector(AUTOMATIC, comm), + const ParallelType type) +: NumericVector(comm, AUTOMATIC), _destroy_vec_on_exit(true), myFirstID_(0), myNumIDs_(0), @@ -914,7 +910,8 @@ template inline AutoPtr > EpetraVector::zero_clone () const { - AutoPtr > cloned_vector (new EpetraVector(AUTOMATIC, this->communicator())); + AutoPtr > cloned_vector + (new EpetraVector(this->communicator(), AUTOMATIC)); cloned_vector->init(*this); @@ -927,7 +924,8 @@ template inline AutoPtr > EpetraVector::clone () const { - AutoPtr > cloned_vector (new EpetraVector(AUTOMATIC, this->communicator())); + AutoPtr > cloned_vector + (new EpetraVector(this->communicator(), AUTOMATIC)); cloned_vector->init(*this, true); diff --git a/src/mesh/boundary_mesh.C b/src/mesh/boundary_mesh.C index 89ece58a0a7..05267d5d1df 100644 --- a/src/mesh/boundary_mesh.C +++ b/src/mesh/boundary_mesh.C @@ -29,13 +29,23 @@ namespace libMesh // ------------------------------------------------------------ // BoundaryMesh class member functions -BoundaryMesh::BoundaryMesh(unsigned int d, - const Parallel::Communicator &comm) : - Mesh(d,comm) +BoundaryMesh::BoundaryMesh(const Parallel::Communicator &comm, + unsigned int d) : + Mesh(comm,d) { } +#ifndef LIBMESH_DISABLE_COMMWORLD +// ------------------------------------------------------------ +// BoundaryMesh class member functions +BoundaryMesh::BoundaryMesh(unsigned int d) : + Mesh(d) +{ +} +#endif + + BoundaryMesh::~BoundaryMesh() { diff --git a/src/mesh/mesh_base.C b/src/mesh/mesh_base.C index 498d43d6c6d..ba0ce421030 100644 --- a/src/mesh/mesh_base.C +++ b/src/mesh/mesh_base.C @@ -43,8 +43,8 @@ namespace libMesh // ------------------------------------------------------------ // MeshBase class member functions -MeshBase::MeshBase (unsigned int d, - const Parallel::Communicator &comm) : +MeshBase::MeshBase (const Parallel::Communicator &comm, + unsigned int d) : ParallelObject (comm), boundary_info (new BoundaryInfo(*this)), _n_parts (1), @@ -61,6 +61,25 @@ MeshBase::MeshBase (unsigned int d, } +#ifndef LIBMESH_DISABLE_COMMWORLD +MeshBase::MeshBase (unsigned int d) : + ParallelObject (CommWorld), + boundary_info (new BoundaryInfo(*this)), + _n_parts (1), + _dim (d), + _is_prepared (false), + _point_locator (NULL), + _partitioner (NULL), + _skip_partitioning(false), + _skip_renumber_nodes_and_elements(false) +{ + libmesh_assert_less_equal (LIBMESH_DIM, 3); + libmesh_assert_greater_equal (LIBMESH_DIM, _dim); + libmesh_assert (libMesh::initialized()); +} +#endif // !LIBMESH_DISABLE_COMMWORLD + + MeshBase::MeshBase (const MeshBase& other_mesh) : ParallelObject (other_mesh), diff --git a/src/mesh/parallel_mesh.C b/src/mesh/parallel_mesh.C index cc613d3bb5c..22b6570787c 100644 --- a/src/mesh/parallel_mesh.C +++ b/src/mesh/parallel_mesh.C @@ -31,9 +31,9 @@ namespace libMesh // ------------------------------------------------------------ // ParallelMesh class member functions -ParallelMesh::ParallelMesh (unsigned int d, - const Parallel::Communicator &comm) : - UnstructuredMesh (d,comm), _is_serial(true), +ParallelMesh::ParallelMesh (const Parallel::Communicator &comm, + unsigned int d) : + UnstructuredMesh (comm,d), _is_serial(true), _n_nodes(0), _n_elem(0), _max_node_id(0), _max_elem_id(0), _next_free_local_node_id(this->processor_id()), _next_free_local_elem_id(this->processor_id()), @@ -45,6 +45,23 @@ ParallelMesh::ParallelMesh (unsigned int d, } +#ifndef LIBMESH_DISABLE_COMMWORLD +// ------------------------------------------------------------ +// ParallelMesh class member functions +ParallelMesh::ParallelMesh (unsigned int d) : + UnstructuredMesh (d), _is_serial(true), + _n_nodes(0), _n_elem(0), _max_node_id(0), _max_elem_id(0), + _next_free_local_node_id(this->processor_id()), + _next_free_local_elem_id(this->processor_id()), + _next_free_unpartitioned_node_id(this->n_processors()), + _next_free_unpartitioned_elem_id(this->n_processors()) +{ + // FIXME: give parmetis the communicator! + _partitioner = AutoPtr(new ParmetisPartitioner()); +} +#endif + + ParallelMesh::~ParallelMesh () { this->clear(); // Free nodes and elements diff --git a/src/mesh/serial_mesh.C b/src/mesh/serial_mesh.C index 14d02c80c96..cd2fe02de24 100644 --- a/src/mesh/serial_mesh.C +++ b/src/mesh/serial_mesh.C @@ -32,14 +32,24 @@ namespace libMesh // ------------------------------------------------------------ // SerialMesh class member functions -SerialMesh::SerialMesh (unsigned int d, - const Parallel::Communicator &comm) : - UnstructuredMesh (d,comm) +SerialMesh::SerialMesh (const Parallel::Communicator &comm, + unsigned int d) : + UnstructuredMesh (comm,d) { _partitioner = AutoPtr(new MetisPartitioner()); } + +#ifndef LIBMESH_DISABLE_COMMWORLD +SerialMesh::SerialMesh (unsigned int d) : + UnstructuredMesh (d) +{ + _partitioner = AutoPtr(new MetisPartitioner()); +} +#endif + + SerialMesh::~SerialMesh () { this->clear(); // Free nodes and elements diff --git a/src/mesh/unstructured_mesh.C b/src/mesh/unstructured_mesh.C index 033712f1e5c..7afa7a48635 100644 --- a/src/mesh/unstructured_mesh.C +++ b/src/mesh/unstructured_mesh.C @@ -78,15 +78,25 @@ namespace libMesh // ------------------------------------------------------------ // UnstructuredMesh class member functions -UnstructuredMesh::UnstructuredMesh (unsigned int d, - const Parallel::Communicator &comm) : - MeshBase (d,comm) +UnstructuredMesh::UnstructuredMesh (const Parallel::Communicator &comm, + unsigned int d) : + MeshBase (comm,d) { libmesh_assert (libMesh::initialized()); } +#ifndef LIBMESH_DISABLE_COMMWORLD +UnstructuredMesh::UnstructuredMesh (unsigned int d) : + MeshBase (d) +{ + libmesh_assert (libMesh::initialized()); +} +#endif + + + void UnstructuredMesh::copy_nodes_and_elements (const UnstructuredMesh& other_mesh) { diff --git a/src/numerics/distributed_vector.C b/src/numerics/distributed_vector.C index c97fefbb8c2..aa435b5a0c8 100644 --- a/src/numerics/distributed_vector.C +++ b/src/numerics/distributed_vector.C @@ -522,7 +522,7 @@ void DistributedVector::localize (const numeric_index_type first_local_idx, // Build a parallel vector, initialize it with the local // parts of (*this) - DistributedVector parallel_vec; + DistributedVector parallel_vec(this->communicator()); parallel_vec.init (my_size, my_local_size, true, PARALLEL); diff --git a/src/numerics/numeric_vector.C b/src/numerics/numeric_vector.C index 5f8e6235b91..15e0aaccd66 100644 --- a/src/numerics/numeric_vector.C +++ b/src/numerics/numeric_vector.C @@ -53,7 +53,7 @@ NumericVector::build(const Parallel::Communicator &comm, const SolverPackage #ifdef LIBMESH_HAVE_LASPACK case LASPACK_SOLVERS: { - AutoPtr > ap(new LaspackVector(AUTOMATIC, comm)); + AutoPtr > ap(new LaspackVector(comm, AUTOMATIC)); return ap; } #endif @@ -62,7 +62,7 @@ NumericVector::build(const Parallel::Communicator &comm, const SolverPackage #ifdef LIBMESH_HAVE_PETSC case PETSC_SOLVERS: { - AutoPtr > ap(new PetscVector(AUTOMATIC, comm)); + AutoPtr > ap(new PetscVector(comm, AUTOMATIC)); return ap; } #endif @@ -71,7 +71,7 @@ NumericVector::build(const Parallel::Communicator &comm, const SolverPackage #ifdef LIBMESH_HAVE_TRILINOS case TRILINOS_SOLVERS: { - AutoPtr > ap(new EpetraVector(AUTOMATIC, comm)); + AutoPtr > ap(new EpetraVector(comm, AUTOMATIC)); return ap; } #endif @@ -80,14 +80,14 @@ NumericVector::build(const Parallel::Communicator &comm, const SolverPackage #ifdef LIBMESH_HAVE_EIGEN case EIGEN_SOLVERS: { - AutoPtr > ap(new EigenSparseVector(AUTOMATIC, comm)); + AutoPtr > ap(new EigenSparseVector(comm, AUTOMATIC)); return ap; } #endif default: - AutoPtr > ap(new DistributedVector(AUTOMATIC, comm)); + AutoPtr > ap(new DistributedVector(comm, AUTOMATIC)); return ap; } @@ -97,6 +97,17 @@ NumericVector::build(const Parallel::Communicator &comm, const SolverPackage } +#ifndef LIBMESH_DISABLE_COMMWORLD +template +AutoPtr > +NumericVector::build(const SolverPackage solver_package) +{ + libmesh_deprecated(); + return NumericVector::build(CommWorld, solver_package); +} +#endif + + template int NumericVector::compare (const NumericVector &other_vector, const Real threshold) const diff --git a/src/numerics/petsc_vector.C b/src/numerics/petsc_vector.C index e69290de6e9..787700c758d 100644 --- a/src/numerics/petsc_vector.C +++ b/src/numerics/petsc_vector.C @@ -957,7 +957,7 @@ void PetscVector::localize (const numeric_index_type first_local_idx, // Build a parallel vector, initialize it with the local // parts of (*this) - PetscVector parallel_vec(PARALLEL, this->communicator()); + PetscVector parallel_vec(this->communicator(), PARALLEL); parallel_vec.init (my_size, my_local_size, true, PARALLEL); diff --git a/src/numerics/trilinos_epetra_vector.C b/src/numerics/trilinos_epetra_vector.C index a0ae16c7927..d7d1c7f3be1 100644 --- a/src/numerics/trilinos_epetra_vector.C +++ b/src/numerics/trilinos_epetra_vector.C @@ -504,7 +504,7 @@ void EpetraVector::localize (const unsigned int first_local_idx, // Build a parallel vector, initialize it with the local // parts of (*this) - EpetraVector parallel_vec(PARALLEL, this->communicator()); + EpetraVector parallel_vec(this->communicator(), PARALLEL); parallel_vec.init (my_size, my_local_size, true, PARALLEL); diff --git a/tests/numerics/numeric_vector_test.h b/tests/numerics/numeric_vector_test.h index aa7a41062ee..181634147da 100644 --- a/tests/numerics/numeric_vector_test.h +++ b/tests/numerics/numeric_vector_test.h @@ -25,6 +25,8 @@ class NumericVectorTest : public CppUnit::TestCase { template void Localize(bool to_one=false) { + libMesh::Parallel::Communicator CommTest(libMesh::COMM_WORLD); + const processor_id_type root_pid = 0; unsigned int block_size = 10; @@ -37,7 +39,7 @@ class NumericVectorTest : public CppUnit::TestCase { global_size += (block_size + static_cast(p)); { - Base & v = *(new Derived(global_size, local_size)); + Base & v = *(new Derived(CommTest, global_size, local_size)); std::vector l(global_size); const dof_id_type