oomph::TwoPlusThreeUpperTriangularWithReplace< MATRIX > Class Template Reference

#include <multi_poisson_block_preconditioners.h>

+ Inheritance diagram for oomph::TwoPlusThreeUpperTriangularWithReplace< MATRIX >:

Public Member Functions

 TwoPlusThreeUpperTriangularWithReplace ()
 Constructor for TwoPlusThreeUpperTriangularWithReplace. More...
 
 ~TwoPlusThreeUpperTriangularWithReplace ()
 Destructor clean up memory. More...
 
virtual void clean_up_my_memory ()
 Clean up the memory. More...
 
 TwoPlusThreeUpperTriangularWithReplace (const TwoPlusThreeUpperTriangularWithReplace &)
 Broken copy constructor. More...
 
void operator= (const TwoPlusThreeUpperTriangularWithReplace &)
 Broken assignment operator. More...
 
void preconditioner_solve (const DoubleVector &r, DoubleVector &z)
 Apply preconditioner to r, i.e. return z such that P z = r. More...
 
void setup ()
 Setup the preconditioner. More...
 
void set_multi_poisson_mesh (Mesh *multi_poisson_mesh_pt)
 Specify the mesh that contains multi-poisson elements. More...
 
- Public Member Functions inherited from oomph::BlockPreconditioner< MATRIX >
 BlockPreconditioner ()
 Constructor. More...
 
virtual ~BlockPreconditioner ()
 Destructor. More...
 
 BlockPreconditioner (const BlockPreconditioner &)=delete
 Broken copy constructor. More...
 
void operator= (const BlockPreconditioner &)=delete
 Broken assignment operator. More...
 
MATRIX * matrix_pt () const
 
void turn_on_recursive_debug_flag ()
 
void turn_off_recursive_debug_flag ()
 
void turn_on_debug_flag ()
 Toggles on the debug flag. More...
 
void turn_off_debug_flag ()
 Toggles off the debug flag. More...
 
void turn_into_subsidiary_block_preconditioner (BlockPreconditioner< MATRIX > *master_block_prec_pt, const Vector< unsigned > &doftype_in_master_preconditioner_coarse)
 
void turn_into_subsidiary_block_preconditioner (BlockPreconditioner< MATRIX > *master_block_prec_pt, const Vector< unsigned > &doftype_in_master_preconditioner_coarse, const Vector< Vector< unsigned >> &doftype_coarsen_map_coarse)
 
virtual void block_setup ()
 
void block_setup (const Vector< unsigned > &dof_to_block_map)
 
void get_block (const unsigned &i, const unsigned &j, MATRIX &output_matrix, const bool &ignore_replacement_block=false) const
 
MATRIX get_block (const unsigned &i, const unsigned &j, const bool &ignore_replacement_block=false) const
 
void set_master_matrix_pt (MATRIX *in_matrix_pt)
 Set the matrix_pt in the upper-most master preconditioner. More...
 
void get_block_other_matrix (const unsigned &i, const unsigned &j, MATRIX *in_matrix_pt, MATRIX &output_matrix)
 
void get_blocks (DenseMatrix< bool > &required_blocks, DenseMatrix< MATRIX * > &block_matrix_pt) const
 
void get_dof_level_block (const unsigned &i, const unsigned &j, MATRIX &output_block, const bool &ignore_replacement_block=false) const
 
MATRIX get_concatenated_block (const VectorMatrix< BlockSelector > &selected_block)
 
void get_concatenated_block_vector (const Vector< unsigned > &block_vec_number, const DoubleVector &v, DoubleVector &b)
 
void return_concatenated_block_vector (const Vector< unsigned > &block_vec_number, const DoubleVector &b, DoubleVector &v) const
 Takes concatenated block ordered vector, b, and copies its. More...
 
void get_block_vectors (const Vector< unsigned > &block_vec_number, const DoubleVector &v, Vector< DoubleVector > &s) const
 
void get_block_vectors (const DoubleVector &v, Vector< DoubleVector > &s) const
 
void return_block_vectors (const Vector< unsigned > &block_vec_number, const Vector< DoubleVector > &s, DoubleVector &v) const
 
void return_block_vectors (const Vector< DoubleVector > &s, DoubleVector &v) const
 
