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-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_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
34namespace oomph
35{
36 //====================================================================
37 /// An interface to allow SuperLU to be used as an (exact) Preconditioner
38 //====================================================================
40 {
41 public:
42 /// Constructor.
44 {
47 }
48
49 /// Destructor.
51
52 /// Broken copy constructor.
54
55 /// Broken assignment operator.
56 void operator=(const SuperLUPreconditioner&) = delete;
57
58 /// Function to set up a preconditioner for the linear
59 /// system defined by matrix_pt. This function must be called
60 /// before using preconditioner_solve.
61 /// Note: matrix_pt must point to an object of class
62 /// CRDoubleMatrix or CCDoubleMatrix
63 void setup()
64 {
65 oomph_info << "Setting up SuperLU (exact) preconditioner" << std::endl;
66 if (dynamic_cast<DistributableLinearAlgebraObject*>(matrix_pt()) != 0)
67 {
70 ->distribution_pt());
71 this->build_distribution(dist);
73 }
74 else
75 {
76 std::ostringstream error_message_stream;
77 error_message_stream
78 << "SuperLUPreconditioner can only be applied to matrices derived \n"
79 << "DistributableLinearAlgebraObject.\n"
80 << "You are most likely to be here because you are using the\n "
81 << "soon to be obsolete CCDoubleMatrix\n";
82 throw OomphLibError(error_message_stream.str(),
83 OOMPH_CURRENT_FUNCTION,
84 OOMPH_EXCEPTION_LOCATION);
85 }
86 }
87
88 /// Function applies SuperLU to vector r for (exact) preconditioning,
89 /// this requires a call to setup(...) first.
91 {
92 Solver.resolve(r, z);
93 }
94
95 /// Function applies SuperLU to vector r for (exact) preconditioning
96 /// (of the transposed matrix system) this requires a call to setup(...)
97 /// first.
99 {
101 }
102
103
104 /// Clean up memory -- forward the call to the version in
105 /// SuperLU in its LinearSolver incarnation.
106 virtual void clean_up_memory()
107 {
109 }
110
111
112 /// Get the amount of memory used to store the LU factors inside SuperLU
114 {
115 // Return the appropriate result
117 } // End of get_memory_usage_for_lu_factors
118
119
120 /// Get the total memory needed by SuperLU to store AND calculate
121 /// the LU factors
123 {
124 // Return the appropriate result
126 } // End of get_memory_usage_for_superlu
127
128
129 /// Get the amount of memory taken up by SuperLU. The first entry
130 /// of the returned result contains the memory used to store the LU
131 /// factors and the second entry contains the total memory used to
132 /// store AND calculate the LU factors
134 {
135 // Allocate storage for the memory statistics
136 Vector<double> memory_usage(2, 0.0);
137
138 // The first entry contains the memory used to store the LU factors
139 memory_usage[0] = Solver.get_memory_usage_for_lu_factors();
140
141 // The second entry contains the total memory used to both calculate
142 // and store the LU factors
143 memory_usage[1] = Solver.get_total_needed_memory();
144
145 // Now return the calculated result
146 return memory_usage;
147 } // End of get_memory_usage_for_superlu
148
149
150 /// Enable documentation of solver statistics
152 {
153 // Enable the documentation of statistics inside SuperLU
155 } // End of enable_doc_stats
156
157 /// Enable documentation of solver statistics
159 {
160 // Disable the documentation of statistics inside SuperLU
162 } // End of disable_doc_stats
163
164
165 private:
166 /// the SuperLU solver emplyed by this preconditioner
168 };
169
170} // namespace oomph
171#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....
Definition: double_vector.h:58
Describes the distribution of a distributable linear algebra type object. Typically this is a contain...
void disable_doc_time()
Disable 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.
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 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.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
OomphInfo oomph_info
Single (global) instantiation of the OomphInfo object – this is used throughout the library as a "rep...