linear_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// 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
27// This header defines a class for linear solvers
28
29// Include guards
30#ifndef OOMPH_LINEAR_SOLVER_HEADER
31#define OOMPH_LINEAR_SOLVER_HEADER
32
33
34// Config header
35#ifdef HAVE_CONFIG_H
36#include <oomph-lib-config.h>
37#endif
38
39#ifdef OOMPH_HAS_MPI
40#include "mpi.h"
41#endif
42
43// oomph-lib headers
44#include "Vector.h"
45#include "double_vector.h"
46#include "matrices.h"
47#include "matrices.h"
48#include "preconditioner.h"
49
50namespace oomph
51{
52 // Forward declaration of problem class
53 class Problem;
54
55 //====================================================================
56 /// Base class for all linear solvers. This merely defines standard
57 /// interfaces for linear solvers, so that different solvers can be
58 /// used in a clean and transparent manner. Note that LinearSolvers
59 /// are primarily used to solve the linear systems arising in
60 /// oomph-lib's Newton iteration. Their primary solve function
61 /// therefore takes a pointer to the associated problem, construct its
62 /// Jacobian matrix and residual vector, and return the solution
63 /// of the linear system formed by the Jacobian and the residual vector.
64 /// We also provide broken virtual interfaces
65 /// to a linear-algebra-type solve function in which the matrix
66 /// and the rhs can be specified, but this are not guaranteed to
67 /// implemented for all linear solvers (e.g. for frontal solvers).
68 //====================================================================
70 {
71 protected:
72 /// Boolean that indicates whether the matrix (or its factors, in
73 /// the case of direct solver) should be stored so that the resolve function
74 /// can be used.
76
77 /// Boolean flag that indicates whether the time taken
78 // for the solves should be documented
80
81 /// flag that indicates whether the gradient required for the
82 /// globally convergent Newton method should be computed or not
84
85 /// flag that indicates whether the gradient was computed or not
87
88 /// DoubleVector storing the gradient for the globally convergent
89 /// Newton method
91
92 public:
93 /// Empty constructor, initialise the member data
101
102 /// Broken copy constructor
104
105 /// Broken assignment operator
106 void operator=(const LinearSolver&) = delete;
107
108 /// Empty virtual destructor
109 virtual ~LinearSolver() {}
110
111 /// Enable documentation of solve times
113 {
114 Doc_time = true;
115 }
116
117 /// Disable documentation of solve times
119 {
120 Doc_time = false;
121 }
122
123 /// Is documentation of solve times enabled?
125 {
126 return Doc_time;
127 }
128
129 /// Boolean flag indicating if resolves are enabled
131 {
132 return Enable_resolve;
133 }
134
135 /// Enable resolve (i.e. store matrix and/or LU decomposition, say)
136 /// Virtual so it can be overloaded to perform additional tasks
137 virtual void enable_resolve()
138 {
139 Enable_resolve = true;
140 }
141
142 /// Disable resolve (i.e. store matrix and/or LU decomposition, say)
143 /// This function simply resets an internal flag. It's virtual so
144 /// it can be overloaded to perform additional tasks such as
145 /// cleaning up memory that is only required for the resolve.
146 virtual void disable_resolve()
147 {
148 Enable_resolve = false;
149 }
150
151 /// Solver: Takes pointer to problem and returns the results vector
152 /// which contains the solution of the linear system defined by
153 /// the problem's fully assembled Jacobian and residual vector.
154 virtual void solve(Problem* const& problem_pt, DoubleVector& result) = 0;
155
156 /// Linear-algebra-type solver: Takes pointer to a matrix and rhs
157 /// vector and returns the solution of the linear system.
158 virtual void solve(DoubleMatrixBase* const& matrix_pt,
159 const DoubleVector& rhs,
161 {
162 throw OomphLibError(
163 "DoubleVector based solve function not implemented for this solver",
166 }
167
168 /// Linear-algebra-type solver: Takes pointer to a matrix and rhs
169 /// vector and returns the solution of the linear system.
170 virtual void solve(DoubleMatrixBase* const& matrix_pt,
171 const Vector<double>& rhs,
173 {
174 throw OomphLibError(
175 "Vector<double> based solve function not implemented for this solver",
178 }
179
180 /// Solver: Takes pointer to problem and returns the results vector
181 /// which contains the solution of the linear system defined by the
182 /// problem's fully assembled Jacobian and residual vector (broken virtual).
183 virtual void solve_transpose(Problem* const& problem_pt,
185 {
186 // Create an output stream
187 std::ostringstream error_message_stream;
188
189 // Create the error message
190 error_message_stream << "The function to solve the transposed system has "
191 << "not yet been\nimplemented for this solver."
192 << std::endl;
193
194 // Throw the error message
198 } // End of solve_transpose
199
200 /// Linear-algebra-type solver: Takes pointer to a matrix and rhs
201 /// vector and returns the solution of the linear system.
202 virtual void solve_transpose(DoubleMatrixBase* const& matrix_pt,
203 const DoubleVector& rhs,
205 {
206 throw OomphLibError(
207 "DoubleVector based solve function not implemented for this solver",
210 }
211
212 /// Linear-algebra-type solver: Takes pointer to a matrix and rhs
213 /// vector and returns the solution of the linear system.
214 virtual void solve_transpose(DoubleMatrixBase* const& matrix_pt,
215 const Vector<double>& rhs,
217 {
218 throw OomphLibError(
219 "Vector<double> based solve function not implemented for this solver",
222 }
223
224 /// Resolve the system defined by the last assembled jacobian
225 /// and the rhs vector. Solution is returned in the vector result.
226 /// (broken virtual)
228 {
229 throw OomphLibError(
230 "Resolve function not implemented for this linear solver",
233 }
234
235 /// Solver: Resolve the system defined by the last assembled jacobian
236 /// and the rhs vector. Solution is returned in the vector result.
237 /// (broken virtual)
238 virtual void resolve_transpose(const DoubleVector& rhs,
240 {
241 // Create an output stream
242 std::ostringstream error_message_stream;
243
244 // Create the error message
246 << "The function to resolve the transposed system has "
247 << "not yet been\nimplemented for this solver." << std::endl;
248
249 // Throw the error message
253 } // End of resolve_transpose
254
255 /// Empty virtual function that can be overloaded in specific
256 /// linear solvers to clean up any memory that may have been
257 /// allocated (e.g. when preparing for a re-solve).
258 virtual void clean_up_memory() {}
259
260 /// returns the time taken to assemble the Jacobian matrix and
261 /// residual vector (needs to be overloaded for each solver)
262 virtual double jacobian_setup_time() const
263 {
264 throw OomphLibError(
265 "jacobian_setup_time has not been implemented for this linear solver",
268 return 0;
269 }
270
271 /// return the time taken to solve the linear system (needs to be
272 /// overloaded for each linear solver)
273 virtual double linear_solver_solution_time() const
274 {
275 throw OomphLibError(
276 "linear_solver_solution_time() not implemented for this linear solver",
279 return 0;
280 }
281
282 /// function to enable the computation of the gradient required
283 /// for the globally convergent Newton method
285 {
286 throw OomphLibError(
287 "enable_computation_of_gradient() not implemented for "
288 "this linear solver",
291 }
292
293 /// function to disable the computation of the gradient required
294 /// for the globally convergent Newton method
296 {
297 Compute_gradient = false;
298 }
299
300 /// function to reset the size of the gradient before each Newton
301 /// solve
306
307 /// function to access the gradient, provided it has been computed
309 {
310#ifdef PARANOID
312 {
313#endif
315#ifdef PARANOID
316 }
317 else
318 {
319 throw OomphLibError(
320 "The gradient has not been computed for this linear solver!",
323 }
324#endif
325 }
326 };
327
328 //=============================================================================
329 /// Dense LU decomposition-based solve of full assembled linear system.
330 /// VERY inefficient but useful to illustrate the principle.
331 /// Only suitable for use with Serial matrices and vectors.
332 /// This solver will only work with non-distributed matrices and vectors
333 /// (note: DenseDoubleMatrix is not distributable)
334 //============================================================================
335 class DenseLU : public LinearSolver
336 {
337 /// The DenseDoubleMatrix class is a friend
338 friend class DenseDoubleMatrix;
339
340 public:
341 /// Constructor, initialise storage
343 : Jacobian_setup_time(0.0),
344 Solution_time(0.0),
346 Index(0),
347 LU_factors(0)
348 {
349 // Shut up!
350 Doc_time = false;
351 }
352
353 /// Broken copy constructor
354 DenseLU(const DenseLU& dummy) = delete;
355
356 /// Broken assignment operator
357 void operator=(const DenseLU&) = delete;
358
359 /// Destructor, clean up the stored LU factors
361 {
363 }
364
365 /// Solver: Takes pointer to problem and returns the results Vector
366 /// which contains the solution of the linear system defined by
367 /// the problem's fully assembled Jacobian and residual Vector.
368 void solve(Problem* const& problem_pt, DoubleVector& result);
369
370 /// Linear-algebra-type solver: Takes pointer to a matrix and rhs
371 /// vector and returns the solution of the linear system.
372 void solve(DoubleMatrixBase* const& matrix_pt,
373 const DoubleVector& rhs,
375
376 /// Linear-algebra-type solver: Takes pointer to a matrix and rhs
377 /// vector and returns the solution of the linear system.
378 void solve(DoubleMatrixBase* const& matrix_pt,
379 const Vector<double>& rhs,
381
382 /// returns the time taken to assemble the jacobian matrix and
383 /// residual vector
384 double jacobian_setup_time() const
385 {
386 return Jacobian_setup_time;
387 }
388
389 /// return the time taken to solve the linear system (needs to be
390 /// overloaded for each linear solver)
391 virtual double linear_solver_solution_time() const
392 {
393 return Solution_time;
394 }
395
396 protected:
397 /// Perform the LU decomposition of the matrix
398 void factorise(DoubleMatrixBase* const& matrix_pt);
399
400 /// Do the backsubstitution step to solve the system LU result = rhs
402
403 /// perform back substitution using Vector<double>
405
406 /// Clean up the stored LU factors
407 void clean_up_memory();
408
409 /// Jacobian setup time
411
412 /// Solution time
414
415 /// Sign of the determinant of the matrix
416 /// (obtained during the LU decomposition)
418
419 private:
420 /// Pointer to storage for the index of permutations in the LU solve
421 long* Index;
422
423 /// Pointer to storage for the LU decomposition
424 double* LU_factors;
425 };
426
427
428 //====================================================================
429 /// Dense LU decomposition-based solve of linear system
430 /// assembled via finite differencing of the residuals Vector.
431 /// Even more inefficient than DenseLU but excellent sanity check!
432 //====================================================================
433 class FD_LU : public DenseLU
434 {
435 public:
436 /// Constructor: empty
437 FD_LU() : DenseLU() {}
438
439 /// Broken copy constructor
440 FD_LU(const FD_LU& dummy) = delete;
441
442 /// Broken assignment operator
443 void operator=(const FD_LU&) = delete;
444
445 /// Solver: Takes pointer to problem and returns the results Vector
446 /// which contains the solution of the linear system defined by
447 /// the problem's residual Vector (Jacobian computed by FD approx.)
448 void solve(Problem* const& problem_pt, DoubleVector& result);
449
450 /// Linear-algebra-type solver: Takes pointer to a matrix and rhs
451 /// vector and returns the solution of the linear system.
452 void solve(DoubleMatrixBase* const& matrix_pt,
453 const DoubleVector& rhs,
455 {
456 DenseLU::solve(matrix_pt, rhs, result);
457 }
458
459 /// Linear-algebra-type solver: Takes pointer to a matrix
460 /// and rhs vector and returns the solution of the linear system
461 /// Call the broken base-class version. If you want this, please
462 /// implement it
463 void solve(DoubleMatrixBase* const& matrix_pt,
464 const Vector<double>& rhs,
466 {
467 LinearSolver::solve(matrix_pt, rhs, result);
468 }
469 };
470
471
472 ///////////////////////////////////////////////////////////////////////////////
473 ///////////////////////////////////////////////////////////////////////////////
474 ///////////////////////////////////////////////////////////////////////////////
475
476
477 //=============================================================================
478 /// SuperLU Project Solver class. This is a combined wrapper for both
479 /// SuperLU and SuperLU Dist.
480 /// See http://crd.lbl.gov/~xiaoye/SuperLU/
481 /// Default Behaviour: If this solver is distributed over more than one
482 /// processor then SuperLU Dist is used.
483 /// Member data naming convention: member data associated with the SuperLU
484 /// Dist solver begins Dist_... and member data associated with the serial
485 /// SuperLU solver begins Serial_... .
486 //=============================================================================
488 {
489 public:
490 /// enum type to specify the solver behaviour.
491 /// Default - will employ superlu dist if more than 1 processor.
492 /// Serial - will always try use superlu (serial).
493 /// Distributed - will always try to use superlu dist.
500
501 /// Constructor. Set the defaults.
503 {
504 // Set solver wide default values and null pointers
505 Doc_stats = false;
506 Suppress_solve = false;
507 Using_dist = false;
509
510#ifdef OOMPH_HAS_MPI
511 // Set default values and nullify pointers for SuperLU Dist
518 Dist_value_pt = 0;
519 Dist_index_pt = 0;
520 Dist_start_pt = 0;
521#endif
522
523 // Set default values and null pointers for SuperLU (serial)
526 Serial_n_dof = 0;
527 }
528
529 /// Broken copy constructor
531
532 /// Broken assignment operator
533 void operator=(const SuperLUSolver&) = delete;
534
535 /// Destructor, clean up the stored matrices
537 {
539 }
540
541 /// function to enable the computation of the gradient
543 {
544 Compute_gradient = true;
545 }
546
547 // SuperLUSolver methods
548 ////////////////////////
549
550 /// Overload disable resolve so that it cleans up memory too
556
557 /// Solver: Takes pointer to problem and returns the results Vector
558 /// which contains the solution of the linear system defined by
559 /// the problem's fully assembled Jacobian and residual Vector.
560 void solve(Problem* const& problem_pt, DoubleVector& result);
561
562 /// Linear-algebra-type solver: Takes pointer to a matrix and rhs
563 /// vector and returns the solution of the linear system.
564 /// The function returns the global result Vector.
565 /// Note: if Delete_matrix_data is true the function
566 /// matrix_pt->clean_up_memory() will be used to wipe the matrix data.
567 void solve(DoubleMatrixBase* const& matrix_pt,
568 const DoubleVector& rhs,
570
571
572 /* /// Linear-algebra-type solver: Takes pointer to a matrix */
573 /* /// and rhs vector and returns the solution of the linear system */
574 /* /// Call the broken base-class version. If you want this, please */
575 /* /// implement it */
576 /* void solve(DoubleMatrixBase* const &matrix_pt, */
577 /* const Vector<double> &rhs, */
578 /* Vector<double> &result) */
579 /* {LinearSolver::solve(matrix_pt,rhs,result);} */
580
581 /// Solver: Takes pointer to problem and returns the results Vector
582 /// which contains the solution of the linear system defined by
583 /// the problem's fully assembled Jacobian and residual Vector.
584 void solve_transpose(Problem* const& problem_pt, DoubleVector& result);
585
586 /// Linear-algebra-type solver: Takes pointer to a matrix and rhs
587 /// vector and returns the solution of the linear system.
588 /// The function returns the global result Vector.
589 /// Note: if Delete_matrix_data is true the function
590 /// matrix_pt->clean_up_memory() will be used to wipe the matrix data.
591 void solve_transpose(DoubleMatrixBase* const& matrix_pt,
592 const DoubleVector& rhs,
594
595 /// Resolve the system defined by the last assembled jacobian
596 /// and the specified rhs vector if resolve has been enabled.
597 /// Note: returns the global result Vector.
599
600 /// Resolve the (transposed) system defined by the last assembled
601 /// Jacobian and the specified rhs vector if resolve has been enabled.
603
604 /// Enable documentation of solver statistics
606 {
607 Doc_stats = true;
608 }
609
610 /// Disable documentation of solver statistics
612 {
613 Doc_stats = false;
614 }
615
616 /// returns the time taken to assemble the jacobian matrix and
617 /// residual vector
618 double jacobian_setup_time() const
619 {
620 return Jacobian_setup_time;
621 }
622
623 /// return the time taken to solve the linear system (needs to be
624 /// overloaded for each linear solver)
625 virtual double linear_solver_solution_time() const
626 {
627 return Solution_time;
628 }
629
630 /// Do the factorisation stage
631 /// Note: if Delete_matrix_data is true the function
632 /// matrix_pt->clean_up_memory() will be used to wipe the matrix data.
633 void factorise(DoubleMatrixBase* const& matrix_pt);
634
635 /// Do the backsubstitution for SuperLU solver
636 /// Note: returns the global result Vector.
638
639 /// Do the back-substitution for transposed system of the SuperLU
640 /// solver Note: Returns the global result Vector.
642
643 /// Clean up the memory allocated by the solver
644 void clean_up_memory();
645
646 /// Specify the solve type. Either default, serial or distributed.
647 /// See enum SuperLU_solver_type for more details.
648 void set_solver_type(const Type& t)
649 {
650 this->clean_up_memory();
651 Solver_type = t;
652 }
653
654 // SuperLU (serial) methods
655 ///////////////////////////
656
657 /// Use the compressed row format in superlu serial
662
663 /// Use the compressed column format in superlu serial
668
669#ifdef OOMPH_HAS_MPI
670
671 // SuperLU Dist methods
672 ///////////////////////
673
674 /// Set Delete_matrix_data flag. SuperLU_dist needs its own copy
675 /// of the input matrix, therefore a copy must be made if any matrix
676 /// used with this solver is to be preserved. If the input matrix can be
677 /// deleted the flag can be set to true to reduce the amount of memory
678 /// required, and the matrix data will be wiped using its clean_up_memory()
679 /// function. Default value is false.
684
685 /// Unset Delete_matrix_data flag. SuperLU_dist needs its own copy
686 /// of the input matrix, therefore a copy must be made if any matrix
687 /// used with this solver is to be preserved. If the input matrix can be
692
693 /// Set flag so that SuperLU_DIST is allowed to permute matrix rows
694 /// and columns during factorisation. This is the default for SuperLU_DIST,
695 /// and can lead to significantly faster solves.
700
701 /// Set flag so that SuperLU_DIST is not allowed to permute matrix
702 /// rows and columns during factorisation.
707
708 /// Calling this method will ensure that when the problem based
709 /// solve interface is used, a global (serial) jacobian will be
710 /// assembled.
711 /// Note: calling this function will delete any distributed solve data.
713 {
715 {
718 }
719 }
720
721 /// Calling this method will ensure that when the problem based
722 /// solve interface is used, a distributed jacobian will be
723 /// assembled.
724 /// Note: calling this function will delete any global solve data.
733
734#endif
735
736 private:
737 /// factorise method for SuperLU (serial)
738 void factorise_serial(DoubleMatrixBase* const& matrix_pt);
739
740 /// backsub method for SuperLU (serial)
742
743 /// backsub method for SuperLU (serial)
746
747#ifdef OOMPH_HAS_MPI
748 /// factorise method for SuperLU Dist
749 void factorise_distributed(DoubleMatrixBase* const& matrix_pt);
750
751 /// backsub method for SuperLU Dist
753
754 /// backsub method for SuperLU Dist
757#endif
758
759 // SuperLUSolver member data
760 ////////////////////////////
761
762 /// Jacobian setup time
764
765 /// Solution time
767
768 /// Suppress solve?
770
771 /// Set to true to output statistics (false by default).
773
774 /// the solver type. see SuperLU_solver_type for details.
776
777 /// boolean flag indicating whether superlu dist is being used
779
780 // SuperLU (serial) member data
781 ///////////////////////////////
782
783 /// Storage for the LU factors as required by SuperLU
785
786 /// Info flag for the SuperLU solver
788
789 /// The number of unknowns in the linear system
790 unsigned long Serial_n_dof;
791
792 /// Sign of the determinant of the matrix
794
795 /// Use compressed row version?
797
798 public:
799 /// How much memory do the LU factors take up? In bytes
801
802 /// How much memory was allocated by SuperLU? In bytes
804
805 private:
806#ifdef OOMPH_HAS_MPI
807
808 // SuperLU Dist member data
809 ///////////////////////////
810 public:
811 /// Static flag that determines whether the warning about
812 /// incorrect distribution of RHSs will be printed or not
814
815 private:
816 /// Flag that determines whether the MPIProblem based solve function
817 /// uses the global or distributed version of SuperLU_DIST
818 /// (default value is false).
820
821 /// Flag is true if solve data has been generated for a global matrix
823
824 /// Flag is true if solve data has been generated for distributed matrix
826
827 /// Storage for the LU factors and other data required by SuperLU
829
830 /// Number of rows for the process grid
832
833 /// Number of columns for the process grid
835
836 /// Info flag for the SuperLU solver
838
839 /// If true then SuperLU_DIST is allowed to permute matrix rows
840 /// and columns during factorisation. This is the default for SuperLU_DIST,
841 /// and can lead to significantly faster solves, but has been known to
842 /// fail, hence the default value is 0.
844
845 /// Delete_matrix_data flag. SuperLU_dist needs its own copy
846 /// of the input matrix, therefore a copy must be made if any matrix
847 /// used with this solver is to be preserved. If the input matrix can be
848 /// deleted the flag can be set to true to reduce the amount of memory
849 /// required, and the matrix data will be wiped using its clean_up_memory()
850 /// function. Default value is false.
852
853 /// Pointer for storage of the matrix values required by SuperLU_DIST
855
856 /// Pointer for storage of matrix rows or column indices required
857 /// by SuperLU_DIST
859
860 /// Pointers for storage of matrix column or row starts
861 // required by SuperLU_DIST
863
864#endif
865 }; // end of SuperLUSolver
866
867
868 /////////////////////////////////////////////////////////////////////////
869 /////////////////////////////////////////////////////////////////////////
870 /////////////////////////////////////////////////////////////////////////
871
872
873 /// Namespace containing functions required to create exact preconditioner
874 namespace ExactPreconditionerFactory
875 {
876
877 /// Factory function to create suitable exact preconditioner
879
880 } // namespace ExactPreconditionerFactory
881
882
883} // namespace oomph
884#endif
char t
Definition cfortran.h:568
Class of matrices containing doubles, and stored as a DenseMatrix<double>, but with solving functiona...
Definition matrices.h:1271
Dense LU decomposition-based solve of full assembled linear system. VERY inefficient but useful to il...
~DenseLU()
Destructor, clean up the stored LU factors.
double Jacobian_setup_time
Jacobian setup time.
double jacobian_setup_time() const
returns the time taken to assemble the jacobian matrix and residual vector
void backsub(const DoubleVector &rhs, DoubleVector &result)
Do the backsubstitution step to solve the system LU result = rhs.
void clean_up_memory()
Clean up the stored LU factors.
long * Index
Pointer to storage for the index of permutations in the LU solve.
DenseLU()
Constructor, initialise storage.
void factorise(DoubleMatrixBase *const &matrix_pt)
Perform the LU decomposition of the matrix.
double * LU_factors
Pointer to storage for the LU decomposition.
void operator=(const DenseLU &)=delete
Broken assignment operator.
virtual double linear_solver_solution_time() const
return the time taken to solve the linear system (needs to be overloaded for each linear solver)
double Solution_time
Solution time.
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...
DenseLU(const DenseLU &dummy)=delete
Broken copy constructor.
int Sign_of_determinant_of_matrix
Sign of the determinant of the matrix (obtained during the LU decomposition)
Base class for any linear algebra object that is distributable. Just contains storage for the LinearA...
Abstract base class for matrices of doubles – adds abstract interfaces for solving,...
Definition matrices.h:261
A vector in the mathematical sense, initially developed for linear algebra type applications....
void clear()
wipes the DoubleVector
Dense LU decomposition-based solve of linear system assembled via finite differencing of the residual...
FD_LU()
Constructor: empty.
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...
FD_LU(const FD_LU &dummy)=delete
Broken copy constructor.
void operator=(const FD_LU &)=delete
Broken assignment operator.
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 ...
Base class for all linear solvers. This merely defines standard interfaces for linear solvers,...
void operator=(const LinearSolver &)=delete
Broken assignment operator.
virtual double jacobian_setup_time() const
returns the time taken to assemble the Jacobian matrix and residual vector (needs to be overloaded fo...
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...
virtual 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 ...
virtual void enable_resolve()
Enable resolve (i.e. store matrix and/or LU decomposition, say) Virtual so it can be overloaded to pe...
virtual void enable_computation_of_gradient()
function to enable the computation of the gradient required for the globally convergent Newton method
virtual void resolve(const DoubleVector &rhs, DoubleVector &result)
Resolve the system defined by the last assembled jacobian and the rhs vector. Solution is returned in...
virtual double linear_solver_solution_time() const
return the time taken to solve the linear system (needs to be overloaded for each linear solver)
bool is_doc_time_enabled() const
Is documentation of solve times enabled?
virtual void solve_transpose(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 ...
bool Doc_time
Boolean flag that indicates whether the time taken.
virtual 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 ...
bool Enable_resolve
Boolean that indicates whether the matrix (or its factors, in the case of direct solver) should be st...
virtual void solve_transpose(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 ...
void get_gradient(DoubleVector &gradient)
function to access the gradient, provided it has been computed
LinearSolver(const LinearSolver &dummy)=delete
Broken copy constructor.
LinearSolver()
Empty constructor, initialise the member data.
void disable_computation_of_gradient()
function to disable the computation of the gradient required for the globally convergent Newton metho...
virtual void solve_transpose(Problem *const &problem_pt, DoubleVector &result)
Solver: Takes pointer to problem and returns the results vector which contains the solution of the li...
void disable_doc_time()
Disable documentation of solve times.
virtual ~LinearSolver()
Empty virtual destructor.
virtual void clean_up_memory()
Empty virtual function that can be overloaded in specific linear solvers to clean up any memory that ...
bool Gradient_has_been_computed
flag that indicates whether the gradient was computed or not
void enable_doc_time()
Enable documentation of solve times.
void reset_gradient()
function to reset the size of the gradient before each Newton solve
virtual void resolve_transpose(const DoubleVector &rhs, DoubleVector &result)
Solver: Resolve the system defined by the last assembled jacobian and the rhs vector....
DoubleVector Gradient_for_glob_conv_newton_solve
DoubleVector storing the gradient for the globally convergent Newton method.
virtual void disable_resolve()
Disable resolve (i.e. store matrix and/or LU decomposition, say) This function simply resets an inter...
bool is_resolve_enabled() const
Boolean flag indicating if resolves are enabled.
bool Compute_gradient
flag that indicates whether the gradient required for the globally convergent Newton method should be...
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...
////////////////////////////////////////////////////////////////// //////////////////////////////////...
Definition problem.h:154
SuperLU Project Solver class. This is a combined wrapper for both SuperLU and SuperLU Dist....
SuperLUSolver(const SuperLUSolver &dummy)=delete
Broken copy constructor.
bool Doc_stats
Set to true to output statistics (false by default).
bool Dist_delete_matrix_data
Delete_matrix_data flag. SuperLU_dist needs its own copy of the input matrix, therefore a copy must b...
void solve_transpose(Problem *const &problem_pt, DoubleVector &result)
Solver: Takes pointer to problem and returns the results Vector which contains the solution of the li...
static bool Suppress_incorrect_rhs_distribution_warning_in_resolve
Static flag that determines whether the warning about incorrect distribution of RHSs will be printed ...
int * Dist_index_pt
Pointer for storage of matrix rows or column indices required by SuperLU_DIST.
Type Solver_type
the solver type. see SuperLU_solver_type for details.
void operator=(const SuperLUSolver &)=delete
Broken assignment operator.
void disable_row_and_col_permutations_in_superlu_dist()
Set flag so that SuperLU_DIST is not allowed to permute matrix rows and columns during factorisation.
virtual double linear_solver_solution_time() const
return the time taken to solve the linear system (needs to be overloaded for each linear solver)
void backsub_serial(const DoubleVector &rhs, DoubleVector &result)
backsub method for SuperLU (serial)
void enable_doc_stats()
Enable documentation of solver statistics.
void use_distributed_solve_in_superlu_dist()
Calling this method will ensure that when the problem based solve interface is used,...
void backsub_transpose_distributed(const DoubleVector &rhs, DoubleVector &result)
backsub method for SuperLU Dist
double Solution_time
Solution time.
double * Dist_value_pt
Pointer for storage of the matrix values required by SuperLU_DIST.
void use_global_solve_in_superlu_dist()
Calling this method will ensure that when the problem based solve interface is used,...
bool Serial_compressed_row_flag
Use compressed row version?
Type
enum type to specify the solver behaviour. Default - will employ superlu dist if more than 1 processo...
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...
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 factorise_serial(DoubleMatrixBase *const &matrix_pt)
factorise method for SuperLU (serial)
void backsub_distributed(const DoubleVector &rhs, DoubleVector &result)
backsub method for SuperLU Dist
bool Using_dist
boolean flag indicating whether superlu dist is being used
int * Dist_start_pt
Pointers for storage of matrix column or row starts.
unsigned long Serial_n_dof
The number of unknowns in the linear system.
void set_solver_type(const Type &t)
Specify the solve type. Either default, serial or distributed. See enum SuperLU_solver_type for more ...
void * Serial_f_factors
Storage for the LU factors as required by SuperLU.
void resolve_transpose(const DoubleVector &rhs, DoubleVector &result)
Resolve the (transposed) system defined by the last assembled Jacobian and the specified rhs vector i...
SuperLUSolver()
Constructor. Set the defaults.
void disable_delete_matrix_data_in_superlu_dist()
Unset Delete_matrix_data flag. SuperLU_dist needs its own copy of the input matrix,...
bool Suppress_solve
Suppress solve?
void enable_row_and_col_permutations_in_superlu_dist()
Set flag so that SuperLU_DIST is allowed to permute matrix rows and columns during factorisation....
void enable_delete_matrix_data_in_superlu_dist()
Set Delete_matrix_data flag. SuperLU_dist needs its own copy of the input matrix, therefore a copy mu...
~SuperLUSolver()
Destructor, clean up the stored matrices.
double jacobian_setup_time() const
returns the time taken to assemble the jacobian matrix and residual vector
int Serial_sign_of_determinant_of_matrix
Sign of the determinant of the matrix.
bool Dist_use_global_solver
Flag that determines whether the MPIProblem based solve function uses the global or distributed versi...
double get_memory_usage_for_lu_factors()
How much memory do the LU factors take up? In bytes.
void factorise_distributed(DoubleMatrixBase *const &matrix_pt)
factorise method for SuperLU Dist
bool Dist_allow_row_and_col_permutations
If true then SuperLU_DIST is allowed to permute matrix rows and columns during factorisation....
int Dist_info
Info flag for the SuperLU solver.
void use_compressed_column_for_superlu_serial()
Use the compressed column format in superlu serial.
void disable_resolve()
Overload disable resolve so that it cleans up memory too.
bool Dist_global_solve_data_allocated
Flag is true if solve data has been generated for a global matrix.
double get_total_needed_memory()
How much memory was allocated by SuperLU? In bytes.
double Jacobian_setup_time
Jacobian setup time.
void backsub_transpose_serial(const DoubleVector &rhs, DoubleVector &result)
backsub method for SuperLU (serial)
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 use_compressed_row_for_superlu_serial()
Use the compressed row format in superlu serial.
void disable_doc_stats()
Disable documentation of solver statistics.
void * Dist_solver_data_pt
Storage for the LU factors and other data required by SuperLU.
bool Dist_distributed_solve_data_allocated
Flag is true if solve data has been generated for distributed matrix.
int Dist_npcol
Number of columns for the process grid.
void backsub(const DoubleVector &rhs, DoubleVector &result)
Do the backsubstitution for SuperLU solver Note: returns the global result Vector.
void enable_computation_of_gradient()
function to enable the computation of the gradient
void clean_up_memory()
Clean up the memory allocated by the solver.
int Dist_nprow
Number of rows for the process grid.
void backsub_transpose(const DoubleVector &rhs, DoubleVector &result)
Do the back-substitution for transposed system of the SuperLU solver Note: Returns the global result ...
int Serial_info
Info flag for the SuperLU solver.
TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D> elements are isoparametric triangular DIM-d...
Preconditioner * create_exact_preconditioner()
Factory function to create suitable exact preconditioner.
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).