void get_block_vector (const unsigned &n, const DoubleVector &v, DoubleVector &b) const
 
void return_block_vector (const unsigned &n, const DoubleVector &b, DoubleVector &v) const
 
void get_block_ordered_preconditioner_vector (const DoubleVector &v, DoubleVector &w)
 
void return_block_ordered_preconditioner_vector (const DoubleVector &w, DoubleVector &v) const
 
unsigned nblock_types () const
 Return the number of block types. More...
 
unsigned ndof_types () const
 Return the total number of DOF types. More...
 
const Meshmesh_pt (const unsigned &i) const
 
unsigned nmesh () const
 
int block_number (const unsigned &i_dof) const
 Return the block number corresponding to a global index i_dof. More...
 
int index_in_block (const unsigned &i_dof) const
 
const LinearAlgebraDistributionblock_distribution_pt (const unsigned &b) const
 Access function to the block distributions (const version). More...
 
LinearAlgebraDistributionblock_distribution_pt (const unsigned b)
 Access function to the block distributions (non-const version). More...
 
LinearAlgebraDistributiondof_block_distribution_pt (const unsigned &b)
 Access function to the dof-level block distributions. More...
 
const LinearAlgebraDistributionmaster_distribution_pt () const
 
unsigned ndof_types_in_mesh (const unsigned &i) const
 
bool is_subsidiary_block_preconditioner () const
 
bool is_master_block_preconditioner () const
 
void set_block_output_to_files (const std::string &basefilename)
 
void disable_block_output_to_files ()
 Turn off output of blocks (by clearing the basefilename string). More...
 
bool block_output_on () const
 Test if output of blocks is on or not. More...
 
void output_blocks_to_files (const std::string &basefilename, const unsigned &precision=8) const
 
void post_block_matrix_assembly_partial_clear ()
 
BlockPreconditioner< MATRIX > * master_block_preconditioner_pt () const
 Access function to the master block preconditioner pt. More...
 
void clear_block_preconditioner_base ()
 
void document ()
 
Vector< Vector< unsigned > > doftype_coarsen_map_fine () const
 
Vector< unsignedget_fine_grain_dof_types_in (const unsigned &i) const
 
unsigned nfine_grain_dof_types_in (const unsigned &i) const
 
MapMatrix< unsigned, CRDoubleMatrix * > replacement_dof_block_pt () const
 Access function to the replaced dof-level blocks. More...
 
void setup_matrix_vector_product (MatrixVectorProduct *matvec_prod_pt, CRDoubleMatrix *block_pt, const Vector< unsigned > &block_col_indices)
 
void setup_matrix_vector_product (MatrixVectorProduct *matvec_prod_pt, CRDoubleMatrix *block_pt, const unsigned &block_col_index)
 
void internal_get_block_ordered_preconditioner_vector (const DoubleVector &v, DoubleVector &w) const
 
void internal_return_block_ordered_preconditioner_vector (const DoubleVector &w, DoubleVector &v) const
 
unsigned internal_nblock_types () const
 
unsigned internal_ndof_types () const
 
void internal_return_block_vector (const unsigned &n, const DoubleVector &b, DoubleVector &v) const
 
void internal_get_block_vector (const unsigned &n, const DoubleVector &v, DoubleVector &b) const
 
void internal_get_block_vectors (const Vector< unsigned > &block_vec_number, const DoubleVector &v, Vector< DoubleVector > &s) const
 
void internal_get_block_vectors (const DoubleVector &v, Vector< DoubleVector > &s) const
 
void internal_return_block_vectors (const Vector< unsigned > &block_vec_number, const Vector< DoubleVector > &s, DoubleVector &v) const
 
void internal_return_block_vectors (const Vector< DoubleVector > &s, DoubleVector &v) const
 
void internal_get_block (const unsigned &i, const unsigned &j, MATRIX &output_block) const
 
int internal_block_number (const unsigned &i_dof) const
 
int internal_index_in_block (const unsigned &i_dof) const
 
const LinearAlgebraDistributioninternal_block_distribution_pt (const unsigned &b) const
 Access function to the internal block distributions. More...
 
void insert_auxiliary_block_distribution (const Vector< unsigned > &block_vec_number, LinearAlgebraDistribution *dist_pt)
 
void block_matrix_test (const unsigned &i, const unsigned &j, const MATRIX *block_matrix_pt) const
 
