general_purpose_space_time_block_preconditioner.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-2025 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// Header file for SpaceTime elements
27#ifndef OOMPH_GENERAL_PURPOSE_SPACE_TIME_BLOCK_PRECONDITIONER_HEADER
28#define OOMPH_GENERAL_PURPOSE_SPACE_TIME_BLOCK_PRECONDITIONER_HEADER
29
30// Config header
31#ifdef HAVE_CONFIG_H
32#include <oomph-lib-config.h>
33#endif
34
35// Oomph-lib headers
38
39// Add in the subsidiary preconditioners
41
42////////////////////////////////////////////////////////////////////////////
43////////////////////////////////////////////////////////////////////////////
44////////////////////////////////////////////////////////////////////////////
45
46namespace oomph
47{
48 //=============================================================================
49 /// General purpose block tridiagonal preconditioner. By default
50 /// ExactPreconditioner is used to solve the
51 /// subsidiary systems, but other preconditioners can be used by setting them
52 /// using passing a pointer to a function of type
53 /// SubsidiaryPreconditionerFctPt to the method
54 /// subsidiary_preconditioner_function_pt().
55 //=============================================================================
56 template<typename MATRIX>
59 {
60 public:
61 /// Constructor. (By default this preconditioner is upper triangular).
63 {
64 // The preconditioner has been created but it hasn't been set up yet
66
67 } // End of ExactDGPBlockPreconditioner
68
69
70 /// Destructor - delete the preconditioner matrices
72 {
73 // Forward the call to a helper clean-up function
74 this->clean_up_memory();
75 } // End of ~ExactDGPBlockPreconditioner
76
77
78 /// Clean up the memory
79 virtual void clean_up_memory()
80 {
81 // Clean up the base class too
83 } // End of clean_up_memory
84
85
86 /// Broken copy constructor
88
89 /// Broken assignment operator
91
92 /// Apply preconditioner to r
94
95
96 /// Setup the preconditioner
97 void setup();
98
99 private:
100 /// Control flag is true if the preconditioner has been setup
101 /// (used so we can wipe the data when the preconditioner is called again)
103 };
104
105 //=============================================================================
106 /// General purpose block triangular preconditioner. By default this
107 /// operates as an upper triangular preconditioner. Also, by default
108 /// ExactPreconditioner is used to solve the
109 /// subsidiary systems, but other preconditioners can be used by setting them
110 /// using passing a pointer to a function of type
111 /// SubsidiaryPreconditionerFctPt to the method
112 /// subsidiary_preconditioner_function_pt().
113 //=============================================================================
114 template<typename MATRIX>
116 : public GeneralPurposeBlockPreconditioner<MATRIX>
117 {
118 public:
119 /// Constructor. (By default this preconditioner is upper triangular).
122 {
123 // Default to upper triangular
124 Upper_triangular = true;
125
126 // Default is to assume every block above the diagonal is non-empty
127 Block_bandwidth = -1;
128
129 // The preconditioner has been created but it hasn't been set up yet
131
132 } // End of BandedBlockTriangularPreconditioner
133
134
135 /// Destructor - delete the preconditioner matrices
137 {
138 // Forward the call to a helper clean-up function
139 this->clean_up_memory();
140 } // End of ~BandedBlockTriangularPreconditioner
141
142
143 /// Clean up the memory
144 virtual void clean_up_memory()
145 {
146 // Delete anything in Off_diagonal_matrix_vector_products
147 for (unsigned i = 0, ni = Off_diagonal_matrix_vector_products.nrow();
148 i < ni;
149 i++)
150 {
151 for (unsigned j = 0, nj = Off_diagonal_matrix_vector_products.ncol();
152 j < nj;
153 j++)
154 {
155 // Delete the matrix-vector product
157
158 // Make it a null pointer
160 }
161 } // for (unsigned i=0,ni=Off_diagonal_matrix_vector_products.nrow();...
162
163 // Clean up the base class too
165 } // End of clean_up_memory
166
167
168 /// Broken copy constructor
171
172 /// Broken assignment operator
174
175 /// Apply preconditioner to r
177
178
179 /// Setup the preconditioner
180 void setup();
181
182
183 /// Set the block bandwidth of the preconditioner
185 {
186 // Store it
188 } // End of set_block_bandwidth
189
190
191 /// Get the block bandwidth of the preconditioner
193 {
194 // Store it
195 return Block_bandwidth;
196 } // End of block_bandwidth
197
198
199 /// Use as an upper triangular preconditioner
201 {
202 // Update the Upper_triangular flag
203 Upper_triangular = true;
204 } // End of upper_triangular
205
206
207 /// Use as a lower triangular preconditioner
209 {
210 // Update the Upper_triangular flag
211 Upper_triangular = false;
212 } // End of lower_triangular
213
214
215 /// Is this being used as an upper triangular preconditioner?
217 {
218 // Return the value of the Upper_triangular flag
219 return Upper_triangular;
220 } // End of is_upper_triangular
221
222
223 protected:
224 /// Matrix of matrix-vector product operators for the off diagonals
226
227 private:
228 /// Storage for the block bandwidth of the matrix. Defaults to -1
229 /// indicating that we assume every off-diagonal block is non-empty. If
230 /// the matrix is block diagonal then the value is zero
232
233 /// Boolean indicating upper or lower triangular
235
236 /// Control flag is true if the preconditioner has been setup
237 /// (used so we can wipe the data when the preconditioner is called again)
239 };
240} // End of namespace oomph
241#endif
cstr elem_len * i
Definition cfortran.h:603
General purpose block triangular preconditioner. By default this operates as an upper triangular prec...
DenseMatrix< MatrixVectorProduct * > Off_diagonal_matrix_vector_products
Matrix of matrix-vector product operators for the off diagonals.
bool Preconditioner_has_been_setup
Control flag is true if the preconditioner has been setup (used so we can wipe the data when the prec...
void preconditioner_solve(const DoubleVector &r, DoubleVector &z)
Apply preconditioner to r.
bool Upper_triangular
Boolean indicating upper or lower triangular.
bool is_upper_triangular()
Is this being used as an upper triangular preconditioner?
BandedBlockTriangularPreconditioner()
Constructor. (By default this preconditioner is upper triangular).
void upper_triangular()
Use as an upper triangular preconditioner.
int block_bandwidth()
Get the block bandwidth of the preconditioner.
int Block_bandwidth
Storage for the block bandwidth of the matrix. Defaults to -1 indicating that we assume every off-dia...
BandedBlockTriangularPreconditioner(const BandedBlockTriangularPreconditioner &)=delete
Broken copy constructor.
virtual ~BandedBlockTriangularPreconditioner()
Destructor - delete the preconditioner matrices.
void set_block_bandwidth(const int &block_bandwidth)
Set the block bandwidth of the preconditioner.
void operator=(const BandedBlockTriangularPreconditioner &)=delete
Broken assignment operator.
A vector in the mathematical sense, initially developed for linear algebra type applications....
General purpose block tridiagonal preconditioner. By default ExactPreconditioner is used to solve the...
ExactDGPBlockPreconditioner()
Constructor. (By default this preconditioner is upper triangular).
void operator=(const ExactDGPBlockPreconditioner &)=delete
Broken assignment operator.
bool Preconditioner_has_been_setup
Control flag is true if the preconditioner has been setup (used so we can wipe the data when the prec...
virtual ~ExactDGPBlockPreconditioner()
Destructor - delete the preconditioner matrices.
void preconditioner_solve(const DoubleVector &r, DoubleVector &z)
Apply preconditioner to r.
ExactDGPBlockPreconditioner(const ExactDGPBlockPreconditioner &)=delete
Broken copy constructor.
Base class for general purpose block preconditioners. Deals with setting subsidiary preconditioners a...
virtual void clean_up_memory()
??ds I think clean_up_memory is supposed to clear out any stuff that doesn't need to be stored betwee...
TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D> elements are isoparametric triangular DIM-d...
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).