oomph::ExactDGPBlockPreconditioner< MATRIX > Class Template Reference

#include <general_purpose_space_time_block_preconditioner.h>

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

Public Member Functions

 ExactDGPBlockPreconditioner ()
 Constructor. (By default this preconditioner is upper triangular). More...
 
virtual ~ExactDGPBlockPreconditioner ()
 Destructor - delete the preconditioner matrices. More...
 
virtual void clean_up_memory ()
 Clean up the memory. More...
 
 ExactDGPBlockPreconditioner (const ExactDGPBlockPreconditioner &)=delete
 Broken copy constructor. More...
 
void operator= (const ExactDGPBlockPreconditioner &)=delete
 Broken assignment operator. More...
 
void preconditioner_solve (const DoubleVector &r, DoubleVector &z)
 Apply preconditioner to r. More...
 
void setup ()
 Setup the preconditioner. More...
 
void enable_doc_memory_usage ()
 Document the memory usage. More...
 
void disable_doc_memory_usage ()
 Don't document the memory usage! More...
 
double get_memory_usage_in_bytes ()
 Get the memory statistics. More...
 
- Public Member Functions inherited from oomph::GeneralPurposeBlockPreconditioner< MATRIX >
 GeneralPurposeBlockPreconditioner ()
 constructor More...
 
virtual ~GeneralPurposeBlockPreconditioner ()
 
 GeneralPurposeBlockPreconditioner (const GeneralPurposeBlockPreconditioner &)=delete
 Broken copy constructor. More...
 
void operator= (const GeneralPurposeBlockPreconditioner &)=delete
 Broken assignment operator. More...
 
void set_subsidiary_preconditioner_function (SubsidiaryPreconditionerFctPt sub_prec_fn)
 access function to set the subsidiary preconditioner function. More...
 
void reset_subsidiary_preconditioner_function_to_default ()
 Reset the subsidiary preconditioner function to its default. More...
 
void set_subsidiary_preconditioner_pt (Preconditioner *prec, const unsigned &i)
 
Preconditionersubsidiary_preconditioner_pt (const unsigned &i) const
 
void set_dof_to_block_map (Vector< unsigned > &dof_to_block_map)
 Specify a DOF to block map. More...
 
void add_mesh (const Mesh *mesh_pt, const bool &allow_multiple_element_type_in_mesh=false)
 
unsigned gp_nmesh ()
 
- 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 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

bool Preconditioner_has_been_setup
 
bool Compute_memory_statistics
 
double Memory_usage_in_bytes
 

Additional Inherited Members

- Public Types inherited from oomph::GeneralPurposeBlockPreconditioner< MATRIX >
typedef Preconditioner *(* SubsidiaryPreconditionerFctPt) ()
 
- Protected Member Functions inherited from oomph::GeneralPurposeBlockPreconditioner< MATRIX >
void gp_preconditioner_set_all_meshes ()
 Set the mesh in the block preconditioning framework. More...
 
void gp_preconditioner_block_setup ()
 Modified block setup for general purpose block preconditioners. More...
 
void fill_in_subsidiary_preconditioners (const unsigned &nprec_needed)
 
- 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::GeneralPurposeBlockPreconditioner< MATRIX >
Vector< Preconditioner * > Subsidiary_preconditioner_pt
 List of preconditioners to use for the blocks to be solved. More...
 
SubsidiaryPreconditionerFctPt Subsidiary_preconditioner_creation_function_pt
 
- 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::ExactDGPBlockPreconditioner< MATRIX >

General purpose block tridiagonal preconditioner. By default SuperLUPreconditioner (or SuperLUDistPreconditioner) is used to solve the subsidiary systems, but other preconditioners can be used by setting them using passing a pointer to a function of type SubsidiaryPreconditionerFctPt to the method subsidiary_preconditioner_function_pt().

Constructor & Destructor Documentation