template<typename myType >
int get_index_of_value (const Vector< myType > &vec, const myType val, const bool sorted=false) const
 
void internal_get_block (const unsigned &block_i, const unsigned &block_j, CRDoubleMatrix &output_block) const
 
void get_dof_level_block (const unsigned &block_i, const unsigned &block_j, CRDoubleMatrix &output_block, const bool &ignore_replacement_block) const
 
- Public Member Functions inherited from oomph::Preconditioner
 Preconditioner ()
 Constructor. More...
 
 Preconditioner (const Preconditioner &)=delete
 Broken copy constructor. More...
 
void operator= (const Preconditioner &)=delete
 Broken assignment operator. More...
 
virtual ~Preconditioner ()
 Destructor (empty) More...
 
virtual void preconditioner_solve_transpose (const DoubleVector &r, DoubleVector &z)
 
void setup (DoubleMatrixBase *matrix_pt)
 
void setup (const Problem *problem_pt, DoubleMatrixBase *matrix_pt)
 
void enable_silent_preconditioner_setup ()
 Set up the block preconditioner quietly! More...
 
void disable_silent_preconditioner_setup ()
 Be verbose in the block preconditioner setup. More...
 
virtual void clean_up_memory ()
 Clean up memory (empty). Generic interface function. More...
 
virtual void set_matrix_pt (DoubleMatrixBase *matrix_pt)
 Set the matrix pointer. More...
 
virtual const OomphCommunicatorcomm_pt () const
 Get function for comm pointer. More...
 
virtual void set_comm_pt (const OomphCommunicator *const comm_pt)
 Set the communicator pointer. More...
 
double setup_time () const
 Returns the time to setup the preconditioner. More...
 
virtual void turn_into_subsidiary_block_preconditioner (BlockPreconditioner< CRDoubleMatrix > *master_block_prec_pt, const Vector< unsigned > &doftype_in_master_preconditioner_coarse)
 
virtual void turn_into_subsidiary_block_preconditioner (BlockPreconditioner< CRDoubleMatrix > *master_block_prec_pt, const Vector< unsigned > &doftype_in_master_preconditioner_coarse, const Vector< Vector< unsigned >> &doftype_coarsen_map_coarse)
 
- Public Member Functions inherited from oomph::DistributableLinearAlgebraObject
 DistributableLinearAlgebraObject ()
 Default constructor - create a distribution. More...
 
 DistributableLinearAlgebraObject (const DistributableLinearAlgebraObject &matrix)=delete
 Broken copy constructor. More...
 
void operator= (const DistributableLinearAlgebraObject &)=delete
 Broken assignment operator. More...
 
virtual ~DistributableLinearAlgebraObject ()
 Destructor. More...
 
LinearAlgebraDistributiondistribution_pt () const
 access to the LinearAlgebraDistribution More...
 
unsigned nrow () const
 access function to the number of global rows. More...
 
unsigned nrow_local () const
 access function for the num of local rows on this processor. More...
 
unsigned nrow_local (const unsigned &p) const
 access function for the num of local rows on this processor. More...
 
unsigned first_row () const
 access function for the first row on this processor More...
 
unsigned first_row (const unsigned &p) const
 access function for the first row on this processor More...
 
bool distributed () const
 distribution is serial or distributed More...
 
bool distribution_built () const
 
void build_distribution (const LinearAlgebraDistribution *const dist_pt)
 
void build_distribution (const LinearAlgebraDistribution &dist)
 

Private Attributes

PreconditionerFirst_subsidiary_preconditioner_pt
 
PreconditionerSecond_subsidiary_preconditioner_pt
 
MatrixVectorProductOff_diagonal_matrix_vector_product_pt
 
DenseMatrix< CRDoubleMatrix * > Replacement_matrix_pt
 
MeshMulti_poisson_mesh_pt
 

Additional Inherited Members

- Protected Member Functions inherited from oomph::BlockPreconditioner< MATRIX >
void set_nmesh (const unsigned &n)
 
void set_mesh (const unsigned &i, const Mesh *const mesh_pt, const bool &allow_multiple_element_type_in_mesh=false)
 
void set_replacement_dof_block (const unsigned &block_i, const unsigned &block_j, CRDoubleMatrix *replacement_dof_block_pt)
 
