frontal_solver.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 //This is the header file for the C-wrapper functions for the HSL MA42
31 //frontal solver
32 
33 //Include guards to prevent multiple inclusions of the header
34 #ifndef HSL_MA42OOMPH__FRONTAL_SOLVER_HEADER
35 #define HSL_MA42OOMPH__FRONTAL_SOLVER_HEADER
36 
37 
38 // Config header generated by autoconfig
39 #ifdef HAVE_CONFIG_H
40  #include <oomph-lib-config.h>
41 #endif
42 
43 #ifdef OOMPH_HAS_MPI
44 #include "mpi.h"
45 #endif
46 
47 //oomph-lib headers
48 #include "Vector.h"
49 #include "linear_solver.h"
50 
51 namespace oomph
52 {
53 
54 
55 //====================================================================
56 /// Linear solver class that provides a wrapper to the frontal
57 /// solver MA42 from the <a href="http://www.hsl.rl.ac.uk/">HSL
58 /// library;</a> see <a href="http://www.hsl.rl.ac.uk/">
59 /// http://www.hsl.rl.ac.uk/.</A>
60 //====================================================================
61 class HSL_MA42 : public LinearSolver
62 {
63  private:
64 
65 
66  /// \short Special solver for problems with 1 dof (MA42 can't handle this
67  /// case so solve() forwards the "solve" to this function.
68  void solve_for_one_dof(Problem* const &problem_pt, DoubleVector &result);
69 
70 
71  /// Doc the solver stats or stay quiet?
72  bool Doc_stats;
73 
74  /// Reorder elements with Sloan's algorithm?
76 
77  /// Use direct access files?
79 
80  /// \short Factor to increase storage for lenbuf[0]; see MA42 documentation
81  /// for details.
83 
84  /// \short Factor to increase storage for lenbuf[1]; see MA42 documentation
85  /// for details
87 
88  /// \short Factor to increase storage for lenbuf[2]; see MA42 documentation
89  /// for details.
91 
92  /// \short Factor to increase storage for front size; see MA42 documentation
93  /// for details.
94  double Front_factor;
95 
96  /// \short Factor to increase size of direct access files; see
97  /// MA42 documentation for details.
98  double Lenfle_factor;
99 
100  ///Control flag for MA42; see MA42 documentation for details
101  int Icntl[8];
102 
103  ///Control flag for MA42; see MA42 documentation for details
104  int Isave[45];
105 
106  ///Control flag for MA42; see MA42 documentation for details
107  int Info[23];
108 
109  ///Workspace storage for MA42
110  double *W;
111 
112  ///Size of the workspace array, W
113  int Lw;
114 
115  ///Integer workspace storage for MA42
116  int *IW;
117 
118  ///Size of the integer workspace array
119  int Liw;
120 
121  ///Size of the linear system
122  unsigned long N_dof;
123 
124  public:
125 
126  /// \short Constructor: By default suppress verbose output (stats), don't
127  /// reorder elements and don't use direct access files
128  HSL_MA42() : W(0), Lw(0), IW(0), Liw(0), N_dof(0)
129  {
130  Doc_stats=false;
131  Reorder_flag=false;
132  Use_direct_access_files=false;
133 
134  // Default values for memory allocation
135  Lenbuf_factor0=1.2;
136  Lenbuf_factor1=1.2;
137  Lenbuf_factor2=1.5;
138  Front_factor=1.1;
139  Lenfle_factor=1.5;
140  }
141 
142  /// Destructor, clean up the allocated memory
144  {
145  clean_up_memory();
146  }
147 
148  /// Broken copy constructor
150  {
151  BrokenCopy::broken_copy("HSL_MA42");
152  }
153 
154  /// Broken assignment operator
155  void operator=(const HSL_MA42&)
156  {
157  BrokenCopy::broken_assign("HSL_MA42");
158  }
159 
160 
161  /// Clean up memory
163  {
164  if(IW) {delete[] IW; IW=0; Liw=0;}
165  if(W) {delete[] W; W=0; Lw=0;}
166  }
167 
168  /// Overload disable resolve so that it cleans up memory too
170  {
172  clean_up_memory();
173  }
174 
175  /// \short Solver: Takes pointer to problem and returns the results Vector
176  /// which contains the solution of the linear system defined by
177  /// the problem's fully assembled Jacobian and residual Vector.
178  void solve(Problem* const &problem_pt, DoubleVector &result);
179 
180  /// \short Linear-algebra-type solver: Takes pointer to a matrix and rhs
181  /// vector and returns the solution of the linear system.
182  /// Call the broken base-class version. If you want this, please implement it
183  void solve(DoubleMatrixBase* const &matrix_pt,
184  const DoubleVector &rhs,
185  DoubleVector &result)
186  {LinearSolver::solve(matrix_pt,rhs,result);}
187 
188 
189  /// \short Linear-algebra-type solver: Takes pointer to a matrix
190  /// and rhs vector and returns the solution of the linear system
191  /// Call the broken base-class version. If you want this, please
192  /// implement it
193  void solve(DoubleMatrixBase* const &matrix_pt,
194  const Vector<double> &rhs,
195  Vector<double> &result)
196  {LinearSolver::solve(matrix_pt,rhs,result);}
197 
198 
199  /// \short Return the solution to the linear system Ax = result, where
200  /// A is the most recently factorised jacobian matrix of the problem
201  /// problem_pt. The solution is returned in the result vector.
202  void resolve(const DoubleVector &rhs, DoubleVector &result);
203 
204  /// \short Function to reorder the elements based on Sloan's algorithm
205  void reorder_elements(Problem* const &problem_pt);
206 
207  /// \short Enable documentation of statistics
208  void enable_doc_stats() {Doc_stats = true;}
209 
210  /// \short Disable documentation of statistics
211  void disable_doc_stats() {Doc_stats = false;}
212 
213  /// \short Enable reordering using Sloan's algorithm
214  void enable_reordering() {Reorder_flag = true;}
215 
216  /// \short Disable reordering
217  void disable_reordering() {Reorder_flag = false;}
218 
219  /// \short Enable use of direct access files
220  void enable_direct_access_files() {Use_direct_access_files = true;}
221 
222  /// \short Disable use of direct access files
223  void disable_direct_access_files() {Use_direct_access_files = false;}
224 
225  /// \short Factor to increase storage for lenbuf[0]; see MA42 documentation
226  /// for details.
227  double& lenbuf_factor0() {return Lenbuf_factor0;}
228 
229  /// \short Factor to increase storage for lenbuf[1]; see MA42 documentation
230  /// for details.
231  double& lenbuf_factor1() {return Lenbuf_factor1;}
232 
233  /// \short Factor to increase storage for lenbuf[2]; see MA42 documentation
234  /// for details.
235  double& lenbuf_factor2() {return Lenbuf_factor2;}
236 
237  /// \short Factor to increase storage for front size; see MA42 documentation
238  /// for details.
239  double& front_factor(){return Front_factor;}
240 
241  /// \short Factor to increase the size of the direct access files;
242  /// see MA42 documentation for details.
243  double& lenfle_factor(){return Lenfle_factor;}
244 
245 
246 };
247 
248 }
249 
250 #endif
void solve(DoubleMatrixBase *const &matrix_pt, const DoubleVector &rhs, DoubleVector &result)
Linear-algebra-type solver: Takes pointer to a matrix and rhs vector and returns the solution of the ...
virtual void solve(Problem *const &problem_pt, DoubleVector &result)=0
Solver: Takes pointer to problem and returns the results vector which contains the solution of the li...
double Lenbuf_factor2
Factor to increase storage for lenbuf[2]; see MA42 documentation for details.
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
int Icntl[8]
Control flag for MA42; see MA42 documentation for details.
void disable_doc_stats()
Disable documentation of statistics.
bool Reorder_flag
Reorder elements with Sloan&#39;s algorithm?
bool Doc_stats
Doc the solver stats or stay quiet?
bool Use_direct_access_files
Use direct access files?
unsigned long N_dof
Size of the linear system.
int Liw
Size of the integer workspace array.
The Problem class.
Definition: problem.h:152
void disable_resolve()
Overload disable resolve so that it cleans up memory too.
double Lenbuf_factor0
Factor to increase storage for lenbuf[0]; see MA42 documentation for details.
void enable_reordering()
Enable reordering using Sloan&#39;s algorithm.
double Lenbuf_factor1
Factor to increase storage for lenbuf[1]; see MA42 documentation for details.
double & lenfle_factor()
Factor to increase the size of the direct access files; see MA42 documentation for details...
HSL_MA42()
Constructor: By default suppress verbose output (stats), don&#39;t reorder elements and don&#39;t use direct ...
double & lenbuf_factor2()
Factor to increase storage for lenbuf[2]; see MA42 documentation for details.
void clean_up_memory()
Clean up memory.
void enable_doc_stats()
Enable documentation of statistics.
void enable_direct_access_files()
Enable use of direct access files.
int Info[23]
Control flag for MA42; see MA42 documentation for details.
void disable_direct_access_files()
Disable use of direct access files.
double & lenbuf_factor0()
Factor to increase storage for lenbuf[0]; see MA42 documentation for details.
void operator=(const HSL_MA42 &)
Broken assignment operator.
int * IW
Integer workspace storage for MA42.
void reorder_elements(Problem *const &problem_pt)
Function to reorder the elements based on Sloan&#39;s algorithm.
double * W
Workspace storage for MA42.
double Front_factor
Factor to increase storage for front size; see MA42 documentation for details.
double & lenbuf_factor1()
Factor to increase storage for lenbuf[1]; see MA42 documentation for details.
void resolve(const DoubleVector &rhs, DoubleVector &result)
Return the solution to the linear system Ax = result, where A is the most recently factorised jacobia...
virtual void disable_resolve()
Disable resolve (i.e. store matrix and/or LU decomposition, say) This function simply resets an inter...
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
void solve(DoubleMatrixBase *const &matrix_pt, const Vector< double > &rhs, Vector< double > &result)
Linear-algebra-type solver: Takes pointer to a matrix and rhs vector and returns the solution of the ...
void solve(Problem *const &problem_pt, DoubleVector &result)
Solver: Takes pointer to problem and returns the results Vector which contains the solution of the li...
double & front_factor()
Factor to increase storage for front size; see MA42 documentation for details.
void disable_reordering()
Disable reordering.
double Lenfle_factor
Factor to increase size of direct access files; see MA42 documentation for details.
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
HSL_MA42(const HSL_MA42 &)
Broken copy constructor.
~HSL_MA42()
Destructor, clean up the allocated memory.
Abstract base class for matrices of doubles – adds abstract interfaces for solving, LU decomposition and multiplication by vectors.
Definition: matrices.h:275
int Isave[45]
Control flag for MA42; see MA42 documentation for details.
void solve_for_one_dof(Problem *const &problem_pt, DoubleVector &result)
Special solver for problems with 1 dof (MA42 can&#39;t handle this case so solve() forwards the "solve" t...
int Lw
Size of the workspace array, W.