solid_preconditioners.h
Go to the documentation of this file.
1 // LIC// ====================================================================
2 // LIC// This file forms part of oomph-lib, the object-oriented,
3 // LIC// multi-physics finite-element library, available
4 // LIC// at http://www.oomph-lib.org.
5 // LIC//
6 // LIC// Copyright (C) 2006-2022 Matthias Heil and Andrew Hazel
7 // LIC//
8 // LIC// This library is free software; you can redistribute it and/or
9 // LIC// modify it under the terms of the GNU Lesser General Public
10 // LIC// License as published by the Free Software Foundation; either
11 // LIC// version 2.1 of the License, or (at your option) any later version.
12 // LIC//
13 // LIC// This library is distributed in the hope that it will be useful,
14 // LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // LIC// Lesser General Public License for more details.
17 // LIC//
18 // LIC// You should have received a copy of the GNU Lesser General Public
19 // LIC// License along with this library; if not, write to the Free Software
20 // LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 // LIC// 02110-1301 USA.
22 // LIC//
23 // LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24 // LIC//
25 // LIC//====================================================================
26 #ifndef OOMPH_SOLID_PRECONDITIONERS_HEADER
27 #define OOMPH_SOLID_PRECONDITIONERS_HEADER
28 
29 
30 // Config header generated by autoconfig
31 #ifdef HAVE_CONFIG_H
32 #include <oomph-lib-config.h>
33 #endif
34 
35 
36 // oomphlib headers
37 #include "../generic/matrices.h"
38 #include "../generic/assembly_handler.h"
39 #include "../generic/problem.h"
40 #include "../generic/block_preconditioner.h"
41 #include "../generic/preconditioner.h"
42 #include "../generic/SuperLU_preconditioner.h"
43 #include "../generic/matrix_vector_product.h"
44 
45 
46 namespace oomph
47 {
48  //===========================================================================
104  //===========================================================================
106  : public BlockPreconditioner<CRDoubleMatrix>
107  {
108  public:
112  {
113  // Flag to indicate that the preconditioner has been setup
114  // previously -- if setup() is called again, data can
115  // be wiped.
117 
118  // By default we use SuperLU for both p and f blocks
121 
122  // resize the mesh pt
123  // note: meaningless if subsidiary preconditioner
124  this->set_nmesh(1);
125  Solid_mesh_pt = 0;
126 
127  // Set default preconditioners (inexact solvers) -- they are
128  // members of this class!
131 
132  // Flag to determine if mass matrix diagonal Q^{-1}
133  // is used for scaling.
134  P_matrix_using_scaling = true;
135 
136  // set Doc_time to false
137  Doc_time = false;
138 
139  // null the off diagonal Block matrix pt
140  Bt_mat_vec_pt = 0;
141 
142  // null the F matrix vector product helper
143  F_mat_vec_pt = 0;
144 
145  // null the QBt matrix vector product pt
146  QBt_mat_vec_pt = 0;
147 
148  // null the E matrix vector product helper
149  E_mat_vec_pt = 0;
150 
151  // by default we do not form the E matrix (BQFQBt)
152  Form_BFBt_product = false;
153  }
154 
157  {
158  clean_up_memory();
159  }
160 
163  const PressureBasedSolidLSCPreconditioner&) = delete;
164 
166  // Commented out broken assignment operator because this can lead to a
167  // conflict warning when used in the virtual inheritence hierarchy.
168  // Essentially the compiler doesn't realise that two separate
169  // implementations of the broken function are the same and so, quite
170  // rightly, it shouts.
171  /*void operator=(const PressureBasedSolidLSCPreconditioner&) = delete;*/
172 
174  void setup();
175 
178 
183  {
185  }
186 
190  {
191  P_matrix_using_scaling = true;
192  }
193 
197  {
198  P_matrix_using_scaling = false;
199  }
200 
204  {
205  return P_matrix_using_scaling;
206  }
207 
209  void set_p_preconditioner(Preconditioner* new_p_preconditioner_pt)
210  {
211  // If the default preconditioner has been used
212  // clean it up now...
214  {
215  delete P_preconditioner_pt;
216  }
217  P_preconditioner_pt = new_p_preconditioner_pt;
219  }
220 
224  {
226  {
229  }
230  }
231 
233  void set_f_preconditioner(Preconditioner* new_f_preconditioner_pt)
234  {
235  // If the default preconditioner has been used
236  // clean it up now...
238  {
239  delete F_preconditioner_pt;
240  }
241  F_preconditioner_pt = new_f_preconditioner_pt;
243  }
244 
248  {
250  {
253  }
254  }
255 
256 
259  {
260  Doc_time = true;
261  }
262 
265  {
266  Doc_time = false;
267  }
268 
274  {
275  Form_BFBt_product = true;
276  }
277 
286  {
287  Form_BFBt_product = false;
288  }
289 
291  void clean_up_memory();
292 
293  private:
294  // oomph-lib objects
295  // -----------------
296 
297  // Pointers to preconditioner (=inexact solver) objects
298  // -----------------------------------------------------
301 
304 
307 
310 
315 
319 
324 
328 
330  bool Doc_time;
331 
334 
337 
340 
343 
357 
361  };
362 
363 
367 
368 
369  //============================================================================
376  //=============================================================================
377  template<typename MATRIX>
379  : public BlockPreconditioner<MATRIX>
380  {
381  public:
384 
385 
388 
389 
392  const PressureBasedSolidExactPreconditioner&) = delete;
393 
394 
396  /*void operator=(const PressureBasedSolidExactPreconditioner&) = delete;*/
397 
398 
400  void setup();
401 
404 
405  protected:
407  MATRIX P_matrix;
408  };
409 
410 } // namespace oomph
411 #endif
Definition: block_preconditioner.h:422
const Mesh * mesh_pt(const unsigned &i) const
Definition: block_preconditioner.h:1782
void set_nmesh(const unsigned &n)
Definition: block_preconditioner.h:2851
Definition: matrices.h:888
Definition: double_vector.h:58
Definition: matrix_vector_product.h:51
Definition: mesh.h:67
Definition: preconditioner.h:54
Definition: solid_preconditioners.h:380
PressureBasedSolidExactPreconditioner()
Constructor - do nothing.
Definition: solid_preconditioners.h:383
~PressureBasedSolidExactPreconditioner()
Destructor - do nothing.
Definition: solid_preconditioners.h:387
MATRIX P_matrix
Preconditioner matrix.
Definition: solid_preconditioners.h:407
PressureBasedSolidExactPreconditioner(const PressureBasedSolidExactPreconditioner &)=delete
Broken copy constructor.
void setup()
Broken assignment operator.
void preconditioner_solve(const Vector< double > &r, Vector< double > &z)
Apply preconditioner to r.
Definition: solid_preconditioners.h:107
MatrixVectorProduct * QBt_mat_vec_pt
MatrixVectorProduct operator for QBt if BFBt is not to be formed.
Definition: solid_preconditioners.h:336
void enable_doc_time()
Enable documentation of time.
Definition: solid_preconditioners.h:258
bool Form_BFBt_product
Definition: solid_preconditioners.h:356
CRDoubleMatrix * assemble_mass_matrix_diagonal()
Definition: solid_preconditioners.cc:705
~PressureBasedSolidLSCPreconditioner()
Destructor.
Definition: solid_preconditioners.h:156
void enable_form_BFBt_product()
Definition: solid_preconditioners.h:273
PressureBasedSolidLSCPreconditioner()
Constructor - sets defaults for control flags.
Definition: solid_preconditioners.h:110
bool Preconditioner_has_been_setup
Definition: solid_preconditioners.h:314
Preconditioner * F_preconditioner_pt
Pointer to the 'preconditioner' for the F matrix.
Definition: solid_preconditioners.h:303
MatrixVectorProduct * E_mat_vec_pt
MatrixVectorProduct operator for E (BFBt) if BFBt is to be formed.
Definition: solid_preconditioners.h:342
void disable_doc_time()
Disable documentation of time.
Definition: solid_preconditioners.h:264
bool Doc_time
Set Doc_time to true for outputting results of timings.
Definition: solid_preconditioners.h:330
PressureBasedSolidLSCPreconditioner(const PressureBasedSolidLSCPreconditioner &)=delete
Broken copy constructor.
void set_p_preconditioner(Preconditioner *new_p_preconditioner_pt)
Function to set a new pressure matrix preconditioner (inexact solver)
Definition: solid_preconditioners.h:209
Mesh * Solid_mesh_pt
Definition: solid_preconditioners.h:360
void disable_p_matrix_scaling()
Definition: solid_preconditioners.h:196
bool F_preconditioner_is_block_preconditioner
Definition: solid_preconditioners.h:327
void preconditioner_solve(const DoubleVector &r, DoubleVector &z)
Apply preconditioner to Vector r.
Definition: solid_preconditioners.cc:493
void setup()
Broken assignment operator.
Definition: solid_preconditioners.cc:38
bool is_p_matrix_using_scaling() const
Definition: solid_preconditioners.h:203
void set_f_preconditioner(Preconditioner *new_f_preconditioner_pt)
Function to set a new momentum matrix preconditioner (inexact solver)
Definition: solid_preconditioners.h:233
MatrixVectorProduct * Bt_mat_vec_pt
MatrixVectorProduct operator for Bt;.
Definition: solid_preconditioners.h:339
bool Using_default_p_preconditioner
flag indicating whether the default P preconditioner is used
Definition: solid_preconditioners.h:309
MatrixVectorProduct * F_mat_vec_pt
MatrixVectorProduct operator for F if BFBt is not to be formed.
Definition: solid_preconditioners.h:333
void set_solid_mesh(Mesh *mesh_pt)
Definition: solid_preconditioners.h:182
void clean_up_memory()
Helper function to delete preconditioner data.
Definition: solid_preconditioners.cc:1357
bool Using_default_f_preconditioner
flag indicating whether the default F preconditioner is used
Definition: solid_preconditioners.h:306
void set_p_superlu_preconditioner()
Definition: solid_preconditioners.h:223
void disable_form_BFBt_product()
Definition: solid_preconditioners.h:285
void enable_p_matrix_scaling()
Definition: solid_preconditioners.h:189
Preconditioner * P_preconditioner_pt
Pointer to the 'preconditioner' for the pressure matrix.
Definition: solid_preconditioners.h:300
bool P_matrix_using_scaling
Definition: solid_preconditioners.h:318
void set_f_superlu_preconditioner()
Definition: solid_preconditioners.h:247
An interface to allow SuperLU to be used as an (exact) Preconditioner.
Definition: SuperLU_preconditioner.h:40
r
Definition: UniformPSDSelfTest.py:20
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10