bool any_mesh_distributed () const
 
int internal_dof_number (const unsigned &i_dof) const
 
unsigned internal_index_in_dof (const unsigned &i_dof) const
 
unsigned internal_block_dimension (const unsigned &b) const
 
unsigned internal_dof_block_dimension (const unsigned &i) const
 
unsigned master_nrow () const
 
unsigned internal_master_dof_number (const unsigned &b) const
 
const LinearAlgebraDistributioninternal_preconditioner_matrix_distribution_pt () const
 
const LinearAlgebraDistributionpreconditioner_matrix_distribution_pt () const
 
- Protected Member Functions inherited from oomph::DistributableLinearAlgebraObject
void clear_distribution ()
 
- Protected Attributes inherited from oomph::BlockPreconditioner< MATRIX >
MapMatrix< unsigned, CRDoubleMatrix * > Replacement_dof_block_pt
 The replacement dof-level blocks. More...
 
Vector< LinearAlgebraDistribution * > Block_distribution_pt
 The distribution for the blocks. More...
 
Vector< Vector< unsigned > > Block_to_dof_map_coarse
 
Vector< Vector< unsigned > > Block_to_dof_map_fine
 Mapping for the block types to the most fine grain dof types. More...
 
Vector< Vector< unsigned > > Doftype_coarsen_map_coarse
 
Vector< Vector< unsigned > > Doftype_coarsen_map_fine
 
Vector< LinearAlgebraDistribution * > Internal_block_distribution_pt
 Storage for the default distribution for each internal block. More...
 
Vector< LinearAlgebraDistribution * > Dof_block_distribution_pt
 
Vector< unsignedAllow_multiple_element_type_in_mesh
 
Vector< const Mesh * > Mesh_pt
 
Vector< unsignedNdof_types_in_mesh
 
unsigned Internal_nblock_types
 
unsigned Internal_ndof_types
 
- Protected Attributes inherited from oomph::Preconditioner
bool Silent_preconditioner_setup
 Boolean to indicate whether or not the build should be done silently. More...
 
std::ostream * Stream_pt
 Pointer to the output stream – defaults to std::cout. More...
 

Detailed Description

template<typename MATRIX>
class oomph::TwoPlusThreeUpperTriangularWithReplace< MATRIX >

///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// Block diagonal preconditioner for system with 5 dof types assembled into a 2x2 block system, with (0,0) block containing the first two dof types, the (1,1) block the remaining dof types. The blocks are solved by upper block triangular preconditioners. However, the overall system is modified by replacing all off-diagonal blocks by replacement matrices (zero matrices, so the preconditioner again behaves like a 5x5 block diagonal preconditioner).

Constructor & Destructor Documentation

◆ TwoPlusThreeUpperTriangularWithReplace() [1/2]

Constructor for TwoPlusThreeUpperTriangularWithReplace.

2421  :
2422  BlockPreconditioner<MATRIX>(),
2426  {
2428  } // end_of_constructor
Preconditioner * Second_subsidiary_preconditioner_pt
Definition: multi_poisson_block_preconditioners.h:2475
Mesh * Multi_poisson_mesh_pt
Definition: multi_poisson_block_preconditioners.h:2486
MatrixVectorProduct * Off_diagonal_matrix_vector_product_pt
Definition: multi_poisson_block_preconditioners.h:2479
Preconditioner * First_subsidiary_preconditioner_pt
Definition: multi_poisson_block_preconditioners.h:2471

References oomph::TwoPlusThreeUpperTriangularWithReplace< MATRIX >::Multi_poisson_mesh_pt.

◆ ~TwoPlusThreeUpperTriangularWithReplace()

Destructor clean up memory.

2433  {
2434  this->clean_up_my_memory();
2435  }
virtual void clean_up_my_memory()
Clean up the memory.
Definition: multi_poisson_block_preconditioners.h:2759

References oomph::TwoPlusThreeUpperTriangularWithReplace< MATRIX >::clean_up_my_memory().

◆ TwoPlusThreeUpperTriangularWithReplace() [2/2]

Broken copy constructor.

2443  {
2444  BrokenCopy::
2445  broken_copy("TwoPlusThreeUpperTriangularWithReplace");
2446  }
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
Definition: oomph_utilities.cc:212