◆ ExactDGPBlockPreconditioner() [1/2]

template<typename MATRIX >
oomph::ExactDGPBlockPreconditioner< MATRIX >::ExactDGPBlockPreconditioner ( )
inline

Constructor. (By default this preconditioner is upper triangular).

62  : GeneralPurposeBlockPreconditioner<MATRIX>()
63  {
64  // The preconditioner has been created but it hasn't been set up yet
66 
67  // By default, don't store the memory statistics of this preconditioner
69 
70  // Initialise the value of Memory_usage_in_bytes
72  } // End of ExactDGPBlockPreconditioner
bool Compute_memory_statistics
Definition: general_purpose_space_time_block_preconditioner.h:180
bool Preconditioner_has_been_setup
Definition: general_purpose_space_time_block_preconditioner.h:176
double Memory_usage_in_bytes
Definition: general_purpose_space_time_block_preconditioner.h:184

References oomph::ExactDGPBlockPreconditioner< MATRIX >::Compute_memory_statistics, oomph::ExactDGPBlockPreconditioner< MATRIX >::Memory_usage_in_bytes, and oomph::ExactDGPBlockPreconditioner< MATRIX >::Preconditioner_has_been_setup.

◆ ~ExactDGPBlockPreconditioner()

template<typename MATRIX >
virtual oomph::ExactDGPBlockPreconditioner< MATRIX >::~ExactDGPBlockPreconditioner ( )
inlinevirtual

Destructor - delete the preconditioner matrices.

77  {
78  // Forward the call to a helper clean-up function
79  this->clean_up_memory();
80  } // End of ~ExactDGPBlockPreconditioner
virtual void clean_up_memory()
Clean up the memory.
Definition: general_purpose_space_time_block_preconditioner.h:84

References oomph::ExactDGPBlockPreconditioner< MATRIX >::clean_up_memory().

◆ ExactDGPBlockPreconditioner() [2/2]

template<typename MATRIX >
oomph::ExactDGPBlockPreconditioner< MATRIX >::ExactDGPBlockPreconditioner ( const ExactDGPBlockPreconditioner< MATRIX > &  )
delete

Broken copy constructor.

Member Function Documentation

◆ clean_up_memory()

template<typename MATRIX >
virtual void oomph::ExactDGPBlockPreconditioner< MATRIX >::clean_up_memory ( )
inlinevirtual

Clean up the memory.

Reimplemented from oomph::GeneralPurposeBlockPreconditioner< MATRIX >.

85  {
86  // Clean up the base class too
88  } // End of clean_up_memory
virtual void clean_up_memory()
Definition: general_purpose_block_preconditioners.h:112

References oomph::GeneralPurposeBlockPreconditioner< MATRIX >::clean_up_memory().

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

◆ disable_doc_memory_usage()

template<typename MATRIX >
void oomph::ExactDGPBlockPreconditioner< MATRIX >::disable_doc_memory_usage ( )
inline

Don't document the memory usage!

Set the appropriate flag to false

115  {
118  } // End of disable_doc_memory_usage

References oomph::ExactDGPBlockPreconditioner< MATRIX >::Compute_memory_statistics.

◆ enable_doc_memory_usage()

template<typename MATRIX >
void oomph::ExactDGPBlockPreconditioner< MATRIX >::enable_doc_memory_usage ( )
inline

Document the memory usage.

Set the appropriate flag to true

107  {
110  } // End of enable_doc_memory_usage

References oomph::ExactDGPBlockPreconditioner< MATRIX >::Compute_memory_statistics.

◆ get_memory_usage_in_bytes()

template<typename MATRIX >
double oomph::ExactDGPBlockPreconditioner< MATRIX >::get_memory_usage_in_bytes ( )
inline

Get the memory statistics.

