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 
34 namespace oomph
35 {
36  //====================================================================
38  //====================================================================
40  {
41  public:
44  {
47  }
48 
51 
54 
56  void operator=(const SuperLUPreconditioner&) = delete;
57 
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(),
85  }
86  }
87 
91  {
92  Solver.resolve(r, z);
93  }
94 
99  {
101  }
102 
103 
106  virtual void clean_up_memory()
107  {
109  }
110 
111 
114  {
115  // Return the appropriate result
117  } // End of get_memory_usage_for_lu_factors
118 
119 
123  {
124  // Return the appropriate result
126  } // End of get_memory_usage_for_superlu
127 
128 
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 
152  {
153  // Enable the documentation of statistics inside SuperLU
155  } // End of enable_doc_stats
156 
159  {
160  // Disable the documentation of statistics inside SuperLU
162  } // End of disable_doc_stats
163 
164 
165  private:
168  };
169 
170 } // namespace oomph
171 #endif
Definition: linear_algebra_distribution.h:435
LinearAlgebraDistribution * distribution_pt() const
access to the LinearAlgebraDistribution
Definition: linear_algebra_distribution.h:457
void build_distribution(const LinearAlgebraDistribution *const dist_pt)
Definition: linear_algebra_distribution.h:507
Definition: double_vector.h:58
Definition: linear_algebra_distribution.h:64
void disable_doc_time()
Disable documentation of solve times.
Definition: linear_solver.h:116
Definition: oomph_definitions.h:222
Definition: preconditioner.h:54
virtual DoubleMatrixBase * matrix_pt() const
Get function for matrix pointer.
Definition: preconditioner.h:150
An interface to allow SuperLU to be used as an (exact) Preconditioner.
Definition: SuperLU_preconditioner.h:40
double get_total_memory_needed_for_superlu()
Definition: SuperLU_preconditioner.h:122
SuperLUSolver Solver
the SuperLU solver emplyed by this preconditioner
Definition: SuperLU_preconditioner.h:167
SuperLUPreconditioner()
Constructor.
Definition: SuperLU_preconditioner.h:43
void preconditioner_solve(const DoubleVector &r, DoubleVector &z)
Definition: SuperLU_preconditioner.h:90
void preconditioner_solve_transpose(const DoubleVector &r, DoubleVector &z)
Definition: SuperLU_preconditioner.h:98
void enable_doc_stats()
Enable documentation of solver statistics.
Definition: SuperLU_preconditioner.h:151
double get_memory_usage_for_lu_factors()
Get the amount of memory used to store the LU factors inside SuperLU.
Definition: SuperLU_preconditioner.h:113
void setup()
Definition: SuperLU_preconditioner.h:63
~SuperLUPreconditioner()
Destructor.
Definition: SuperLU_preconditioner.h:50
SuperLUPreconditioner(const SuperLUPreconditioner &)=delete
Broken copy constructor.
virtual void clean_up_memory()
Definition: SuperLU_preconditioner.h:106
void operator=(const SuperLUPreconditioner &)=delete
Broken assignment operator.
void disable_doc_stats()
Enable documentation of solver statistics.
Definition: SuperLU_preconditioner.h:158
Vector< double > get_memory_usage_for_superlu()
Definition: SuperLU_preconditioner.h:133
Definition: linear_solver.h:486
void enable_doc_stats()
Enable documentation of solver statistics.
Definition: linear_solver.h:603
void factorise(DoubleMatrixBase *const &matrix_pt)
Definition: linear_solver.cc:1820
void resolve_transpose(const DoubleVector &rhs, DoubleVector &result)
Resolve the (transposed) system for a given RHS.
Definition: linear_solver.cc:1793
double get_memory_usage_for_lu_factors()
How much memory do the LU factors take up? In bytes.
Definition: linear_solver.cc:758
double get_total_needed_memory()
How much memory was allocated by SuperLU? In bytes.
Definition: linear_solver.cc:786
void resolve(const DoubleVector &rhs, DoubleVector &result)
Resolve the system for a given RHS.
Definition: linear_solver.cc:1769
void disable_doc_stats()
Disable documentation of solver statistics.
Definition: linear_solver.h:609
void clean_up_memory()
Clean up the memory allocated by the solver.
Definition: linear_solver.cc:2683
r
Definition: UniformPSDSelfTest.py:20
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86