30#include <oomph-lib-config.h>
57 const unsigned n_dof = problem_pt->
ndof();
77 <<
"CPU for setup of Dense Jacobian: "
84 solve(&jacobian, residuals, result);
91 double total_time = t_end - t_start;
134 const unsigned long n = matrix_pt->
nrow();
137 const double small_number = 1.0e-20;
147 for (
unsigned long i = 0;
i < n;
i++)
149 double largest_entry = 0.0;
150 for (
unsigned long j = 0; j < n; j++)
152 double tmp = std::fabs((*matrix_pt)(
i, j));
153 if (tmp > largest_entry) largest_entry = tmp;
155 if (largest_entry == 0.0)
158 "Singular Matrix", OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
161 scaling[
i] = 1.0 / largest_entry;
177 for (
unsigned long i = 0;
i < n;
i++)
179 for (
unsigned long j = 0; j < n; j++)
187 for (
unsigned long j = 0; j < n; j++)
190 unsigned long imax = 0;
192 for (
unsigned long i = 0;
i < j;
i++)
195 for (
unsigned long k = 0; k <
i; k++)
203 double largest_entry = 0.0;
204 for (
unsigned long i = j;
i < n;
i++)
207 for (
unsigned long k = 0; k < j; k++)
213 double tmp = scaling[
i] * std::fabs(sum);
214 if (tmp >= largest_entry)
224 for (
unsigned long k = 0; k < n; k++)
231 signature = -signature;
234 scaling[imax] = scaling[j];
247 for (
unsigned long i = j + 1;
i < n;
i++)
259 double determinant_mantissa = 1.0;
260 int determinant_exponent = 0, iexp;
261 for (
unsigned i = 0;
i < n;
i++)
265 determinant_mantissa *= frexp(
LU_factors[n *
i +
i], &iexp);
268 determinant_exponent += iexp;
271 determinant_mantissa = frexp(determinant_mantissa, &iexp);
272 determinant_exponent += iexp;
299 if (determinant_mantissa > 0.0)
303 if (determinant_mantissa < 0.0)
327 const unsigned long n = rhs.
nrow();
328 for (
unsigned long i = 0;
i < n; ++
i)
330 result_pt[
i] = rhs_pt[
i];
335 for (
unsigned long i = 0;
i < n;
i++)
337 unsigned long ip =
Index[
i];
338 double sum = result_pt[ip];
339 result_pt[ip] = result_pt[
i];
342 for (
unsigned long j = k - 1; j <
i; j++)
355 for (
long i =
long(n) - 1;
i >= 0;
i--)
357 double sum = result_pt[
i];
358 for (
long j =
i + 1; j < long(n); j++)
375 const unsigned long n = rhs.size();
376 for (
unsigned long i = 0;
i < n; ++
i)
383 for (
unsigned long i = 0;
i < n;
i++)
385 unsigned long ip =
Index[
i];
386 double sum = result[ip];
387 result[ip] = result[
i];
390 for (
unsigned long j = k - 1; j <
i; j++)
403 for (
long i =
long(n) - 1;
i >= 0;
i--)
405 double sum = result[
i];
406 for (
long j =
i + 1; j < long(n); j++)
427 std::ostringstream error_message_stream;
429 <<
"The vectors rhs and result must not be distributed";
431 OOMPH_CURRENT_FUNCTION,
432 OOMPH_EXCEPTION_LOCATION);
436 if (matrix_pt->
nrow() != matrix_pt->
ncol())
438 std::ostringstream error_message_stream;
439 error_message_stream <<
"The matrix at matrix_pt must be square.";
441 OOMPH_CURRENT_FUNCTION,
442 OOMPH_EXCEPTION_LOCATION);
445 if (matrix_pt->
nrow() != rhs.
nrow())
447 std::ostringstream error_message_stream;
449 <<
"The matrix and the rhs vector must have the same number of rows.";
451 OOMPH_CURRENT_FUNCTION,
452 OOMPH_EXCEPTION_LOCATION);
459 if (dist_matrix_pt != 0)
465 "Matrix must not be distributed or only one processor",
466 OOMPH_CURRENT_FUNCTION,
467 OOMPH_EXCEPTION_LOCATION);
472 std::ostringstream error_message_stream;
474 <<
"The matrix matrix_pt must have the same communicator as the "
476 <<
" rhs and result must have the same communicator";
478 OOMPH_CURRENT_FUNCTION,
479 OOMPH_EXCEPTION_LOCATION);
488 std::ostringstream error_message_stream;
490 <<
"The result vector distribution has been setup; it must have the "
491 <<
"same distribution as the rhs vector.";
493 OOMPH_CURRENT_FUNCTION,
494 OOMPH_EXCEPTION_LOCATION);
523 <<
"CPU for solve with DenseLU : "
546 clock_t t_start = clock();
552 clock_t t_end = clock();
578 clock_t t_start = clock();
587 std::ostringstream error_message_stream;
588 error_message_stream <<
"The result vector must not be distributed";
590 OOMPH_CURRENT_FUNCTION,
591 OOMPH_EXCEPTION_LOCATION);
597 unsigned long n_dof = problem_pt->
ndof();
605 clock_t t_start = clock();
611 clock_t t_end = clock();
618 <<
"CPU for setup of Dense Jacobian: "
627 solve(&jacobian, residuals, result);
633 clock_t t_end = clock();
634 double total_time = double(t_end - t_start) / CLOCKS_PER_SEC;
637 oomph_info <<
"CPU for FD DenseLU LinearSolver: "
675 int allow_permutations,
692 int allow_permutations,
829 unsigned n_dof = problem_pt->
ndof();
860 oomph_info <<
"Time to set up CRDoubleMatrix Jacobian : "
873 if ((result.
built()) &&
879 solve(&jacobian, residuals, result);
884 solve(&jacobian, residuals, result);
923 result.
build(&dist, 0.0);
924 solve(&jacobian, residuals, result);
929 solve(&jacobian, residuals, result);
977 <<
"Time to set up CRDoubleMatrix Jacobian : "
989 if ((result.
built()) &&
995 solve(&CR_jacobian, residuals, result);
1001 solve(&CR_jacobian, residuals, result);
1031 oomph_info <<
"\nTime to set up CCDoubleMatrix Jacobian: "
1043 if ((result.
built()) &&
1049 solve(&CC_jacobian, residuals, result);
1055 solve(&CC_jacobian, residuals, result);
1089 std::ostringstream error_message_stream;
1090 error_message_stream <<
"The vectors rhs must be setup";
1092 OOMPH_CURRENT_FUNCTION,
1093 OOMPH_EXCEPTION_LOCATION);
1097 if (matrix_pt->
nrow() != matrix_pt->
ncol())
1099 std::ostringstream error_message_stream;
1100 error_message_stream <<
"The matrix at matrix_pt must be square.";
1102 OOMPH_CURRENT_FUNCTION,
1103 OOMPH_EXCEPTION_LOCATION);
1112 if (cr_pt->
nnz() == 0)
1114 std::ostringstream error_message_stream;
1115 error_message_stream
1116 <<
"Attempted to call SuperLu on a CRDoubleMatrix with no entries, "
1117 <<
"SuperLU would segfault (because the values array pt is "
1118 <<
"uninitialised or null).";
1120 OOMPH_CURRENT_FUNCTION,
1121 OOMPH_EXCEPTION_LOCATION);
1126 if (matrix_pt->
nrow() != rhs.
nrow())
1128 std::ostringstream error_message_stream;
1129 error_message_stream
1130 <<
"The matrix and the rhs vector must have the same number of rows.";
1132 OOMPH_CURRENT_FUNCTION,
1133 OOMPH_EXCEPTION_LOCATION);
1140 if (dist_matrix_pt != 0)
1144 std::ostringstream error_message_stream;
1145 error_message_stream
1146 <<
"The matrix matrix_pt must have the same distribution as the "
1149 OOMPH_CURRENT_FUNCTION,
1150 OOMPH_EXCEPTION_LOCATION);
1159 std::ostringstream error_message_stream;
1160 error_message_stream
1161 <<
"The matrix (matrix_pt) is not distributable and therefore the rhs"
1162 <<
" vector must not be distributed";
1164 OOMPH_CURRENT_FUNCTION,
1165 OOMPH_EXCEPTION_LOCATION);
1174 std::ostringstream error_message_stream;
1175 error_message_stream
1176 <<
"The result vector distribution has been setup; it must have the "
1177 <<
"same distribution as the rhs vector.";
1179 OOMPH_CURRENT_FUNCTION,
1180 OOMPH_EXCEPTION_LOCATION);
1209 double factorise_time = t_factorise_end - t_factorise_start;
1219 if (cr_pt->
nnz() != 0)
1222 unsigned n_row = cr_pt->
nrow();
1225 unsigned n_nnz = cr_pt->
nnz();
1228 double memory_usage_for_jacobian =
1229 ((2 * ((n_row + 1) *
sizeof(
int))) +
1230 (n_nnz * (
sizeof(int) +
sizeof(
double))));
1238 double total_memory_usage =
1239 memory_usage_for_jacobian + memory_usage_for_lu_storage;
1243 <<
"\n - Memory used to store the Jacobian (MB) : "
1244 << memory_usage_for_jacobian / 1.0e+06
1245 <<
"\n - Memory used to store the LU factors (MB) : "
1246 << memory_usage_for_lu_storage / 1.0e+06
1247 <<
"\n - Total memory used for matrix storage (MB): "
1248 << total_memory_usage / 1.0e+06 <<
"\n"
1263 double backsub_time = t_backsub_end - t_backsub_start;
1271 <<
"Time for LU factorisation : "
1273 <<
"\nTime for back-substitution: "
1275 <<
"\nTime for SuperLUSolver solve (ndof=" << matrix_pt->
nrow() <<
"): "
1309 unsigned n_dof = problem_pt->
ndof();
1340 oomph_info <<
"Time to set up CRDoubleMatrix Jacobian : "
1353 if ((result.
built()) &&
1386 oomph_info <<
"Time to set up CR Jacobian : "
1403 result.
build(&dist, 0.0);
1457 <<
"Time to set up CRDoubleMatrix Jacobian: "
1469 if ((result.
built()) &&
1511 oomph_info <<
"\nTime to set up CCDoubleMatrix Jacobian: "
1523 if ((result.
built()) &&
1568 std::ostringstream error_message_stream;
1569 error_message_stream <<
"The vectors rhs must be setup";
1571 OOMPH_CURRENT_FUNCTION,
1572 OOMPH_EXCEPTION_LOCATION);
1576 if (matrix_pt->
nrow() != matrix_pt->
ncol())
1578 std::ostringstream error_message_stream;
1579 error_message_stream <<
"The matrix at matrix_pt must be square.";
1581 OOMPH_CURRENT_FUNCTION,
1582 OOMPH_EXCEPTION_LOCATION);
1591 if (cr_pt->
nnz() == 0)
1593 std::ostringstream error_message_stream;
1594 error_message_stream
1595 <<
"Attempted to call SuperLu on a CRDoubleMatrix with no entries, "
1596 <<
"SuperLU would segfault (because the values array pt is "
1597 <<
"uninitialised or null).";
1599 OOMPH_CURRENT_FUNCTION,
1600 OOMPH_EXCEPTION_LOCATION);
1605 if (matrix_pt->
nrow() != rhs.
nrow())
1607 std::ostringstream error_message_stream;
1608 error_message_stream
1609 <<
"The matrix and the rhs vector must have the same number of rows.";
1611 OOMPH_CURRENT_FUNCTION,
1612 OOMPH_EXCEPTION_LOCATION);
1619 if (dist_matrix_pt != 0)
1623 std::ostringstream error_message_stream;
1624 error_message_stream
1625 <<
"The matrix matrix_pt must have the same distribution as the "
1628 OOMPH_CURRENT_FUNCTION,
1629 OOMPH_EXCEPTION_LOCATION);
1638 std::ostringstream error_message_stream;
1639 error_message_stream
1640 <<
"The matrix (matrix_pt) is not distributable and therefore the rhs"
1641 <<
" vector must not be distributed";
1643 OOMPH_CURRENT_FUNCTION,
1644 OOMPH_EXCEPTION_LOCATION);
1653 std::ostringstream error_message_stream;
1654 error_message_stream
1655 <<
"The result vector distribution has been setup; it must have the "
1656 <<
"same distribution as the rhs vector.";
1658 OOMPH_CURRENT_FUNCTION,
1659 OOMPH_EXCEPTION_LOCATION);
1688 double factorise_time = t_factorise_end - t_factorise_start;
1698 if (cr_pt->
nnz() != 0)
1701 unsigned n_row = cr_pt->
nrow();
1704 unsigned n_nnz = cr_pt->
nnz();
1707 double memory_usage_for_jacobian =
1708 ((2 * ((n_row + 1) *
sizeof(
int))) +
1709 (n_nnz * (
sizeof(int) +
sizeof(
double))));
1717 double total_memory_usage =
1718 memory_usage_for_jacobian + memory_usage_for_lu_storage;
1722 <<
"\n - Memory used to store the Jacobian (MB): "
1723 << memory_usage_for_jacobian / 1.0e+06
1724 <<
"\n - Memory used to store the LU factors (MB): "
1725 << memory_usage_for_lu_storage / 1.0e+06
1726 <<
"\n - Total memory used for matrix storage (MB): "
1727 << total_memory_usage / 1.0e+06 <<
"\n"
1742 double backsub_time = t_backsub_end - t_backsub_start;
1750 <<
"Time for LU factorisation : "
1752 <<
"\nTime for back-substitution: "
1754 <<
"\nTime for SuperLUSolver solve (ndof=" << matrix_pt->
nrow() <<
"): "
1782 oomph_info <<
"Time for SuperLUSolver solve (ndof=" << rhs.
nrow() <<
"): "
1807 oomph_info <<
"Time for SuperLUSolver solve (ndof=" << rhs.
nrow() <<
"): "
1831 if (dist_matrix_pt != 0)
1840 if (dist_matrix_pt != 0)
1869 int m = matrix_pt->
ncol();
1870 int n = matrix_pt->
nrow();
1873 std::ostringstream error_message_stream;
1874 error_message_stream <<
"Can only solve for square matrices\n"
1875 <<
"N, M " << n <<
" " << m << std::endl;
1878 OOMPH_CURRENT_FUNCTION,
1879 OOMPH_EXCEPTION_LOCATION);
1895 int nprow = int(sqrt(
double(nproc)));
1900 if (nproc % nprow == 0)
break;
1931 if (!cr_matrix_pt->
built())
1934 "To apply SuperLUSolver to a CRDoubleMatrix - it must be built",
1935 OOMPH_CURRENT_FUNCTION,
1936 OOMPH_EXCEPTION_LOCATION);
1944 const int nnz_local = int(cr_matrix_pt->
nnz());
1953 double* matrix_value_pt = cr_matrix_pt->
value();
1954 for (
int i = 0;
i < nnz_local;
i++)
1962 for (
int i = 0;
i < nnz_local;
i++)
1970 int* matrix_start_pt = cr_matrix_pt->
row_start();
1983 cr_matrix_pt->
clear();
2012 const int nnz = int(cr_matrix_pt->
nnz());
2026 cr_matrix_pt->
value(),
2036 cr_matrix_pt->
clear();
2069 const int nnz = int(serial_matrix_pt->
nnz());
2072 int ndof = int(serial_matrix_pt->
nrow());
2075 int ndof_local = ndof;
2084 double* matrix_value_pt = serial_matrix_pt->
value();
2085 for (
int i = 0;
i < nnz;
i++)
2092 int* matrix_index_pt = serial_matrix_pt->
row_index();
2093 for (
int i = 0;
i < nnz;
i++)
2100 int* matrix_start_pt = serial_matrix_pt->
column_start();
2101 for (
int i = 0;
i <= ndof_local;
i++)
2135 std::ostringstream error_message_stream;
2136 error_message_stream <<
"SuperLUSolver implemented only for "
2137 <<
" CCDoubleMatrix, CRDoubleMatrix\n"
2138 <<
"and DistributedCRDoubleMatrix matrices\n";
2140 OOMPH_CURRENT_FUNCTION,
2141 OOMPH_EXCEPTION_LOCATION);
2147 std::ostringstream error_msg;
2148 error_msg <<
"SuperLU returned the error status code " <<
Dist_info
2149 <<
" . See the SuperLU documentation for what this means.";
2151 error_msg.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
2171 std::ostringstream error_message_stream;
2172 error_message_stream <<
"The matrix must not be distributed.";
2174 OOMPH_CURRENT_FUNCTION,
2175 OOMPH_EXCEPTION_LOCATION);
2181 int n = matrix_pt->
nrow();
2185 int m = matrix_pt->
ncol();
2188 std::ostringstream error_message_stream;
2189 error_message_stream <<
"Can only solve for square matrices\n"
2190 <<
"N, M " << n <<
" " << m << std::endl;
2193 OOMPH_CURRENT_FUNCTION,
2194 OOMPH_EXCEPTION_LOCATION);
2201 int *index = 0, *
start = 0;
2224 nnz = CR_matrix_pt->
nnz();
2225 value = CR_matrix_pt->
value();
2239 nnz = CC_matrix_pt->
nnz();
2240 value = CC_matrix_pt->
value();
2247 throw OomphLibError(
"SuperLU only works with CR or CC Double matrices",
2248 OOMPH_CURRENT_FUNCTION,
2249 OOMPH_EXCEPTION_LOCATION);
2275 std::ostringstream error_msg;
2276 error_msg <<
"SuperLU returned the error status code " <<
Serial_info
2277 <<
" . See the SuperLU documentation for what this means.";
2279 error_msg.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
2347 std::ostringstream error_message_stream;
2348 error_message_stream <<
"The vectors rhs must be setup";
2350 OOMPH_CURRENT_FUNCTION,
2351 OOMPH_EXCEPTION_LOCATION);
2361 std::ostringstream warning_stream;
2362 warning_stream <<
"The distribution of rhs vector does not match that "
2364 warning_stream <<
"The rhs will be redistributed, which is likely to "
2367 <<
"To remove this warning you can either:\n"
2368 <<
" i) Ensure that the rhs vector has the correct distribution\n"
2369 <<
" before calling the resolve() function\n"
2370 <<
"or ii) Set the flag \n"
2371 <<
" SuperLUSolver::Suppress_incorrect_rhs_distribution_warning_in_"
2373 <<
" to be true\n\n";
2376 "SuperLUSolver::resolve()",
2377 OOMPH_EXCEPTION_LOCATION);
2392 std::ostringstream error_message_stream;
2393 error_message_stream
2394 <<
"The result vector distribution has been setup; it must have the "
2395 <<
"same distribution as the rhs vector.";
2397 OOMPH_CURRENT_FUNCTION,
2398 OOMPH_EXCEPTION_LOCATION);
2434 this->distribution_pt()->communicator_pt()->mpi_comm());
2453 this->distribution_pt()->communicator_pt()->mpi_comm());
2457 throw OomphLibError(
"The matrix factors have not been stored",
2458 OOMPH_CURRENT_FUNCTION,
2459 OOMPH_EXCEPTION_LOCATION);
2465 std::ostringstream error_msg;
2466 error_msg <<
"SuperLU returned the error status code " <<
Dist_info
2467 <<
" . See the SuperLU documentation for what this means.";
2469 error_msg.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
2475 const_cast<DoubleVector&
>(rhs).redistribute(&rhs_distribution);
2487 std::ostringstream error_message_stream;
2490 error_message_stream <<
"This function hasn't been implemented yet. If you "
2491 <<
"need it, implement it!" << std::endl;
2495 OOMPH_CURRENT_FUNCTION,
2496 OOMPH_EXCEPTION_LOCATION);
2513 std::ostringstream error_message_stream;
2514 error_message_stream <<
"The rhs vector distribution must be setup.";
2516 OOMPH_CURRENT_FUNCTION,
2517 OOMPH_EXCEPTION_LOCATION);
2523 "RHS does not have the same dimension as the linear system",
2524 OOMPH_CURRENT_FUNCTION,
2525 OOMPH_EXCEPTION_LOCATION);
2530 std::ostringstream error_message_stream;
2531 error_message_stream <<
"The rhs vector must not be distributed.";
2533 OOMPH_CURRENT_FUNCTION,
2534 OOMPH_EXCEPTION_LOCATION);
2542 std::ostringstream error_message_stream;
2543 error_message_stream <<
"If the result distribution is setup then it "
2544 "must be the same as the "
2545 <<
"rhs distribution";
2547 OOMPH_CURRENT_FUNCTION,
2548 OOMPH_EXCEPTION_LOCATION);
2582 std::ostringstream error_msg;
2583 error_msg <<
"SuperLU returned the error status code " <<
Serial_info
2584 <<
" . See the SuperLU documentation for what this means.";
2586 error_msg.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
2603 std::ostringstream error_message_stream;
2604 error_message_stream <<
"The rhs vector distribution must be setup.";
2606 OOMPH_CURRENT_FUNCTION,
2607 OOMPH_EXCEPTION_LOCATION);
2613 "RHS does not have the same dimension as the linear system",
2614 OOMPH_CURRENT_FUNCTION,
2615 OOMPH_EXCEPTION_LOCATION);
2620 std::ostringstream error_message_stream;
2621 error_message_stream <<
"The rhs vector must not be distributed.";
2623 OOMPH_CURRENT_FUNCTION,
2624 OOMPH_EXCEPTION_LOCATION);
2632 std::ostringstream error_message_stream;
2633 error_message_stream <<
"If the result distribution is setup then it "
2634 "must be the same as the "
2635 <<
"rhs distribution";
2637 OOMPH_CURRENT_FUNCTION,
2638 OOMPH_EXCEPTION_LOCATION);
2672 std::ostringstream error_msg;
2673 error_msg <<
"SuperLU returned the error status code " <<
Serial_info
2674 <<
" . See the SuperLU documentation for what this means.";
2676 error_msg.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
//////////////////////////////////////////////////////////////// ////////////////////////////////////...
void multiply_transpose(const DoubleVector &x, DoubleVector &soln) const
Multiply the transposed matrix by the vector x: soln=A^T x.
unsigned long nrow() const
Return the number of rows of the matrix.
int * column_start()
Access to C-style column_start array.
int * row_index()
Access to C-style row index array.
void clean_up_memory()
Wipe matrix data and set all values to 0.
A class for compressed row matrices. This is a distributable object.
int * row_start()
Access to C-style row_start array.
void multiply_transpose(const DoubleVector &x, DoubleVector &soln) const
Multiply the transposed matrix by the vector x: soln=A^T x.
int * column_index()
Access to C-style column index array.
unsigned long nnz() const
Return the number of nonzero entries (the local nnz)
bool built() const
access function to the Built flag - indicates whether the matrix has been build - i....
double * value()
Access to C-style value array.
unsigned long nrow() const
Return the number of rows of the matrix.
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 build(const DoubleVector &old_vector)
Just copys the argument DoubleVector.
void redistribute(const LinearAlgebraDistribution *const &dist_pt)
The contents of the vector are redistributed to match the new distribution. In a non-MPI rebuild this...
double * values_pt()
access function to the underlying values
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...
Describes the distribution of a distributable linear algebra type object. Typically this is a contain...
bool distributed() const
access function to the distributed - indicates whether the distribution is serial or distributed
OomphCommunicator * communicator_pt() const
const access to the communicator pointer
bool built() const
if the communicator_pt is null then the distribution is not setup then false is returned,...
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 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....
////////////////////////////////////////////////////////////////// //////////////////////////////////...
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,...
T * value()
Access to C-style value array.
unsigned long nnz() const
Return the number of nonzero entries.
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.
void start(const unsigned &i)
(Re-)start i-th timer
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...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
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)