Skip to content

Commit

Permalink
Add LIBMESH_CAN_DEFAULT_TO_COMMWORLD macro
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
roystgnr committed Apr 10, 2013
1 parent 81ce5ab commit fd41d47
Show file tree
Hide file tree
Showing 24 changed files with 373 additions and 228 deletions.
16 changes: 14 additions & 2 deletions include/mesh/boundary_mesh.h
Expand Up @@ -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.
Expand Down
18 changes: 14 additions & 4 deletions include/mesh/mesh.h
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions include/mesh/mesh_base.h
Expand Up @@ -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.
Expand Down
16 changes: 13 additions & 3 deletions include/mesh/parallel_mesh.h
Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions include/mesh/serial_mesh.h
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions include/mesh/unstructured_mesh.h
Expand Up @@ -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.
Expand Down
61 changes: 30 additions & 31 deletions include/numerics/distributed_vector.h
Expand Up @@ -57,40 +57,36 @@ class DistributedVector : public NumericVector<T>
* 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<numeric_index_type>& 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
Expand Down Expand Up @@ -484,8 +480,9 @@ class DistributedVector : public NumericVector<T>
// DistributedVector inline methods
template <typename T>
inline
DistributedVector<T>::DistributedVector (const ParallelType ptype, const Parallel::Communicator &comm)
: NumericVector<T>(ptype, comm),
DistributedVector<T>::DistributedVector (const Parallel::Communicator &comm,
const ParallelType ptype)
: NumericVector<T>(comm, ptype),
_global_size (0),
_local_size (0),
_first_local_index(0),
Expand All @@ -498,10 +495,10 @@ DistributedVector<T>::DistributedVector (const ParallelType ptype, const Paralle

template <typename T>
inline
DistributedVector<T>::DistributedVector (const numeric_index_type n,
const ParallelType ptype,
const Parallel::Communicator &comm)
: NumericVector<T>(ptype, comm)
DistributedVector<T>::DistributedVector (const Parallel::Communicator &comm,
const numeric_index_type n,
const ParallelType ptype)
: NumericVector<T>(comm, ptype)
{
this->init(n, n, false, ptype);
}
Expand All @@ -510,11 +507,11 @@ DistributedVector<T>::DistributedVector (const numeric_index_type n,

template <typename T>
inline
DistributedVector<T>::DistributedVector (const numeric_index_type n,
DistributedVector<T>::DistributedVector (const Parallel::Communicator &comm,
const numeric_index_type n,
const numeric_index_type n_local,
const ParallelType ptype,
const Parallel::Communicator &comm)
: NumericVector<T>(ptype, comm)
const ParallelType ptype)
: NumericVector<T>(comm, ptype)
{
this->init(n, n_local, false, ptype);
}
Expand All @@ -523,12 +520,12 @@ DistributedVector<T>::DistributedVector (const numeric_index_type n,

template <typename T>
inline
DistributedVector<T>::DistributedVector (const numeric_index_type n,
DistributedVector<T>::DistributedVector (const Parallel::Communicator &comm,
const numeric_index_type n,
const numeric_index_type n_local,
const std::vector<numeric_index_type>& ghost,
const ParallelType ptype,
const Parallel::Communicator &comm)
: NumericVector<T>(ptype, comm)
const ParallelType ptype)
: NumericVector<T>(comm, ptype)
{
this->init(n, n_local, ghost, false, ptype);
}
Expand Down Expand Up @@ -712,7 +709,8 @@ template <typename T>
inline
AutoPtr<NumericVector<T> > DistributedVector<T>::zero_clone () const
{
AutoPtr<NumericVector<T> > cloned_vector (new DistributedVector<T>);
AutoPtr<NumericVector<T> > cloned_vector
(new DistributedVector<T>(this->communicator()));

cloned_vector->init(*this);

Expand All @@ -725,7 +723,8 @@ template <typename T>
inline
AutoPtr<NumericVector<T> > DistributedVector<T>::clone () const
{
AutoPtr<NumericVector<T> > cloned_vector (new DistributedVector<T>);
AutoPtr<NumericVector<T> > cloned_vector
(new DistributedVector<T>(this->communicator()));

cloned_vector->init(*this, true);

Expand Down
61 changes: 30 additions & 31 deletions include/numerics/eigen_sparse_vector.h
Expand Up @@ -61,40 +61,36 @@ class EigenSparseVector : public NumericVector<T>
* 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<numeric_index_type>& ghost,
const ParallelType = AUTOMATIC,
const Parallel::Communicator &comm
LIBMESH_CAN_DEFAULT_TO_COMMWORLD);
const ParallelType = AUTOMATIC);

/**
* Destructor, deallocates memory. Made virtual to allow
Expand Down Expand Up @@ -482,8 +478,9 @@ class EigenSparseVector : public NumericVector<T>
// EigenSparseVector inline methods
template <typename T>
inline
EigenSparseVector<T>::EigenSparseVector (const ParallelType ptype, const Parallel::Communicator &comm)
: NumericVector<T>(ptype, comm)
EigenSparseVector<T>::EigenSparseVector (const Parallel::Communicator &comm,
const ParallelType ptype)
: NumericVector<T>(comm, ptype)
{
this->_type = ptype;
}
Expand All @@ -492,10 +489,10 @@ EigenSparseVector<T>::EigenSparseVector (const ParallelType ptype, const Paralle

template <typename T>
inline
EigenSparseVector<T>::EigenSparseVector (const numeric_index_type n,
const ParallelType ptype,
const Parallel::Communicator &comm)
: NumericVector<T>(ptype, comm)
EigenSparseVector<T>::EigenSparseVector (const Parallel::Communicator &comm,
const numeric_index_type n,
const ParallelType ptype)
: NumericVector<T>(comm, ptype)
{
this->init(n, n, false, ptype);
}
Expand All @@ -504,11 +501,11 @@ EigenSparseVector<T>::EigenSparseVector (const numeric_index_type n,

template <typename T>
inline
EigenSparseVector<T>::EigenSparseVector (const numeric_index_type n,
EigenSparseVector<T>::EigenSparseVector (const Parallel::Communicator &comm,
const numeric_index_type n,
const numeric_index_type n_local,
const ParallelType ptype,
const Parallel::Communicator &comm)
: NumericVector<T>(ptype, comm)
const ParallelType ptype)
: NumericVector<T>(comm, ptype)
{
this->init(n, n_local, false, ptype);
}
Expand All @@ -517,12 +514,12 @@ EigenSparseVector<T>::EigenSparseVector (const numeric_index_type n,

template <typename T>
inline
EigenSparseVector<T>::EigenSparseVector (const numeric_index_type N,
EigenSparseVector<T>::EigenSparseVector (const Parallel::Communicator &comm,
const numeric_index_type N,
const numeric_index_type n_local,
const std::vector<numeric_index_type>& ghost,
const ParallelType ptype,
const Parallel::Communicator &comm)
: NumericVector<T>(ptype, comm)
const ParallelType ptype)
: NumericVector<T>(comm, ptype)
{
this->init(N, n_local, ghost, false, ptype);
}
Expand Down Expand Up @@ -648,7 +645,8 @@ template <typename T>
inline
AutoPtr<NumericVector<T> > EigenSparseVector<T>::zero_clone () const
{
AutoPtr<NumericVector<T> > cloned_vector (new EigenSparseVector<T>);
AutoPtr<NumericVector<T> > cloned_vector
(new EigenSparseVector<T>(this->communicator()));

cloned_vector->init(*this);

Expand All @@ -661,7 +659,8 @@ template <typename T>
inline
AutoPtr<NumericVector<T> > EigenSparseVector<T>::clone () const
{
AutoPtr<NumericVector<T> > cloned_vector (new EigenSparseVector<T>);
AutoPtr<NumericVector<T> > cloned_vector
(new EigenSparseVector<T>(this->communicator()));

cloned_vector->init(*this, true);

Expand Down

0 comments on commit fd41d47

Please sign in to comment.