SuperLU_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#ifndef OOMPH_SuperLU_Preconditioner_HEADER
27#define OOMPH_SuperLU_Preconditioner_HEADER
28
29// oomph-lib headers
30
31#include "linear_solver.h"
32#include "preconditioner.h"
33#ifdef OOMPH_HAS_MUMPS
34#include "mumps_solver.h"
35#endif
36
37namespace oomph
38{
39 //====================================================================
40 /// An interface to allow SuperLU to be used as an (exact) Preconditioner
41 //====================================================================
43 {
44 public:
45 /// Constructor.
51
52 /// Destructor.
54
55 /// Broken copy constructor.
57
58 /// Broken assignment operator.
59 void operator=(const SuperLUPreconditioner&) = delete;
60
61 /// Function to set up a preconditioner for the linear
62 /// system defined by matrix_pt. This function must be called
63 /// before using preconditioner_solve.
64 /// Note: matrix_pt must point to an object of class
65 /// CRDoubleMatrix or CCDoubleMatrix
66 void setup()
67 {
68 oomph_info << "Setting up SuperLU (exact) preconditioner" << std::endl;
69 if (dynamic_cast<DistributableLinearAlgebraObject*>(matrix_pt()) != 0)
70 {
73 ->distribution_pt());
74 this->build_distribution(dist);
76 }
77 else
78 {
79 std::ostringstream error_message_stream;
81 << "SuperLUPreconditioner can only be applied to matrices derived \n"
82 << "DistributableLinearAlgebraObject.\n"
83 << "You are most likely to be here because you are using the\n "
84 << "soon to be obsolete CCDoubleMatrix\n";
88 }
89 }
90
91 /// Function applies SuperLU to vector r for (exact) preconditioning,
92 /// this requires a call to setup(...) first.
94 {
95 Solver.resolve(r, z);
96 }
97
98 /// Function applies SuperLU to vector r for (exact) preconditioning
99 /// (of the transposed matrix system) this requires a call to setup(...)
100 /// first.
105
106
107 /// Clean up memory -- forward the call to the version in
108 /// SuperLU in its LinearSolver incarnation.
109 virtual void clean_up_memory()
110 {
112 }
113
114 /// Get the amount of memory used to store the LU factors inside SuperLU
116 {
117 // Return the appropriate result
119 } // End of get_memory_usage_for_lu_factors
120
121
122 /// Get the total memory needed by SuperLU to store AND calculate
123 /// the LU factors
125 {
126 // Return the appropriate result
128 } // End of get_memory_usage_for_superlu
129
130
131 /// Get the amount of memory taken up by SuperLU. The first entry
132 /// of the returned result contains the memory used to store the LU
133 /// factors and the second entry contains the total memory used to
134 /// store AND calculate the LU factors
136 {
137 // Allocate storage for the memory statistics
139
140 // The first entry contains the memory used to store the LU factors
142
143 // The second entry contains the total memory used to both calculate
144 // and store the LU factors
146
147 // Now return the calculated result
148 return memory_usage;
149 }
150
151 /// Enable documentation of solver statistics
153 {
154 // Enable the documentation of statistics inside SuperLU
156 }
157
158 /// Enable documentation of solver statistics
160 {
161 // Disable the documentation of statistics inside SuperLU
163 }
164
165 /// Enable documentation of solver statistics
167 {
168 // Enable the documentation of statistics inside SuperLU
170 }
171
172 /// Enable documentation of solver statistics
174 {
175 // Disable the documentation of statistics inside SuperLU
177 }
178
179 private:
180 /// the SuperLU solver emplyed by this preconditioner
182 };
183
184
185 ///////////////////////////////////////////////////////////////
186 ///////////////////////////////////////////////////////////////
187 ///////////////////////////////////////////////////////////////
188
189
190} // namespace oomph
191#endif
Base class for any linear algebra object that is distributable. Just contains storage for the LinearA...
LinearAlgebraDistribution * distribution_pt() const
access to the LinearAlgebraDistribution
void build_distribution(const LinearAlgebraDistribution *const dist_pt)
setup the distribution of this distributable linear algebra object
A vector in the mathematical sense, initially developed for linear algebra type applications....
Describes the distribution of a distributable linear algebra type object. Typically this is a contain...
void disable_doc_time()
Disable documentation of solve times.
void enable_doc_time()
Enable documentation of solve times.
An OomphLibError object which should be thrown when an run-time error is encountered....
Preconditioner base class. Gives an interface to call all other preconditioners through and stores th...
virtual DoubleMatrixBase * matrix_pt() const
Get function for matrix pointer.
An interface to allow SuperLU to be used as an (exact) Preconditioner.
void enable_doc_time()
Enable documentation of solver statistics.
double get_total_memory_needed_for_superlu()
Get the total memory needed by SuperLU to store AND calculate the LU factors.
SuperLUSolver Solver
the SuperLU solver emplyed by this preconditioner
void preconditioner_solve(const DoubleVector &r, DoubleVector &z)
Function applies SuperLU to vector r for (exact) preconditioning, this requires a call to setup(....
void preconditioner_solve_transpose(const DoubleVector &r, DoubleVector &z)
Function applies SuperLU to vector r for (exact) preconditioning (of the transposed matrix system) th...
void enable_doc_stats()
Enable documentation of solver statistics.
double get_memory_usage_for_lu_factors()
Get the amount of memory used to store the LU factors inside SuperLU.
Vector< double > get_memory_usage_for_superlu()
Get the amount of memory taken up by SuperLU. The first entry of the returned result contains the mem...
void setup()
Function to set up a preconditioner for the linear system defined by matrix_pt. This function must be...
SuperLUPreconditioner(const SuperLUPreconditioner &)=delete
Broken copy constructor.
virtual void clean_up_memory()
Clean up memory – forward the call to the version in SuperLU in its LinearSolver incarnation.
void operator=(const SuperLUPreconditioner &)=delete
Broken assignment operator.
void disable_doc_stats()
Enable documentation of solver statistics.
void disable_doc_time()
Enable documentation of solver statistics.
SuperLU Project Solver class. This is a combined wrapper for both SuperLU and SuperLU Dist....
void enable_doc_stats()
Enable documentation of solver statistics.
void factorise(DoubleMatrixBase *const &matrix_pt)
Do the factorisation stage Note: if Delete_matrix_data is true the function matrix_pt->clean_up_memor...
void resolve_transpose(const DoubleVector &rhs, DoubleVector &result)
Resolve the (transposed) system defined by the last assembled Jacobian and the specified rhs vector i...
double get_memory_usage_for_lu_factors()
How much memory do the LU factors take up? In bytes.
double get_total_needed_memory()
How much memory was allocated by SuperLU? In bytes.
void resolve(const DoubleVector &rhs, DoubleVector &result)
Resolve the system defined by the last assembled jacobian and the specified rhs vector if resolve has...
void disable_doc_stats()
Disable documentation of solver statistics.
void clean_up_memory()
Clean up the memory allocated by the solver.
TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D> elements are isoparametric triangular DIM-d...
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
OomphInfo oomph_info
Single (global) instantiation of the OomphInfo object – this is used throughout the library as a "rep...