38 template<
typename MATRIX>
50 if (this->is_master_block_preconditioner())
53 if (this->gp_nmesh() == 0)
55 std::ostringstream err_msg;
56 err_msg <<
"There are no meshes set.\n"
57 <<
"Did you remember to call add_mesh(...)?";
59 err_msg.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
64 this->gp_preconditioner_set_all_meshes();
68 if (this->Silent_preconditioner_setup ==
true)
79 this->gp_preconditioner_block_setup();
82 unsigned nblock_types = this->nblock_types();
85 this->fill_in_subsidiary_preconditioners(nblock_types);
88 double t_extraction_total = 0.0;
91 double t_subsidiary_setup_total = 0.0;
96 if (Use_two_level_parallelisation)
102 for (
unsigned i = 0;
i < nblock_types;
i++)
112 i, get_other_diag_ds(
i, nblock_types), *block_diagonal_matrix_pt[
i]);
118 t_extraction_total += (t_extract_end - t_extract_start);
128 Preconditioner_array_pt->setup_preconditioners(
129 block_diagonal_matrix_pt,
130 this->Subsidiary_preconditioner_pt,
137 t_subsidiary_setup_total +=
138 (t_subsidiary_setup_end - t_subsidiary_setup_start);
141 for (
unsigned i = 0;
i < nblock_types;
i++)
143 delete block_diagonal_matrix_pt[
i];
144 block_diagonal_matrix_pt[
i] = 0;
149 this->Subsidiary_preconditioner_pt.clear();
154 for (
unsigned i = 0;
i < nblock_types;
i++)
157 unsigned j = get_other_diag_ds(
i, nblock_types);
169 t_extraction_total += (t_extract_end - t_extract_start);
175 this->Subsidiary_preconditioner_pt[
i]->setup(&block);
182 << t_subsidiary_setup_end - t_subsidiary_setup_start
183 <<
"s to setup." << std::endl;
186 t_subsidiary_setup_total +=
187 (t_subsidiary_setup_end - t_subsidiary_setup_start);
192 if (this->Silent_preconditioner_setup ==
true)
202 oomph_info <<
"Total block extraction time [sec]: " << t_extraction_total
203 <<
"\nTotal subsidiary preconditioner setup time [sec]: "
204 << t_subsidiary_setup_total << std::endl;
210 template<
typename MATRIX>
215 unsigned n_block = this->nblock_types();
219 this->get_block_vectors(r, block_r);
224 z.
build(this->distribution_pt(), 0.0);
230 if (Use_two_level_parallelisation)
232 Preconditioner_array_pt->solve_preconditioners(block_r, block_z);
237 for (
unsigned i = 0;
i < n_block;
i++)
239 double t_start = 0.0;
240 if (Doc_time_during_preconditioner_solve)
251 this->Subsidiary_preconditioner_pt[
i]) == 0)
253 this->Subsidiary_preconditioner_pt[
i]->preconditioner_solve(
254 block_r[
i], block_z[
i]);
267 this->return_block_vectors(block_r, r_updated);
270 this->Subsidiary_preconditioner_pt[
i]->preconditioner_solve(
271 r_updated, block_z_with_size_of_full_z);
275 this->get_block_vector(
i, block_z_with_size_of_full_z, block_z[
i]);
279 if (Doc_time_during_preconditioner_solve)
282 <<
"-th block preconditioner: "
289 this->return_block_vectors(block_z, z);
296 template<
typename MATRIX>
303 if (this->is_master_block_preconditioner())
306 if (this->gp_nmesh() == 0)
308 std::ostringstream err_msg;
309 err_msg <<
"There are no meshes set.\n"
310 <<
"Did you remember to call add_mesh(...)?";
312 err_msg.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
317 this->gp_preconditioner_set_all_meshes();
321 if (this->Silent_preconditioner_setup ==
true)
332 this->gp_preconditioner_block_setup();
335 unsigned nblock_types = this->nblock_types();
338 Off_diagonal_matrix_vector_products.resize(nblock_types, nblock_types, 0);
341 this->fill_in_subsidiary_preconditioners(nblock_types);
344 double t_extraction_total = 0.0;
347 double t_subsidiary_setup_total = 0.0;
350 double t_mvp_setup_total = 0.0;
353 for (
unsigned i = 0;
i < nblock_types;
i++)
367 t_extraction_total += (t_extract_end - t_extract_start);
373 this->Subsidiary_preconditioner_pt[
i]->setup(&block_matrix);
379 t_subsidiary_setup_total +=
380 (t_subsidiary_setup_end - t_subsidiary_setup_start);
385 if (Upper_triangular)
396 for (
unsigned j = l; j < u; j++)
408 t_extraction_total += (t_extract_end - t_extract_start);
418 this->setup_matrix_vector_product(
419 Off_diagonal_matrix_vector_products(
i, j), &block_matrix, j);
425 t_mvp_setup_total += (t_mvp_end - t_mvp_start);
430 oomph_info <<
"Total block extraction time [sec]: " << t_extraction_total
431 <<
"\nTotal subsidiary preconditioner setup time [sec]: "
432 << t_subsidiary_setup_total
433 <<
"\nTotal matrix-vector product setup time [sec]: "
434 << t_mvp_setup_total << std::endl;
437 if (this->Silent_preconditioner_setup ==
true)
450 template<
typename MATRIX>
455 unsigned n_block = this->nblock_types();
458 int start, end, step;
459 if (Upper_triangular)
476 this->get_block_vectors(r, block_r);
482 for (
int i =
start;
i != end;
i += step)
486 this->Subsidiary_preconditioner_pt[
i]) == 0)
489 this->Subsidiary_preconditioner_pt[
i]->preconditioner_solve(block_r[
i],
503 this->return_block_vectors(block_r, r_updated);
506 this->Subsidiary_preconditioner_pt[
i]->preconditioner_solve(
507 r_updated, block_z_with_size_of_full_z);
511 this->get_block_vector(
i, block_z_with_size_of_full_z, block_z[
i]);
515 for (
int j =
i + step; j != end; j += step)
518 Off_diagonal_matrix_vector_products(j,
i)->multiply(block_z[
i], temp);
524 this->return_block_vectors(block_z, z);
531 template<
typename MATRIX>
537 if (this->is_master_block_preconditioner())
540 if (this->gp_nmesh() == 0)
542 std::ostringstream err_msg;
543 err_msg <<
"There are no meshes set.\n"
544 <<
"Did you remember to call add_mesh(...)?";
546 err_msg.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
551 this->gp_preconditioner_set_all_meshes();
555 this->gp_preconditioner_block_setup();
558 unsigned nblock_types = this->nblock_types();
564 const bool want_block =
true;
565 for (
unsigned b_i = 0; b_i < nblock_types; b_i++)
567 for (
unsigned b_j = 0; b_j < nblock_types; b_j++)
569 required_blocks[b_i][b_j].select_block(b_i, b_j, want_block);
575 this->get_concatenated_block(required_blocks);
578 this->fill_in_subsidiary_preconditioners(1);
579 preconditioner_pt()->setup(&exact_block_matrix);
585 template<
typename MATRIX>
591 this->get_block_ordered_preconditioner_vector(r, block_order_r);
597 preconditioner_pt()->preconditioner_solve(block_order_r, block_order_z);
600 this->return_block_ordered_preconditioner_vector(block_order_z, z);
Block "anti-diagonal" preconditioner, i.e. same as block diagonal but along the other diagonal of the...
Block diagonal preconditioner. By default SuperLU is used to solve the subsidiary systems,...
void preconditioner_solve(const DoubleVector &r, DoubleVector &z)
Apply preconditioner to r.
virtual void setup()
Setup the preconditioner.
//////////////////////////////////////////////////////////////////////////// ////////////////////////...
void setup()
Setup the preconditioner.
void preconditioner_solve(const DoubleVector &r, DoubleVector &z)
Apply preconditioner to r.
A class for compressed row matrices. This is a distributable object.
LinearAlgebraDistribution * distribution_pt() const
access to the LinearAlgebraDistribution
A vector in the mathematical sense, initially developed for linear algebra type applications....
void build(const DoubleVector &old_vector)
Just copys the argument DoubleVector.
Preconditioner that doesn't actually do any preconditioning, it just allows access to the Jacobian bl...
//////////////////////////////////////////////////////////////////////////// ////////////////////////...
void preconditioner_solve(const DoubleVector &r, DoubleVector &z)
Apply preconditioner to r.
void setup()
Setup the preconditioner.
Matrix vector product helper class - primarily a wrapper to Trilinos's Epetra matrix vector product m...
std::ostream *& stream_pt()
Access function for the stream pointer.
An OomphLibError object which should be thrown when an run-time error is encountered....
PreconditionerArray - NOTE - first implementation, a number of assumptions / simplifications were mad...
VectorMatrix is a generalised, STL-map-based, matrix based on a Vector of Vectors.
A slight extension to the standard template vector class so that we can include "graceful" array rang...
void start(const unsigned &i)
(Re-)start i-th timer
void clean_up_memory()
Clean up function that deletes anything dynamically allocated in this namespace.
double timer()
returns the time in seconds after some point in past
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
Nullstream oomph_nullstream
///////////////////////////////////////////////////////////////////////// ///////////////////////////...
OomphInfo oomph_info
Single (global) instantiation of the OomphInfo object – this is used throughout the library as a "rep...