30#include <oomph-lib-config.h>
61 const unsigned n_dof = problem_pt->
ndof();
81 <<
"CPU for setup of Dense Jacobian: "
138 const unsigned long n = matrix_pt->
nrow();
151 for (
unsigned long i = 0;
i <
n;
i++)
154 for (
unsigned long j = 0;
j <
n;
j++)
156 double tmp = std::fabs((*matrix_pt)(
i,
j));
181 for (
unsigned long i = 0;
i <
n;
i++)
183 for (
unsigned long j = 0;
j <
n;
j++)
191 for (
unsigned long j = 0;
j <
n;
j++)
194 unsigned long imax = 0;
196 for (
unsigned long i = 0;
i <
j;
i++)
199 for (
unsigned long k = 0;
k <
i;
k++)
208 for (
unsigned long i =
j;
i <
n;
i++)
211 for (
unsigned long k = 0;
k <
j;
k++)
217 double tmp = scaling[
i] * std::fabs(
sum);
228 for (
unsigned long k = 0;
k <
n;
k++)
238 scaling[
imax] = scaling[
j];
251 for (
unsigned long i =
j + 1;
i <
n;
i++)
265 for (
unsigned i = 0;
i <
n;
i++)
331 const unsigned long n =
rhs.nrow();
332 for (
unsigned long i = 0;
i <
n; ++
i)
339 for (
unsigned long i = 0;
i <
n;
i++)
346 for (
unsigned long j =
k - 1;
j <
i;
j++)
359 for (
long i =
long(
n) - 1;
i >= 0;
i--)
380 for (
unsigned long i = 0;
i <
n; ++
i)
387 for (
unsigned long i = 0;
i <
n;
i++)
394 for (
unsigned long j =
k - 1;
j <
i;
j++)
407 for (
long i =
long(
n) - 1;
i >= 0;
i--)
429 if (
rhs.distribution_pt()->distributed())
433 <<
"The vectors rhs and result must not be distributed";
440 if (matrix_pt->
nrow() != matrix_pt->
ncol())
449 if (matrix_pt->
nrow() !=
rhs.nrow())
453 <<
"The matrix and the rhs vector must have the same number of rows.";
465 if (
dist_matrix_pt->distribution_pt()->communicator_pt()->nproc() > 1 &&
469 "Matrix must not be distributed or only one processor",
478 <<
"The matrix matrix_pt must have the same communicator as the "
480 <<
" rhs and result must have the same communicator";
488 if (
result.distribution_built())
490 if (!(*
result.distribution_pt() == *
rhs.distribution_pt()))
494 <<
"The result vector distribution has been setup; it must have the "
495 <<
"same distribution as the rhs vector.";
503 if (!
result.distribution_built())
505 result.build(
rhs.distribution_pt(), 0.0);
527 <<
"CPU for solve with DenseLU : "
601 unsigned long n_dof = problem_pt->
ndof();
622 <<
"CPU for setup of Dense Jacobian: "
641 oomph_info <<
"CPU for FD DenseLU LinearSolver: "
864 oomph_info <<
"Time to set up CRDoubleMatrix Jacobian : "
878 (!(*
result.distribution_pt() == *
this->distribution_pt())))
881 result.distribution_pt());
926 result.distribution_pt());
981 <<
"Time to set up CRDoubleMatrix Jacobian : "
994 (!(*
result.distribution_pt() == *
this->distribution_pt())))
997 result.distribution_pt());
1035 oomph_info <<
"\nTime to set up CCDoubleMatrix Jacobian: "
1048 (!(*
result.distribution_pt() == *
this->distribution_pt())))
1051 result.distribution_pt());
1101 if (matrix_pt->
nrow() != matrix_pt->
ncol())
1116 if (
cr_pt->nnz() == 0)
1120 <<
"Attempted to call SuperLu on a CRDoubleMatrix with no entries, "
1121 <<
"SuperLU would segfault (because the values array pt is "
1122 <<
"uninitialised or null).";
1130 if (matrix_pt->
nrow() !=
rhs.nrow())
1134 <<
"The matrix and the rhs vector must have the same number of rows.";
1150 <<
"The matrix matrix_pt must have the same distribution as the "
1161 if (
rhs.distribution_pt()->distributed())
1165 <<
"The matrix (matrix_pt) is not distributable and therefore the rhs"
1166 <<
" vector must not be distributed";
1176 if (!(*
result.distribution_pt() == *
rhs.distribution_pt()))
1180 <<
"The result vector distribution has been setup; it must have the "
1181 <<
"same distribution as the rhs vector.";
1238 if (
cr_pt->nnz() != 0)
1248 ((2 * ((
n_row + 1) *
sizeof(
int))) +
1249 (
n_nnz * (
sizeof(
int) +
sizeof(
double))));
1265 <<
"\n - Memory used to store the Jacobian (MB): "
1267 <<
"\n - Memory used to store the LU factors (MB): "
1269 <<
"\n - Total memory used for matrix storage (MB): "
1294 <<
"Time for LU factorisation : "
1296 <<
"\nTime for back-substitution: "
1298 <<
"\nTime for SuperLUSolver solve (ndof=" << matrix_pt->
nrow() <<
"): "
1363 oomph_info <<
"Time to set up CRDoubleMatrix Jacobian : "
1377 (!(*
result.distribution_pt() == *
this->distribution_pt())))
1380 result.distribution_pt());
1409 oomph_info <<
"Time to set up CR Jacobian : "
1425 result.distribution_pt());
1480 <<
"Time to set up CRDoubleMatrix Jacobian: "
1493 (!(*
result.distribution_pt() == *
this->distribution_pt())))
1496 result.distribution_pt());
1534 oomph_info <<
"\nTime to set up CCDoubleMatrix Jacobian: "
1547 (!(*
result.distribution_pt() == *
this->distribution_pt())))
1550 result.distribution_pt());
1599 if (matrix_pt->
nrow() != matrix_pt->
ncol())
1614 if (
cr_pt->nnz() == 0)
1618 <<
"Attempted to call SuperLu on a CRDoubleMatrix with no entries, "
1619 <<
"SuperLU would segfault (because the values array pt is "
1620 <<
"uninitialised or null).";
1628 if (matrix_pt->
nrow() !=
rhs.nrow())
1632 <<
"The matrix and the rhs vector must have the same number of rows.";
1648 <<
"The matrix matrix_pt must have the same distribution as the "
1659 if (
rhs.distribution_pt()->distributed())
1663 <<
"The matrix (matrix_pt) is not distributable and therefore the rhs"
1664 <<
" vector must not be distributed";
1674 if (!(*
result.distribution_pt() == *
rhs.distribution_pt()))
1678 <<
"The result vector distribution has been setup; it must have the "
1679 <<
"same distribution as the rhs vector.";
1721 if (
cr_pt->nnz() != 0)
1731 ((2 * ((
n_row + 1) *
sizeof(
int))) +
1732 (
n_nnz * (
sizeof(
int) +
sizeof(
double))));
1747 <<
"\n - Memory used to store the Jacobian (MB): "
1749 <<
"\n - Memory used to store the LU factors (MB): "
1751 <<
"\n - Total memory used for matrix storage (MB): "
1776 <<
"Time for LU factorisation : "
1778 <<
"\nTime for back-substitution: "
1780 <<
"\nTime for SuperLUSolver solve (ndof=" << matrix_pt->
nrow() <<
"): "
1808 oomph_info <<
"Time for SuperLUSolver solve (ndof=" <<
rhs.nrow() <<
"): "
1833 oomph_info <<
"Time for SuperLUSolver solve (ndof=" <<
rhs.nrow() <<
"): "
1895 int m = matrix_pt->
ncol();
1896 int n = matrix_pt->
nrow();
1901 <<
"N, M " <<
n <<
" " <<
m << std::endl;
1960 "To apply SuperLUSolver to a CRDoubleMatrix - it must be built",
2111 for (
int i = 0;
i < nnz;
i++)
2119 for (
int i = 0;
i < nnz;
i++)
2163 <<
" CCDoubleMatrix, CRDoubleMatrix\n"
2164 <<
"and DistributedCRDoubleMatrix matrices\n";
2175 <<
" . See the SuperLU documentation for what this means.";
2207 int n = matrix_pt->
nrow();
2211 int m = matrix_pt->
ncol();
2216 <<
"N, M " <<
n <<
" " <<
m << std::endl;
2227 int *index = 0, *start = 0;
2273 throw OomphLibError(
"SuperLU only works with CR or CC Double matrices",
2303 <<
" . See the SuperLU documentation for what this means.";
2371 if (!
rhs.distribution_pt()->built())
2383 if (!(*
rhs.distribution_pt() == *
this->distribution_pt()))
2388 warning_stream <<
"The distribution of rhs vector does not match that "
2390 warning_stream <<
"The rhs will be redistributed, which is likely to "
2393 <<
"To remove this warning you can either:\n"
2394 <<
" i) Ensure that the rhs vector has the correct distribution\n"
2395 <<
" before calling the resolve() function\n"
2396 <<
"or ii) Set the flag \n"
2397 <<
" SuperLUSolver::Suppress_incorrect_rhs_distribution_warning_in_"
2399 <<
" to be true\n\n";
2402 "SuperLUSolver::resolve()",
2416 if (!(*
result.distribution_pt() == *
rhs.distribution_pt()))
2420 <<
"The result vector distribution has been setup; it must have the "
2421 <<
"same distribution as the rhs vector.";
2460 this->distribution_pt()->communicator_pt()->mpi_comm());
2479 this->distribution_pt()->communicator_pt()->mpi_comm());
2483 throw OomphLibError(
"The matrix factors have not been stored",
2493 <<
" . See the SuperLU documentation for what this means.";
2517 <<
"need it, implement it!" << std::endl;
2549 "RHS does not have the same dimension as the linear system",
2554 if (
rhs.distribution_pt()->distributed())
2566 if (!(*
rhs.distribution_pt() == *
result.distribution_pt()))
2570 "must be the same as the "
2571 <<
"rhs distribution";
2610 <<
" . See the SuperLU documentation for what this means.";
2639 "RHS does not have the same dimension as the linear system",
2644 if (
rhs.distribution_pt()->distributed())
2656 if (!(*
rhs.distribution_pt() == *
result.distribution_pt()))
2660 "must be the same as the "
2661 <<
"rhs distribution";
2700 <<
" . See the SuperLU documentation for what this means.";
2815 namespace ExactPreconditionerFactory
2821#if defined(OOMPH_HAS_MUMPS) && \
2822 defined(OOMPH_ENABLE_MUMPS_AS_DEFAULT_LINEAR_SOLVER)
A class for compressed column matrices that store doubles.
A class for compressed row matrices. This is a distributable object.
Class of matrices containing doubles, and stored as a DenseMatrix<double>, but with solving functiona...
double Jacobian_setup_time
Jacobian setup time.
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.
void factorise(DoubleMatrixBase *const &matrix_pt)
Perform the LU decomposition of the matrix.
double * LU_factors
Pointer to storage for the LU decomposition.
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...
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...
void clear_distribution()
clear the distribution of this distributable linear algebra object
bool distributed() const
distribution is serial or distributed
unsigned nrow() const
access function to the number of global rows.
bool distribution_built() const
if the communicator_pt is null then the distribution is not setup then false is returned,...
unsigned nrow_local() const
access function for the num of local rows on this processor.
unsigned first_row() const
access function for the first row on this processor
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
Abstract base class for matrices of doubles – adds abstract interfaces for solving,...
virtual unsigned long ncol() const =0
Return the number of columns of the matrix.
virtual unsigned long nrow() const =0
Return the number of rows of the matrix.
A vector in the mathematical sense, initially developed for linear algebra type applications....
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 size() const
Calculate the size of the element (length, area, volume,...) in Eulerian computational coordinates....
Describes the distribution of a distributable linear algebra type object. Typically this is a contain...
OomphCommunicator * communicator_pt() const
const access to the communicator pointer
unsigned nrow() const
access function to the number of global rows.
bool Doc_time
Boolean flag that indicates whether the time taken.
bool Enable_resolve
Boolean that indicates whether the matrix (or its factors, in the case of direct solver) should be st...
bool Gradient_has_been_computed
flag that indicates whether the gradient was computed or not
DoubleVector Gradient_for_glob_conv_newton_solve
DoubleVector storing the gradient for the globally convergent Newton method.
bool Compute_gradient
flag that indicates whether the gradient required for the globally convergent Newton method should be...
static bool mpi_has_been_initialised()
return true if MPI has been initialised
static OomphCommunicator * communicator_pt()
access to global communicator. This is the oomph-lib equivalent of MPI_COMM_WORLD
An interface to allow Mumps to be used as an (exact) Preconditioner.
An oomph-lib wrapper to the MPI_Comm communicator object. Just contains an MPI_Comm object (which is ...
An OomphLibError object which should be thrown when an run-time error is encountered....
An OomphLibWarning object which should be created as a temporary object to issue a warning....
Preconditioner base class. Gives an interface to call all other preconditioners through and stores th...
////////////////////////////////////////////////////////////////// //////////////////////////////////...
unsigned long ndof() const
Return the number of dofs.
OomphCommunicator * communicator_pt()
access function to the oomph-lib communicator
virtual void get_jacobian(DoubleVector &residuals, DenseDoubleMatrix &jacobian)
Return the fully-assembled Jacobian and residuals for the problem Interface for the case when the Jac...
void get_fd_jacobian(DoubleVector &residuals, DenseMatrix< double > &jacobian)
Return the fully-assembled Jacobian and residuals, generated by finite differences.
int & sign_of_jacobian()
Access function for the sign of the global jacobian matrix. This will be set by the linear solver,...
An interface to allow SuperLU to be used as an (exact) Preconditioner.
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 backsub_serial(const DoubleVector &rhs, DoubleVector &result)
backsub method for SuperLU (serial)
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.
bool Serial_compressed_row_flag
Use compressed row version?
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 * 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...
bool Suppress_solve
Suppress solve?
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.
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 * 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 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.
unsigned Number
The unsigned.
std::string to_string(T object, unsigned float_precision=8)
Conversion function that should work for anything with operator<< defined (at least all basic types).
double timer()
returns the time in seconds after some point in past
std::string convert_secs_to_formatted_string(const double &time_in_sec)
Returns a nicely formatted string from an input time in seconds; the format depends on the size of ti...
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
double get_total_memory_usage_in_bytes()
Function to calculate the number of bytes used in calculating and storing the LU factors.
double get_lu_factor_memory_usage_in_bytes_dist()
Function to calculate the number of bytes used to store the LU factors.
double get_total_memory_usage_in_bytes_dist()
Function to calculate the number of bytes used in calculating and storing the LU factors.
void superlu_dist_global_matrix(int opt_flag, int allow_permutations, int n, int nnz, double *values, int *row_index, int *col_start, double *b, int nprow, int npcol, int doc, void **data, int *info, MPI_Comm comm)
void superlu_cr_to_cc(int nrow, int ncol, int nnz, double *cr_values, int *cr_index, int *cr_start, double **cc_values, int **cc_index, int **cc_start)
int superlu(int *, int *, int *, int *, double *, int *, int *, double *, int *, int *, int *, void *, int *)
OomphInfo oomph_info
Single (global) instantiation of the OomphInfo object – this is used throughout the library as a "rep...
double get_lu_factor_memory_usage_in_bytes()
Function to calculate the number of bytes used to store the LU factors.
void superlu_dist_distributed_matrix(int opt_flag, int allow_permutations, int n, int nnz_local, int nrow_local, int first_row, double *values, int *col_index, int *row_start, double *b, int nprow, int npcol, int doc, void **data, int *info, MPI_Comm comm)