References oomph::BrokenCopy::broken_copy().

Member Function Documentation

◆ clean_up_my_memory()

template<typename MATRIX >
void oomph::TwoPlusThreeUpperTriangularWithReplace< MATRIX >::clean_up_my_memory
virtual

Clean up the memory.

The clean up function.

2760  {
2761  // Clean up subsidiary preconditioners.
2763  {
2766  }
2768  {
2771  }
2772 
2773  // Clean up the replacement matricies.
2774  for(unsigned i=0,ni=Replacement_matrix_pt.nrow();i<ni;i++)
2775  {
2776  for(unsigned j=0,nj=Replacement_matrix_pt.ncol();j<nj;j++)
2777  {
2778  if(Replacement_matrix_pt(i,j)!=0)
2779  {
2780  delete Replacement_matrix_pt(i,j);
2782  }
2783  } // End loop over j.
2784  } // End loop over i.
2785 
2786  // Clean up the off diag matrix products.
2788  {
2791  }
2792  } // End of clean_up_my_memory function.
int i
Definition: BiCGSTAB_step_by_step.cpp:9
DenseMatrix< CRDoubleMatrix * > Replacement_matrix_pt
Definition: multi_poisson_block_preconditioners.h:2482
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References i, and j.

Referenced by oomph::TwoPlusThreeUpperTriangularWithReplace< MATRIX >::~TwoPlusThreeUpperTriangularWithReplace().

◆ operator=()

template<typename MATRIX >
void oomph::TwoPlusThreeUpperTriangularWithReplace< MATRIX >::operator= ( const TwoPlusThreeUpperTriangularWithReplace< MATRIX > &  )
inline

Broken assignment operator.

2450  {
2451  BrokenCopy::
2452  broken_assign("TwoPlusThreeUpperTriangularWithReplace");
2453  }
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
Definition: oomph_utilities.cc:195

References oomph::BrokenCopy::broken_assign().

◆ preconditioner_solve()

template<typename MATRIX >
void oomph::TwoPlusThreeUpperTriangularWithReplace< MATRIX >::preconditioner_solve ( const DoubleVector r,
DoubleVector z 
)
virtual

Apply preconditioner to r, i.e. return z such that P z = r.

Preconditioner solve for the two plus three upper triangular with replacement preconditioner: Apply preconditioner to r and return z, so that P r = z, where P is the block diagonal matrix constructed from the original linear system.

Implements oomph::Preconditioner.

2714  {
2715  // Now apply the subsidiary block preconditioner that acts on the
2716  // "bottom right" 3x3 sub-system (only!). The subsidiary preconditioner
2717  // will extract the relevant (3x1) "sub-vectors" from the "big" (5x1)
2718  // vector big_r and treat it as the rhs, r, of P z = r
2719  // where P is 3x3 block diagonal.
2721 
2722  // Split up rhs vector into sub-vectors, re-arranged to match
2723  // the matrix blocks
2724  DoubleVector r_0;
2725  this->get_block_vector(0,r,r_0);
2726 
2727  DoubleVector z_1;
2728  this->get_block_vector(1,z,z_1);
2729 
2730  // Multiply by (0,1) off diagonal.
2731  DoubleVector temp;
2733  r_0 -= temp;
2734 
2735  // Block solve for first diagonal block. Since the associated subsidiary
2736  // preconditioner is a block preconditioner itself, it will extract
2737  // the required (2x1) block rhs from a "big" (5x1) rhs vector, big_r.
2738  // Therefore we first put the actual (2x1) rhs vector block_r_0 into the
2739  // "big" (5x1) vector big_r.
2740  DoubleVector big_r(z.distribution_pt());
2741  this->return_block_vector(0,r_0,big_r);
2742 
2743  // Now apply the subsidiary block preconditioner that acts on the
2744  // "top left" 2x2 sub-system (only!). The subsidiary preconditioner
2745  // will extract the relevant (2x1) "sub-vectors" from the "big" (5x1)
2746  // vector big_r and treat it as the rhs, r, of P z = r
2747  // where P is 2x2 block diagonal. Once the system is solved,
2748  // the result is automatically put back into the appropriate places
2749  // of the "big" (5x1) vector z:
2751 
2752  }
std::vector< double > DoubleVector
loads clump configuration
Definition: ClumpInput.h:26
void return_block_vector(const unsigned &n, const DoubleVector &b, DoubleVector &v) const
Definition: block_preconditioner.cc:4489
void get_block_vector(const unsigned &n, const DoubleVector &v, DoubleVector &b) const
Definition: block_preconditioner.cc:4186
void multiply(const DoubleVector &x, DoubleVector &y) const
Definition: matrix_vector_product.cc:108
virtual void preconditioner_solve(const DoubleVector &r, DoubleVector &z)=0
r
Definition: UniformPSDSelfTest.py:20

