39 : Distribution_pt(dist_pt)
51 std::map<unsigned, Vector<unsigned>> to_be_haloed;
55 std::map<unsigned, Vector<unsigned>> halo_entries;
58 const unsigned my_rank =
63 const unsigned n_global_eqn = required_global_eqn.size();
66 for (
unsigned n = 0; n < n_global_eqn; n++)
69 const unsigned i_global = required_global_eqn[n];
74 if (my_rank != rank_of_global)
77 unsigned i_local = i_global - dist_pt->
first_row(rank_of_global);
79 halo_entries[rank_of_global].push_back(index);
82 to_be_haloed[rank_of_global].push_back(i_local);
99 int send_data_count = 0;
104 to_be_haloed.begin();
105 it != to_be_haloed.end();
108 const unsigned rank = it->first;
109 const unsigned size_ = it->second.size();
111 send_displacement[rank] = send_data_count;
113 send_n[rank] =
static_cast<int>(size_);
114 send_data_count += size_;
122 MPI_Alltoall(&send_n[0],
132 if (send_data_count == 0)
140 to_be_haloed.begin();
141 it != to_be_haloed.end();
146 it2 != it->second.end();
149 send_data[count] = (*it2);
156 int receive_data_count = 0;
158 for (
int d = 0; d < n_proc; d++)
167 if (receive_data_count == 0)
169 ++receive_data_count;
173 MPI_Alltoallv(&send_data[0],
175 &send_displacement[0],
189 unsigned receive_haloed_count = 0;
190 for (
int d = 0; d < n_proc; d++)
193 std::map<unsigned, Vector<unsigned>>::iterator it =
194 halo_entries.find(d);
196 if (it == halo_entries.end())
204 const int size_ = it->second.size();
207 Halo_eqns.resize(receive_haloed_count + size_);
208 for (
int i = 0;
i < size_;
i++)
210 Halo_eqns[receive_haloed_count +
i] = it->second[
i];
212 receive_haloed_count += size_;
226 const std::map<unsigned, double*>& halo_data_pt,
232 halo_dof_pt.resize(n_halo);
235 for (std::map<unsigned, unsigned>::iterator it =
Local_index.begin();
240 std::map<unsigned, double*>::const_iterator it2 =
241 halo_data_pt.find(it->first);
243 if (it2 != halo_data_pt.end())
246 halo_dof_pt[it->second] = it2->second;
250 std::ostringstream error_stream;
251 error_stream <<
"Global equation " << it->first
252 <<
" reqired as halo is not stored in halo_data_pt\n";
255 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
279 for (
unsigned i = 0;
i < n_send;
i++)
295 receive_data.resize(1);
298 MPI_Alltoallv(&send_data[0],
306 this->distribution_pt()->communicator_pt()->mpi_comm());
310 for (
unsigned i = 0;
i < n_receive;
i++)
333 for (
unsigned i = 0;
i < n_send;
i++)
349 receive_data.resize(1);
352 MPI_Alltoallv(&send_data[0],
360 this->distribution_pt()->communicator_pt()->mpi_comm());
364 for (
unsigned i = 0;
i < n_receive;
i++)
bool distributed() const
distribution is serial or distributed
A class that stores the halo/haloed entries required when using a DoubleVectorWithHaloEntries....
Vector< int > Haloed_n
Storage for the number of haloed entries to be sent to each processor.
Vector< int > Halo_displacement
Storage for the offsets of the processor data in the receive buffer.
Vector< int > Halo_n
Storage for the number of entries to be received from each other processor.
std::map< unsigned, unsigned > Local_index
Storage for the translation scheme from global unknown to local index in the additional storage vecto...
Vector< int > Haloed_displacement
Storage for the offsets of the haloed entries for each processor in the packed Haloed_eqns array.
void setup_halo_dofs(const std::map< unsigned, double * > &halo_data_pt, Vector< double * > &halo_dof_pt)
Function that sets up a vector of pointers to halo data, index using the scheme in Local_index.
Vector< unsigned > Haloed_eqns
The haloed entries that will be sent in a format compatible with MPI_Alltoallv i.e....
DoubleVectorHaloScheme(LinearAlgebraDistribution *const &dist_pt, const Vector< unsigned > &required_global_eqn)
Constructor that sets up the required information communicating between all processors....
Vector< unsigned > Halo_eqns
Storage for all the entries that are to be received from other processors (received_from_proc0,...
void build_halo_scheme(DoubleVectorHaloScheme *const &halo_scheme_pt)
Construct the halo scheme and storage for the halo data.
DoubleVectorHaloScheme * Halo_scheme_pt
Pointer to the lookup scheme that stores information about on which processor the required informatio...
void synchronise()
Synchronise the halo data.
void sum_all_halo_and_haloed_values()
Sum all the data, store in the master (haloed) data and then synchronise.
DoubleVectorHaloScheme *& halo_scheme_pt()
Access function for halo scheme.
Vector< double > Halo_value
Vector of the halo values.
Describes the distribution of a distributable linear algebra type object. Typically this is a contain...
bool distributed() const
access function to the distributed - indicates whether the distribution is serial or distributed
unsigned first_row() const
access function for the first row on this processor. If not distributed then this is just zero.
OomphCommunicator * communicator_pt() const
const access to the communicator pointer
unsigned rank_of_global_row(const unsigned i) const
return the processor rank of the global row number i
An OomphLibError object which should be thrown when an run-time error is encountered....
//////////////////////////////////////////////////////////////////// ////////////////////////////////...