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// Version 1.0; svn revision $LastChangedRevision$
7 //LIC//
8 //LIC// $LastChangedDate$
9 //LIC//
10 //LIC// Copyright (C) 2006-2016 Matthias Heil and Andrew Hazel
11 //LIC//
12 //LIC// This library is free software; you can redistribute it and/or
13 //LIC// modify it under the terms of the GNU Lesser General Public
14 //LIC// License as published by the Free Software Foundation; either
15 //LIC// version 2.1 of the License, or (at your option) any later version.
16 //LIC//
17 //LIC// This library is distributed in the hope that it will be useful,
18 //LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
19 //LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 //LIC// Lesser General Public License for more details.
21 //LIC//
22 //LIC// You should have received a copy of the GNU Lesser General Public
23 //LIC// License along with this library; if not, write to the Free Software
24 //LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 //LIC// 02110-1301 USA.
26 //LIC//
27 //LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
28 //LIC//
29 //LIC//====================================================================
30 #ifndef OOMPH_SuperLU_Preconditioner_HEADER
31 #define OOMPH_SuperLU_Preconditioner_HEADER
32 
33 //oomph-lib headers
34 
35 #include "linear_solver.h"
36 #include "preconditioner.h"
37 
38 namespace oomph
39 {
40 
41 //====================================================================
42 /// An interface to allow SuperLU to be used as an (exact) Preconditioner
43 //====================================================================
45 {
46  public:
47 
48  /// Constructor.
50  {
53  }
54 
55  /// Destructor.
57  {}
58 
59  /// Broken copy constructor.
61  {
62  BrokenCopy::broken_copy("SuperLUPreconditioner");
63  }
64 
65 
66  /// Broken assignment operator.
68  {
69  BrokenCopy::broken_assign("SuperLUPreconditioner");
70  }
71 
72  /// \short Function to set up a preconditioner for the linear
73  /// system defined by matrix_pt. This function must be called
74  /// before using preconditioner_solve.
75  /// Note: matrix_pt must point to an object of class
76  /// CRDoubleMatrix or CCDoubleMatrix
77  void setup()
78  {
79  oomph_info << "Setting up SuperLU (exact) preconditioner"
80  << std::endl;
81  if (dynamic_cast<DistributableLinearAlgebraObject*>(matrix_pt()) != 0)
82  {
84  ((dynamic_cast<DistributableLinearAlgebraObject*>
85  (matrix_pt()))->distribution_pt());
86  this->build_distribution(dist);
88  }
89  else
90  {
91  std::ostringstream error_message_stream;
92  error_message_stream
93  << "SuperLUPreconditioner can only be applied to matrices derived \n"
94  << "DistributableLinearAlgebraObject.\n"
95  << "You are most likely to be here because you are using the\n "
96  << "soon to be obsolete CCDoubleMatrix\n";
97  throw OomphLibError(error_message_stream.str(),
98  OOMPH_CURRENT_FUNCTION,
99  OOMPH_EXCEPTION_LOCATION);
100  }
101  }
102 
103  /// \short Function applies SuperLU to vector r for (exact) preconditioning,
104  /// this requires a call to setup(...) first.
106  DoubleVector &z)
107  {
108  Solver.resolve(r, z);
109  }
110 
111 
112  /// \short Clean up memory -- forward the call to the version in
113  /// SuperLU in its LinearSolver incarnation.
114  virtual void clean_up_memory()
115  {
117  }
118 
119  private:
120 
121  /// \short the SuperLU solver emplyed by this preconditioner
123 };
124 
125 }
126 #endif
virtual DoubleMatrixBase * matrix_pt() const
Get function for matrix pointer.
virtual void clean_up_memory()
Clean up memory – forward the call to the version in SuperLU in its LinearSolver incarnation...
void clean_up_memory()
Clean up the memory allocated by the solver.
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
OomphInfo oomph_info
. SuperLU Project Solver class. This is a combined wrapper for both SuperLU and SuperLU Dist...
void preconditioner_solve(const DoubleVector &r, DoubleVector &z)
Function applies SuperLU to vector r for (exact) preconditioning, this requires a call to setup(...
void setup()
Function to set up a preconditioner for the linear system defined by matrix_pt. This function must be...
Describes the distribution of a distributable linear algebra type object. Typically this is a contain...
SuperLUPreconditioner(const SuperLUPreconditioner &)
Broken copy constructor.
void disable_doc_time()
Disable documentation of solve times.
void resolve(const DoubleVector &rhs, DoubleVector &result)
Resolve the system defined by the last assembled jacobian and the specified rhs vector if resolve has...
SuperLUSolver Solver
the SuperLU solver emplyed by this preconditioner
An interface to allow SuperLU to be used as an (exact) Preconditioner.
void disable_doc_stats()
Disable documentation of solver statistics.
Preconditioner base class. Gives an interface to call all other preconditioners through and stores th...
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
void build_distribution(const LinearAlgebraDistribution *const dist_pt)
setup the distribution of this distributable linear algebra object
void factorise(DoubleMatrixBase *const &matrix_pt)
Do the factorisation stage Note: if Delete_matrix_data is true the function matrix_pt->clean_up_memor...
A vector in the mathematical sense, initially developed for linear algebra type applications. If MPI then this vector can be distributed - its distribution is described by the LinearAlgebraDistribution object at Distribution_pt. Data is stored in a C-style pointer vector (double*)
Definition: double_vector.h:61
LinearAlgebraDistribution * distribution_pt() const
access to the LinearAlgebraDistribution
void operator=(const SuperLUPreconditioner &)
Broken assignment operator.