References oomph::DistributableLinearAlgebraObject::distribution_pt(), and UniformPSDSelfTest::r.

◆ set_multi_poisson_mesh()

template<typename MATRIX >
void oomph::TwoPlusThreeUpperTriangularWithReplace< MATRIX >::set_multi_poisson_mesh ( Mesh multi_poisson_mesh_pt)
inline

Specify the mesh that contains multi-poisson elements.

2463  {
2464  Multi_poisson_mesh_pt=multi_poisson_mesh_pt;
2465  }

References oomph::TwoPlusThreeUpperTriangularWithReplace< MATRIX >::Multi_poisson_mesh_pt.

Referenced by MultiPoissonProblem< ELEMENT >::MultiPoissonProblem().

◆ setup()

template<typename MATRIX >
void oomph::TwoPlusThreeUpperTriangularWithReplace< MATRIX >::setup
virtual

Setup the preconditioner.

The setup function.

Implements oomph::Preconditioner.

2496  {
2497  // Clean up memory.
2498  this->clean_up_my_memory();
2499 
2500 #ifdef PARANOID
2501  if (Multi_poisson_mesh_pt == 0)
2502  {
2503  std::stringstream err;
2504  err << "Please set pointer to mesh using set_multi_poisson_mesh(...).\n";
2505  throw OomphLibError(err.str(),
2508  }
2509 #endif
2510 
2511  // The preconditioner works with one mesh; set it!
2512  this->set_nmesh(1);
2514 
2515  // How many dof types do we have?
2516  const unsigned n_dof_types = this->ndof_types();
2517 
2518 #ifdef PARANOID
2519  // This preconditioner only works for 5 dof types
2520  if (n_dof_types!=5)
2521  {
2522  std::stringstream tmp;
2523  tmp << "This preconditioner only works for problems with 5 dof types\n"
2524  << "Yours has " << n_dof_types;
2525  throw OomphLibError(tmp.str(),
2528  }
2529 #endif
2530 
2531  // Call block setup with the Vector [0,0,1,1,1] to:
2532  // Merge DOF types 0 and 1 into block type 0
2533  // Merge DOF types 2, 3, and 4 into block type 1.
2534  Vector<unsigned> dof_to_block_map(n_dof_types,0);
2535  dof_to_block_map[0] = 0;
2536  dof_to_block_map[1] = 0;
2537  dof_to_block_map[2] = 1;
2538  dof_to_block_map[3] = 1;
2539  dof_to_block_map[4] = 1;
2540  this->block_setup(dof_to_block_map);
2541 
2542 #ifdef PARANOID
2543 
2544  // We should now have two block types -- do we?
2545  const unsigned nblocks = this->nblock_types();
2546  if (nblocks!=2)
2547  {
2548  std::stringstream tmp;
2549  tmp << "Expected number of block types is 2.\n"
2550  << "Yours has " << nblocks << ".\n"
2551  << "Perhaps your argument to block_setup(...) is not correct.\n";
2552  throw OomphLibError(tmp.str(),
2555  }
2556 
2557 #endif
2558 
2559  // Now replace all the off-diagonal DOF blocks.
2560 
2561  // Storage for the replacement DOF blocks
2562  Replacement_matrix_pt.resize(n_dof_types,n_dof_types,0);
2563 
2564  // Set off-diagonal DOF blocks to zero, loop over the number of DOF blocks.
2565  // NOTE: There are two (compound) blocks, but the replacement functionality
2566  // works with DOF blocks.
2567  for(unsigned i=0;i<n_dof_types;i++)
2568  {
2569  for(unsigned j=0;j<n_dof_types;j++)
2570  {
2571  if(i!=j)
2572  {
2573  // Modify matrix
2574  bool modify_existing_matrix=true;
2575  if (modify_existing_matrix)
2576  {
2577  // Get the dof-block and make a deep copy of it
2578  Replacement_matrix_pt(i,j)=new CRDoubleMatrix;
2580 
2581  // Set all its entries to zero
2582  unsigned nnz=Replacement_matrix_pt(i,j)->nnz();
2583  for (unsigned k=0;k<nnz;k++)
2584  {
2585  Replacement_matrix_pt(i,j)->value()[k]=0.0;
2586  }
2587  } // done -- quite wasteful, we're actually storing lots of zeroes, but
2588  // this is just an example!
2589 
2590  // Build (zero) replacement matrix from scratch:
2591  else
2592  {
2593  // Get the DOF block's (row!) distribution.
2594  LinearAlgebraDistribution* dof_block_dist_pt=
2596 
2597  // Number of rows in DOF block matrix (i,j).
2598  const unsigned long dof_block_nrow_local
2599  = dof_block_dist_pt->nrow_local();
2600 
2601  // Number of columns in DOF block matrix (i,j) is the same as the
2602  // number of rows in block matrix (j,i).
2603  const unsigned long dof_block_ncol
2604  = this->dof_block_distribution_pt(j)->nrow();
2605 
2606  // Storage for replacement matrices:
2607  // Values
2608  Vector<double> replacement_value(0);
2609  // Column index
2610  Vector<int> replacement_column_index(0);
2611  // Row start
2612  Vector<int> replacement_row_start;
2613 
2614  // Need one row start per row, and one for the nnz, all of which are 0.
2615  // There are no rows, so this is a Vector of size 1.
2616  replacement_row_start.resize(dof_block_nrow_local+1,0);
2617 
2619  new CRDoubleMatrix(dof_block_dist_pt,
2620  dof_block_ncol,
2621  replacement_value,
2622  replacement_column_index,
2623  replacement_row_start);
2624  }
2625 
2626  // Replace (i,j)-th dof block
2628  }
2629  }// end for loop of j
2630  }// end for loop of i
2631 
2632 
2633  // First subsidiary precond is a block triangular preconditioner
2634  {
2635  UpperTriangular<CRDoubleMatrix>* block_prec_pt=
2636  new UpperTriangular<CRDoubleMatrix>;
2637  First_subsidiary_preconditioner_pt=block_prec_pt;
2638 
2639  // Set mesh
2640  block_prec_pt->set_multi_poisson_mesh(Multi_poisson_mesh_pt);
2641 
2642  // Turn it into a subsidiary preconditioner, declaring which
2643  // of the five dof types in the present (master) preconditioner
2644  // correspond to the dof types in the subsidiary block preconditioner
2645  unsigned n_sub_dof_types=2;
2646  Vector<unsigned> dof_map(n_sub_dof_types);
2647  dof_map[0]=0;
2648  dof_map[1]=1;
2649  block_prec_pt->turn_into_subsidiary_block_preconditioner(this,dof_map);
2650 
2651  // Perform setup. Note that because the subsidiary
2652  // preconditioner is a block preconditioner itself it is given
2653  // the pointer to the "full" matrix
2654  block_prec_pt->setup(this->matrix_pt());
2655  }
2656 
2657  // Second subsidiary precond is a block triangular preconditioner
2658  {
2659  UpperTriangular<CRDoubleMatrix>* block_prec_pt=
2660  new UpperTriangular<CRDoubleMatrix>;
2662 
2663  // Set mesh
2664  block_prec_pt->set_multi_poisson_mesh(Multi_poisson_mesh_pt);
2665 
2666  // Turn it into a subsidiary preconditioner, declaring which
2667  // of the five dof types in the present (master) preconditioner
2668  // correspond to the dof types in the subsidiary block preconditioner
2669  unsigned n_sub_dof_types=3;
2670  Vector<unsigned> dof_map(n_sub_dof_types);
2671  dof_map[0]=2;
2672  dof_map[1]=3;
2673  dof_map[2]=4;
2674  block_prec_pt->turn_into_subsidiary_block_preconditioner(this,dof_map);
2675 
2676  // Perform setup. Note that because the subsidiary
2677  // preconditioner is a block preconditioner itself it is given
2678  // the pointer to the "full" matrix
2679  block_prec_pt->setup(this->matrix_pt());
2680  }
2681 
2682  // Next setup the off diagonal mat vec operators:
2683  {
2684  // Get the block
2685  CRDoubleMatrix block_matrix = this->get_block(0,1);
2686 
2687  // Create matrix vector product operator
2688  Off_diagonal_matrix_vector_product_pt = new MatrixVectorProduct;
2689 
2690  // Setup: Final argument indicates block column in the present
2691  // block preconditioner (which views the system matrix as comprising
2692  // 2x2 blocks).
2693  unsigned block_column_index=1;
2695  Off_diagonal_matrix_vector_product_pt,&block_matrix,block_column_index);
2696 
2697  // Extracted block can now go out of scope since the matrix vector
2698  // product retains whatever information it needs
2699  }
2700 
2701  }
LinearAlgebraDistribution * dof_block_distribution_pt(const unsigned &b)
Access function to the dof-level block distributions.
Definition: block_preconditioner.h:1962
void get_dof_level_block(const unsigned &i, const unsigned &j, MATRIX &output_block, const bool &ignore_replacement_block=false) const
void get_block(const unsigned &i, const unsigned &j, MATRIX &output_matrix, const bool &ignore_replacement_block=false) const
Definition: block_preconditioner.h:673
unsigned nblock_types() const
Return the number of block types.
Definition: block_preconditioner.h:1670
void set_replacement_dof_block(const unsigned &block_i, const unsigned &block_j, CRDoubleMatrix *replacement_dof_block_pt)
Definition: block_preconditioner.h:2911
MATRIX * matrix_pt() const
Definition: block_preconditioner.h:520
unsigned ndof_types() const
Return the total number of DOF types.
Definition: block_preconditioner.h:1694
void setup_matrix_vector_product(MatrixVectorProduct *matvec_prod_pt, CRDoubleMatrix *block_pt, const Vector< unsigned > &block_col_indices)
Definition: block_preconditioner.h:2397
void set_nmesh(const unsigned &n)
Definition: block_preconditioner.h:2851
virtual void block_setup()
Definition: block_preconditioner.cc:2483
void set_mesh(const unsigned &i, const Mesh *const mesh_pt, const bool &allow_multiple_element_type_in_mesh=false)
Definition: block_preconditioner.h:2866
unsigned nrow() const
access function to the number of global rows.
Definition: linear_algebra_distribution.h:186
char char char int int * k
Definition: level2_impl.h:374
Eigen::Matrix< Scalar, Dynamic, Dynamic, ColMajor > tmp
Definition: level3_impl.h:365
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References i, j, k, oomph::LinearAlgebraDistribution::nrow_local(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::UpperTriangular< MATRIX >::set_multi_poisson_mesh(), oomph::UpperTriangular< MATRIX >::setup(), tmp, and oomph::BlockPreconditioner< MATRIX >::turn_into_subsidiary_block_preconditioner().

Member Data Documentation

◆ First_subsidiary_preconditioner_pt

template<typename MATRIX >
Preconditioner* oomph::TwoPlusThreeUpperTriangularWithReplace< MATRIX >::First_subsidiary_preconditioner_pt
private

Pointer to preconditioners/inexact solver for compound (0,0) block

◆ Multi_poisson_mesh_pt

template<typename MATRIX >
Mesh* oomph::TwoPlusThreeUpperTriangularWithReplace< MATRIX >::Multi_poisson_mesh_pt
private

◆ Off_diagonal_matrix_vector_product_pt

template<typename MATRIX >
MatrixVectorProduct* oomph::TwoPlusThreeUpperTriangularWithReplace< MATRIX >::Off_diagonal_matrix_vector_product_pt
private

Matrix vector product operator with the compound (0,1) off diagonal block.

◆ Replacement_matrix_pt

template<typename MATRIX >
DenseMatrix<CRDoubleMatrix*> oomph::TwoPlusThreeUpperTriangularWithReplace< MATRIX >::Replacement_matrix_pt
private

◆ Second_subsidiary_preconditioner_pt

template<typename MATRIX >
Preconditioner* oomph::TwoPlusThreeUpperTriangularWithReplace< MATRIX >::Second_subsidiary_preconditioner_pt
private

Pointer to preconditioners/inexact solver for compound (1,1) block


The documentation for this class was generated from the following file: