30 #ifndef OOMPH_LINEAR_ALGEBRA_DISTRIBUTION_CLASS_HEADER 31 #define OOMPH_LINEAR_ALGEBRA_DISTRIBUTION_CLASS_HEADER 35 #include <oomph-lib-config.h> 81 const unsigned &first_row_,
82 const unsigned &n_row_local,
83 const unsigned &n_row = 0)
86 this->
build(&comm,first_row_,n_row_local,n_row);
93 const unsigned &n_row,
94 const bool &distributed_ =
true)
97 this->
build(&comm,n_row,distributed_);
104 const unsigned &first_row_,
105 const unsigned &n_row_local,
106 const unsigned &n_row = 0)
109 this->
build(comm_pt,first_row_,n_row_local,n_row);
116 const unsigned &n_row,
117 const bool &distributed_ =
true)
120 this->
build(comm_pt,n_row,distributed_);
127 this->
build(old_dist);
134 this->
build(old_dist_pt);
146 this->
build(old_dist);
155 const unsigned&
nrow = 0);
163 const unsigned&
nrow,
174 this->
build(*new_dist_pt);
210 throw OomphLibError(
"LinearAlgebraDistribution has not been built : Comm_pt == 0.",
211 "LinearAlgebraDistribution::nrow_local()",
212 OOMPH_EXCEPTION_LOCATION);
235 "LinearAlgebraDistribution has not been built : Comm_pt == 0.",
236 OOMPH_CURRENT_FUNCTION,
237 OOMPH_EXCEPTION_LOCATION);
239 if (p >=
unsigned(
Comm_pt->nproc()))
241 std::ostringstream error_message;
243 <<
"Requested nrow_local(" << p <<
"), but this distribution is defined " 244 <<
"on " <<
Comm_pt->nproc() <<
"processors.";
246 OOMPH_CURRENT_FUNCTION,
247 OOMPH_EXCEPTION_LOCATION);
279 (
"LinearAlgebraDistribution has not been built : Comm_pt == 0.",
280 OOMPH_CURRENT_FUNCTION,
281 OOMPH_EXCEPTION_LOCATION);
303 (
"LinearAlgebraDistribution has not been built : Comm_pt == 0.",
304 OOMPH_CURRENT_FUNCTION,
305 OOMPH_EXCEPTION_LOCATION);
307 if (p >=
unsigned(
Comm_pt->nproc()))
309 std::ostringstream error_message;
311 <<
"Requested first_row(" << p <<
"), but this distribution is defined " 312 <<
"on " <<
Comm_pt->nproc() <<
"processors.";
314 OOMPH_CURRENT_FUNCTION,
315 OOMPH_EXCEPTION_LOCATION);
365 return !(*
this == other_dist);
369 friend std::ostream&
operator<<(std::ostream& stream,
376 if (global_i >=
Nrow)
379 (
"Requested global row outside the number of global rows",
380 OOMPH_CURRENT_FUNCTION,
381 OOMPH_EXCEPTION_LOCATION);
384 int local_i =
static_cast<int>(global_i);
386 while ((
int)(local_i - (int)
nrow_local(p)) >= 0)
391 return (
unsigned)local_i;
470 delete Distribution_pt;
476 return Distribution_pt;
482 return Distribution_pt->nrow();
488 return Distribution_pt->nrow_local();
494 return Distribution_pt->nrow_local(p);
500 return Distribution_pt->first_row();
506 return Distribution_pt->first_row(p);
512 return Distribution_pt->distributed();
519 return Distribution_pt->built();
526 Distribution_pt->build(dist_pt);
533 Distribution_pt->build(dist);
542 Distribution_pt->clear();
554 namespace LinearAlgebraDistributionHelpers
LinearAlgebraDistribution(const OomphCommunicator *const comm_pt, const unsigned &n_row, const bool &distributed_=true)
Constructor. Takes the number of global rows and uniformly distributes them over the processors if di...
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
friend std::ostream & operator<<(std::ostream &stream, LinearAlgebraDistribution &dist)
<< operator
void build(const LinearAlgebraDistribution *new_dist_pt)
Copy the argument distribution. Also a helper method for the =assignment operator and copy constructo...
LinearAlgebraDistribution(const OomphCommunicator &comm, const unsigned &n_row, const bool &distributed_=true)
Constructor. Takes the number of global rows and uniformly distributes them over the processors if di...
void operator=(const DistributableLinearAlgebraObject &)
Broken assignment operator.
Vector< unsigned > First_row
the first row on this processor
LinearAlgebraDistribution * Distribution_pt
the LinearAlgebraDistribution object
OomphCommunicator * communicator_pt() const
const access to the communicator pointer
LinearAlgebraDistribution(const LinearAlgebraDistribution *old_dist_pt)
pointer based copy constructor
void build(const OomphCommunicator *const comm_pt, const unsigned &first_row, const unsigned &nrow_local, const unsigned &nrow=0)
Sets the distribution. Takes first_row, nrow_local and nrow as arguments. If nrow is not provided or ...
OomphCommunicator * Comm_pt
the pointer to the MPI communicator object in this distribution
Vector< unsigned > Nrow_local
the number of local rows on the processor
unsigned nrow() const
access function to the number of global rows.
DistributableLinearAlgebraObject()
Default constructor - create a distribution.
unsigned first_row() const
access function for the first row on this processor. If not distributed then this is just zero...
bool distributed() const
access function to the distributed - indicates whether the distribution is serial or distributed ...
~LinearAlgebraDistribution()
Destructor.
unsigned nrow_local(const unsigned &p) const
access function for the num of local rows on this processor.
Vector< unsigned > first_row_vector() const
return the first_row Vector
unsigned Nrow
the number of global rows
bool distribution_built() const
LinearAlgebraDistribution(const LinearAlgebraDistribution &old_dist)
Copy Constructor.
bool distributed() const
distribution is serial or distributed
Describes the distribution of a distributable linear algebra type object. Typically this is a contain...
Base class for any linear algebra object that is distributable. Just contains storage for the LinearA...
void operator=(const LinearAlgebraDistribution &old_dist)
Assignment Operator.
bool operator!=(const LinearAlgebraDistribution &other_dist) const
!= operator
Vector< unsigned > nrow_local_vector() const
return the nrow_local Vector
unsigned nrow_local() const
access function for the num of local rows on this processor. If no MPI then Nrow is returned...
unsigned first_row() const
access function for the first row on this processor
bool operator==(const LinearAlgebraDistribution &other_dist) const
== Operator
void clear_distribution()
clear the distribution of this distributable linear algebra object
unsigned nrow_local(const unsigned &p) const
access function for the num of local rows on this processor. If no MPI the nrow is returned ...
unsigned rank_of_global_row(const unsigned i) const
return the processor rank of the global row number i
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
unsigned nrow() const
access function to the number of global rows.
LinearAlgebraDistribution(const OomphCommunicator *const comm_pt, const unsigned &first_row_, const unsigned &n_row_local, const unsigned &n_row=0)
Constructor. Takes the first_row, nrow_local (both for this processor) and nrow as arguments...
unsigned first_row(const unsigned &p) const
access function for the first row on this processor
void build_distribution(const LinearAlgebraDistribution &dist)
setup the distribution of this distributable linear algebra object
void build_distribution(const LinearAlgebraDistribution *const dist_pt)
setup the distribution of this distributable linear algebra object
unsigned nrow_local() const
access function for the num of local rows on this processor.
void concatenate(const Vector< DoubleVector *> &in_vector_pt, DoubleVector &out_vector)
Concatenate DoubleVectors. Takes a Vector of DoubleVectors. If the out vector is built, we will not build a new distribution. Otherwise we build a uniform distribution.
void clear()
clears the distribution
virtual ~DistributableLinearAlgebraObject()
Destructor.
LinearAlgebraDistribution(const OomphCommunicator &comm, const unsigned &first_row_, const unsigned &n_row_local, const unsigned &n_row=0)
Constructor. Takes the first_row, nrow_local (both for this processor) and nrow as arguments...
LinearAlgebraDistribution()
Default Constructor - creates a Distribution that has not been setup.
unsigned first_row(const unsigned &p) const
access function for the first row on the p-th processor
LinearAlgebraDistribution * distribution_pt() const
access to the LinearAlgebraDistribution
unsigned global_to_local_row_map(const unsigned &global_i) const
return the local index corresponding to the global index
An oomph-lib wrapper to the MPI_Comm communicator object. Just contains an MPI_Comm object (which is ...