Driver code for generic mpi stuff.
///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
265 MPI_Helpers::init(argc,argv);
271 std::ofstream output_stream;
273 sprintf(
filename,
"OUTPUT.%i",MPI_Helpers::communicator_pt()->my_rank());
276 OomphLibWarning::set_stream_pt(&output_stream);
277 OomphLibError::set_stream_pt(&output_stream);
283 unsigned my_rank = comm_pt->
my_rank();
284 unsigned nproc = comm_pt->
nproc();
287 oomph_info <<
"I'm rank " << my_rank <<
" on a total of "
288 << nproc <<
" processors" << std::endl;
296 unsigned nrow_global = 100;
301 oomph_info <<
"distributed distribution: first_row and nrow_local: "
302 << distributed_distribution.first_row() <<
" "
303 << distributed_distribution.nrow_local()
312 bool distributed=
false;
313 locally_replicated_distribution.
build(comm_pt,nrow_global,distributed);
316 oomph_info <<
"locally replicated distribution: first_row and nrow_local: "
317 << locally_replicated_distribution.
first_row() <<
" "
318 << locally_replicated_distribution.
nrow_local()
322 unsigned nrow_local = distributed_distribution.nrow_local();
325 unsigned first_row = distributed_distribution.first_row();
328 nrow_global = distributed_distribution.nrow();
331 distributed = distributed_distribution.distributed();
334 bool built = distributed_distribution.built();
342 nrow_local = my_vector.distribution_pt()->nrow_local();
343 for (
unsigned i = 0;
i < nrow_local;
i++)
349 nrow_local = my_vector.distribution_pt()->nrow_local();
350 first_row = my_vector.distribution_pt()->first_row();
351 for (
unsigned i = 0;
i < nrow_local;
i++)
354 <<
" is global row " << first_row+
i
355 <<
" and has value " << my_vector[
i] << std::endl;
359 my_vector.redistribute(&locally_replicated_distribution);
363 my_vector.build(distributed_distribution,1.0);
376 my_matrix.
build(&distributed_distribution);
389 for (
unsigned i = 0;
i < nrow_local; ++
i)
391 column_indices[
i]=first_row+nrow_local;
394 row_start[nrow_local]=nrow_local;
397 unsigned ncol = nrow_global;
398 my_matrix.
build(ncol,values,column_indices,row_start);
401 column_indices,row_start);
404 first_row = my_matrix2.distribution_pt()->first_row();
407 first_row = my_matrix2.first_row();
416 unsigned n_element=40;
426 problem.get_jacobian(my_vector,my_matrix);
429 <<
"Uniformly distributed residual vector: first_row and nrow_local: "
430 << my_vector.first_row() <<
" "
431 << my_vector.nrow_local() << std::endl
432 <<
"Uniformly distributed jacobian matrix: first_row, nrow_local and nnz: "
435 << my_matrix.
nnz() <<
" "
442 comm_pt,
problem.ndof(),distributed);
446 <<
"locally replicated distribution_for_jac: first_row and nrow_local: "
447 << locally_replicated_distribution_for_jac.first_row() <<
" "
448 << locally_replicated_distribution_for_jac.nrow_local()
451 my_vector.build(locally_replicated_distribution_for_jac);
452 my_matrix.
build(&locally_replicated_distribution_for_jac);
455 problem.get_jacobian(my_vector,my_matrix);
458 <<
"Replicated residual vector: first_row and nrow_local: "
459 << my_vector.first_row() <<
" "
460 << my_vector.nrow_local() << std::endl
461 <<
"Replicated jacobian matrix: first_row, nrow_local and nnz: "
464 << my_matrix.
nnz() <<
" "
468 MPI_Helpers::finalize();
int i
Definition: BiCGSTAB_step_by_step.cpp:9
1D Poisson problem in unit interval.
Definition: linear_solvers/direct_solver_test.cc:81
Definition: matrices.h:888
void clear()
clear
Definition: matrices.cc:1657
unsigned long nnz() const
Return the number of nonzero entries (the local nnz)
Definition: matrices.h:1096
void build(const LinearAlgebraDistribution *distribution_pt, const unsigned &ncol, const Vector< double > &value, const Vector< int > &column_index, const Vector< int > &row_start)
Definition: matrices.cc:1672
unsigned nrow_local() const
access function for the num of local rows on this processor.
Definition: linear_algebra_distribution.h:469
unsigned first_row() const
access function for the first row on this processor
Definition: linear_algebra_distribution.h:481
Definition: double_vector.h:58
void clear()
wipes the DoubleVector
Definition: double_vector.h:142
Definition: linear_algebra_distribution.h:64
unsigned first_row() const
Definition: linear_algebra_distribution.h:261
void build(const OomphCommunicator *const comm_pt, const unsigned &first_row, const unsigned &nrow_local, const unsigned &nrow=0)
Definition: linear_algebra_distribution.cc:35
unsigned nrow_local() const
Definition: linear_algebra_distribution.h:193
Definition: communicator.h:54
int my_rank() const
my rank
Definition: communicator.h:176
int nproc() const
number of processors
Definition: communicator.h:157
std::ostream *& stream_pt()
Access function for the stream pointer.
Definition: oomph_definitions.h:464
OutputModifier *& output_modifier_pt()
Access function for the output modifier pointer.
Definition: oomph_definitions.h:476
void source_function(const Vector< double > &x, double &source)
Source function required to make the fish shape an exact solution.
Definition: linear_solvers/direct_solver_test.cc:63
string filename
Definition: MergeRestartFiles.py:39
OutputModifier default_output_modifier
Single global instatiation of the default output modifier.
Definition: oomph_definitions.cc:325
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213