123  {
124  // Has the preconditioner even been set up yet?
126  {
127  // Were we meant to compute the statistics?
129  {
130  // Return the appropriate variable value
131  return Memory_usage_in_bytes;
132  }
133  else
134  {
135  // Allocate storage for an output stream
136  std::ostringstream warning_message_stream;
137 
138  // Create a warning message
139  warning_message_stream
140  << "The memory statistics have not been calculated "
141  << "so I'm returning\nthe value zero." << std::endl;
142 
143  // Give the user a warning
144  OomphLibWarning(warning_message_stream.str(),
147 
148  // Return the value zero
149  return 0.0;
150  }
151  }
152  // If the preconditioner hasn't been set up yet
153  else
154  {
155  // Allocate storage for an output stream
156  std::ostringstream warning_message_stream;
157 
158  // Create a warning message
159  warning_message_stream
160  << "The preconditioner hasn't even been set up yet "
161  << "so I'm returning\nthe value zero." << std::endl;
162 
163  // Give the user a warning
164  OomphLibWarning(warning_message_stream.str(),
167 
168  // Return the value zero
169  return 0.0;
170  } // if (Preconditioner_has_been_setup)
171  } // End of get_memory_usage_in_bytes
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References oomph::ExactDGPBlockPreconditioner< MATRIX >::Compute_memory_statistics, oomph::ExactDGPBlockPreconditioner< MATRIX >::Memory_usage_in_bytes, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, and oomph::ExactDGPBlockPreconditioner< MATRIX >::Preconditioner_has_been_setup.

◆ operator=()

template<typename MATRIX >
void oomph::ExactDGPBlockPreconditioner< MATRIX >::operator= ( const ExactDGPBlockPreconditioner< MATRIX > &  )
delete

Broken assignment operator.

◆ preconditioner_solve()

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

Apply preconditioner to r.

Preconditioner solve for the exact preconditioner.

Implements oomph::Preconditioner.

183  {
184  // Vector of vectors for each section of residual vector
185  Vector<DoubleVector> block_r;
186 
187  // Rearrange the vector r into the vector of block vectors block_r
188  this->get_block_vectors(r, block_r);
189 
190  // Allocate space for the properly rearranged RHS vector
191  DoubleVector rhs_reordered;
192 
193  // Concatenate the DoubleVectors together
194  DoubleVectorHelpers::concatenate(block_r, rhs_reordered);
195 
196  // Allocate space for the rearranged solution vector
197  DoubleVector z_reordered;
198 
199  // Solve the whole system exactly
200  this->Subsidiary_preconditioner_pt[0]->preconditioner_solve(rhs_reordered,
201  z_reordered);
202 
203  // Vector of vectors for each section of solution vector (copy the RHS
204  // block vector to get the sizing and distributions right)
205  Vector<DoubleVector> block_z(block_r);
206 
207  // Split the solution vector into blocks
208  DoubleVectorHelpers::split(z_reordered, block_z);
209 
210  // Copy the solution from the block vector block_z back into z
211  this->return_block_vectors(block_z, z);
212  } // End of preconditioner_solve
std::vector< double > DoubleVector
loads clump configuration
Definition: ClumpInput.h:26
void return_block_vectors(const Vector< unsigned > &block_vec_number, const Vector< DoubleVector > &s, DoubleVector &v) const
Definition: block_preconditioner.cc:3443
void get_block_vectors(const Vector< unsigned > &block_vec_number, const DoubleVector &v, Vector< DoubleVector > &s) const
Definition: block_preconditioner.cc:2939
Vector< Preconditioner * > Subsidiary_preconditioner_pt
List of preconditioners to use for the blocks to be solved.
Definition: general_purpose_block_preconditioners.h:294
r
Definition: UniformPSDSelfTest.py:20
void split(const DoubleVector &in_vector, Vector< DoubleVector * > &out_vector_pt)
Definition: double_vector.cc:1413
void concatenate(const Vector< DoubleVector * > &in_vector_pt, DoubleVector &out_vector)
Definition: double_vector.cc:993

References oomph::DoubleVectorHelpers::concatenate(), UniformPSDSelfTest::r, and oomph::DoubleVectorHelpers::split().

◆ setup()

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

Setup the preconditioner.

Set up the exact preconditioner.

Implements oomph::Preconditioner.

43  {
44  // Clean the memory
45  this->clean_up_memory();
46 
47  // Subsidiary preconditioners don't really need the meshes
49  {
50 #ifdef PARANOID
51  if (this->gp_nmesh() == 0)
52  {
53  std::ostringstream err_msg;
54  err_msg << "There are no meshes set.\n"
55  << "Did you remember to call add_mesh(...)?";
56  throw OomphLibError(
58  }
59 #endif
60 
61  // Set all meshes if this is master block preconditioner
63  }
64 
65  // Initialise the memory usage variable
67 
68  // If we're meant to build silently
69  if (this->Silent_preconditioner_setup == true)
70  {
71  // Store the output stream pointer
72  this->Stream_pt = oomph_info.stream_pt();
73 
74  // Now set the oomph_info stream pointer to the null stream to
75  // disable all possible output
77  }
78 
79  // Set up the block look up schemes
81 
82  // Number of block types
83  unsigned n_block_types = this->nblock_types();
84 
85  // Fill in any null subsidiary preconditioners
86  this->fill_in_subsidiary_preconditioners(n_block_types);
87 
88  // The total time for setting up the subsidiary preconditioners
89  double t_subsidiary_setup_total = 0.0;
90 
91  // Stores the blocks we want to extract
92  VectorMatrix<BlockSelector> required_blocks(n_block_types, n_block_types);
93 
94  // Boolean indicating if we want the block, stored for readability.
95  const bool want_block = true;
96 
97  // Loop over the block rows
98  for (unsigned i = 0; i < n_block_types; i++)
99  {
100  // Loop over the block columns
101  for (unsigned j = 0; j < n_block_types; j++)
102  {
103  // Indicate that we want this block
104  required_blocks[i][j].select_block(i, j, want_block);
105  }
106  } // for (unsigned i=0;i<n_block_types;i++)
107 
108  // Get the start time
109  double t_extract_start = TimingHelpers::timer();
110 
111  // Get the concatenated blocks
112  CRDoubleMatrix full_matrix = this->get_concatenated_block(required_blocks);
113 
114  // The total time for extracting all the blocks from the "global" matrix
115  double t_extraction_total = (TimingHelpers::timer() - t_extract_start);
116 
117  // Get the start time
118  double t_subsidiary_setup_start = TimingHelpers::timer();
119 
120  // It's a block preconditioner so pass it a pointer to the global matrix!
121  this->Subsidiary_preconditioner_pt[0]->setup(&full_matrix);
122 
123  // Update the timing total
124  t_subsidiary_setup_total +=
125  (TimingHelpers::timer() - t_subsidiary_setup_start);
126 
127  // Remember that the preconditioner has been set up
129 
130  // If we're meant to build silently, reassign the oomph stream pointer
131  if (this->Silent_preconditioner_setup == true)
132  {
133  // Store the output stream pointer
134  oomph_info.stream_pt() = this->Stream_pt;
135 
136  // Reset our own stream pointer
137  this->Stream_pt = 0;
138  }
139 
140  // Tell the user
141  oomph_info << "Total block extraction time [sec]: " << t_extraction_total
142  << "\nTotal subsidiary preconditioner setup time [sec]: "
143  << t_subsidiary_setup_total << std::endl;
144 
145  // Do we need to doc. the memory statistics?
146  // NOTE: We're going to assume that either:
147  // (1) GMRES is used as a subsidiary block preconditioner (preconditioned
148  // by the Navier-Stokes subsidiary block preconditioner), or;
149  // (2) SuperLU is used as the subsidiary preconditioner.
151  {
152  // How many rows are there in the global Jacobian?
153  unsigned n_row = this->matrix_pt()->nrow();
154 
155  // How many nonzeros are there in the global Jacobian?
156  unsigned n_nnz = this->matrix_pt()->nnz();
157 
158  // Add in the subsidiary preconditioners contribution
159  double total_memory_usage_for_setup_phase =
160  dynamic_cast<SuperLUPreconditioner*>(
162  ->get_total_memory_needed_for_superlu();
163 
164  // Add in the global Jacobian contribution
165  total_memory_usage_for_setup_phase +=
166  ((2 * ((n_row + 1) * sizeof(int))) +
167  (n_nnz * (sizeof(int) + sizeof(double))));
168 
169  // How much memory have we used in the subsidiary preconditioners?
170  oomph_info << "\nTotal amount of memory being used after setup (MB): "
171  << total_memory_usage_for_setup_phase / 1.0e+06 << "\n"
172  << std::endl;
173  } // if (Compute_memory_statistics)
174  } // End of setup
int i
Definition: BiCGSTAB_step_by_step.cpp:9
MATRIX get_concatenated_block(const VectorMatrix< BlockSelector > &selected_block)
Definition: block_preconditioner.h:1134
bool is_master_block_preconditioner() const
Definition: block_preconditioner.h:2068
unsigned nblock_types() const
Return the number of block types.
Definition: block_preconditioner.h:1670
MATRIX * matrix_pt() const
Definition: block_preconditioner.h:520
void gp_preconditioner_set_all_meshes()
Set the mesh in the block preconditioning framework.
Definition: general_purpose_block_preconditioners.h:218
void fill_in_subsidiary_preconditioners(const unsigned &nprec_needed)
Definition: general_purpose_block_preconditioners.h:256
void gp_preconditioner_block_setup()
Modified block setup for general purpose block preconditioners.
Definition: general_purpose_block_preconditioners.h:241
unsigned gp_nmesh()
Definition: general_purpose_block_preconditioners.h:211
std::ostream *& stream_pt()
Access function for the stream pointer.
Definition: oomph_definitions.h:464
std::ostream * Stream_pt
Pointer to the output stream – defaults to std::cout.
Definition: preconditioner.h:232
bool Silent_preconditioner_setup
Boolean to indicate whether or not the build should be done silently.
Definition: preconditioner.h:229
return int(ret)+1
double timer()
returns the time in seconds after some point in past
Definition: oomph_utilities.cc:1295
Nullstream oomph_nullstream
Single (global) instantiation of the Nullstream.
Definition: oomph_definitions.cc:313
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References oomph::TerminateHelper::clean_up_memory(), i, int(), j, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::oomph_info, oomph::oomph_nullstream, GlobalParameters::Stream_pt, oomph::OomphInfo::stream_pt(), and oomph::TimingHelpers::timer().

Member Data Documentation

◆ Compute_memory_statistics

◆ Memory_usage_in_bytes

template<typename MATRIX >
double oomph::ExactDGPBlockPreconditioner< MATRIX >::Memory_usage_in_bytes
private

Storage for the memory usage of the solver if the flag above is set to true (in bytes)

Referenced by oomph::ExactDGPBlockPreconditioner< MATRIX >::ExactDGPBlockPreconditioner(), and oomph::ExactDGPBlockPreconditioner< MATRIX >::get_memory_usage_in_bytes().

◆ Preconditioner_has_been_setup

template<typename MATRIX >
bool oomph::ExactDGPBlockPreconditioner< MATRIX >::Preconditioner_has_been_setup
private

Control flag is true if the preconditioner has been setup (used so we can wipe the data when the preconditioner is called again)

Referenced by oomph::ExactDGPBlockPreconditioner< MATRIX >::ExactDGPBlockPreconditioner(), and oomph::ExactDGPBlockPreconditioner< MATRIX >::get_memory_usage_in_bytes().


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