26 #ifndef OOMPH_LINEAR_ALGEBRA_DISTRIBUTION_CLASS_HEADER
27 #define OOMPH_LINEAR_ALGEBRA_DISTRIBUTION_CLASS_HEADER
31 #include <oomph-lib-config.h>
74 const unsigned& first_row_,
75 const unsigned& n_row_local,
76 const unsigned& n_row = 0)
79 this->
build(&comm, first_row_, n_row_local, n_row);
86 const unsigned& n_row,
87 const bool& distributed_ =
true)
90 this->
build(&comm, n_row, distributed_);
97 const unsigned& first_row_,
98 const unsigned& n_row_local,
99 const unsigned& n_row = 0)
102 this->
build(comm_pt, first_row_, n_row_local, n_row);
109 const unsigned& n_row,
110 const bool& distributed_ =
true)
113 this->
build(comm_pt, n_row, distributed_);
120 this->
build(old_dist);
127 this->
build(old_dist_pt);
139 this->
build(old_dist);
148 const unsigned&
nrow = 0);
156 const unsigned&
nrow,
167 this->
build(*new_dist_pt);
203 "LinearAlgebraDistribution has not been built : Comm_pt == 0.",
204 "LinearAlgebraDistribution::nrow_local()",
205 OOMPH_EXCEPTION_LOCATION);
228 "LinearAlgebraDistribution has not been built : Comm_pt == 0.",
229 OOMPH_CURRENT_FUNCTION,
230 OOMPH_EXCEPTION_LOCATION);
232 if (p >=
unsigned(
Comm_pt->nproc()))
234 std::ostringstream error_message;
235 error_message <<
"Requested nrow_local(" << p
236 <<
"), but this distribution is defined "
237 <<
"on " <<
Comm_pt->nproc() <<
"processors.";
239 OOMPH_CURRENT_FUNCTION,
240 OOMPH_EXCEPTION_LOCATION);
271 "LinearAlgebraDistribution has not been built : Comm_pt == 0.",
272 OOMPH_CURRENT_FUNCTION,
273 OOMPH_EXCEPTION_LOCATION);
295 "LinearAlgebraDistribution has not been built : Comm_pt == 0.",
296 OOMPH_CURRENT_FUNCTION,
297 OOMPH_EXCEPTION_LOCATION);
299 if (p >=
unsigned(
Comm_pt->nproc()))
301 std::ostringstream error_message;
302 error_message <<
"Requested first_row(" << p
303 <<
"), but this distribution is defined "
304 <<
"on " <<
Comm_pt->nproc() <<
"processors.";
306 OOMPH_CURRENT_FUNCTION,
307 OOMPH_EXCEPTION_LOCATION);
357 return !(*
this == other_dist);
361 friend std::ostream&
operator<<(std::ostream& stream,
368 if (global_i >=
Nrow)
371 "Requested global row outside the number of global rows",
372 OOMPH_CURRENT_FUNCTION,
373 OOMPH_EXCEPTION_LOCATION);
376 int local_i =
static_cast<int>(global_i);
378 while ((
int)(local_i - (int)
nrow_local(p)) >= 0)
383 return (
unsigned)local_i;
535 namespace LinearAlgebraDistributionHelpers
Base class for any linear algebra object that is distributable. Just contains storage for the LinearA...
unsigned nrow_local(const unsigned &p) const
access function for the num of local rows on this processor.
void clear_distribution()
clear the distribution of this distributable linear algebra object
virtual ~DistributableLinearAlgebraObject()
Destructor.
unsigned first_row(const unsigned &p) const
access function for the first row on this processor
bool distributed() const
distribution is serial or distributed
LinearAlgebraDistribution * distribution_pt() const
access to the LinearAlgebraDistribution
DistributableLinearAlgebraObject(const DistributableLinearAlgebraObject &matrix)=delete
Broken copy constructor.
unsigned nrow() const
access function to the number of global rows.
bool distribution_built() const
if the communicator_pt is null then the distribution is not setup then false is returned,...
LinearAlgebraDistribution * Distribution_pt
the LinearAlgebraDistribution object
unsigned nrow_local() const
access function for the num of local rows on this processor.
unsigned first_row() const
access function for the first row on this processor
void build_distribution(const LinearAlgebraDistribution *const dist_pt)
setup the distribution of this distributable linear algebra object
DistributableLinearAlgebraObject()
Default constructor - create a distribution.
void operator=(const DistributableLinearAlgebraObject &)=delete
Broken assignment operator.
void build_distribution(const LinearAlgebraDistribution &dist)
setup the distribution of this distributable linear algebra object
Describes the distribution of a distributable linear algebra type object. Typically this is a contain...
void operator=(const LinearAlgebraDistribution &old_dist)
Assignment Operator.
bool distributed() const
access function to the distributed - indicates whether the distribution is serial or distributed
Vector< unsigned > first_row_vector() const
return the first_row Vector
unsigned first_row(const unsigned &p) const
access function for the first row on the p-th processor
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
access function for the first row on this processor. If not distributed then this is just zero.
bool operator==(const LinearAlgebraDistribution &other_dist) const
== Operator
OomphCommunicator * communicator_pt() const
const access to the communicator pointer
friend std::ostream & operator<<(std::ostream &stream, LinearAlgebraDistribution &dist)
<< operator
Vector< unsigned > Nrow_local
the number of local rows on the processor
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 ...
~LinearAlgebraDistribution()
Destructor.
bool operator!=(const LinearAlgebraDistribution &other_dist) const
!= operator
OomphCommunicator * Comm_pt
the pointer to the MPI communicator object in this distribution
unsigned Nrow
the number of global rows
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...
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...
Vector< unsigned > First_row
the first row on this processor
unsigned global_to_local_row_map(const unsigned &global_i) const
return the local index corresponding to the global index
Vector< unsigned > nrow_local_vector() const
return the nrow_local Vector
bool built() const
if the communicator_pt is null then the distribution is not setup then false is returned,...
bool Distributed
flag to indicate whether this distribution describes an object that is distributed over the processor...
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 nrow() const
access function to the number of global rows.
void clear()
clears the distribution
unsigned nrow_local() const
access function for the num of local rows on this processor. If no MPI then Nrow is returned.
unsigned rank_of_global_row(const unsigned i) const
return the processor rank of the global row number i
LinearAlgebraDistribution(const LinearAlgebraDistribution &old_dist)
Copy Constructor.
LinearAlgebraDistribution()
Default Constructor - creates a Distribution that has not been setup.
LinearAlgebraDistribution(const LinearAlgebraDistribution *old_dist_pt)
pointer based copy constructor
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 &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....
An oomph-lib wrapper to the MPI_Comm communicator object. Just contains an MPI_Comm object (which is ...
An OomphLibError object which should be thrown when an run-time error is encountered....
void concatenate(const Vector< LinearAlgebraDistribution * > &in_distribution_pt, LinearAlgebraDistribution &out_distribution)
Takes a vector of LinearAlgebraDistribution objects and concatenates them such that the nrow_local of...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...