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;
1246 <<
"\n - Memory used to store the Jacobian (MB): "
1247 << memory_usage_for_jacobian / 1.0e+06
1248 <<
"\n - Memory used to store the LU factors (MB): "
1249 << memory_usage_for_lu_storage / 1.0e+06
1250 <<
"\n - Total memory used for matrix storage (MB): "
1251 << total_memory_usage / 1.0e+06 <<
"\n"
1267 double backsub_time = t_backsub_end - t_backsub_start;
1275 <<
"Time for LU factorisation : "
1277 <<
"\nTime for back-substitution: "
1279 <<
"\nTime for SuperLUSolver solve (ndof=" << matrix_pt->
nrow() <<
"): "
1303 #ifdef OOMPH_HAS_MPI
1313 unsigned n_dof = problem_pt->
ndof();
1344 oomph_info <<
"Time to set up CRDoubleMatrix Jacobian : "
1357 if ((result.
built()) &&
1390 oomph_info <<
"Time to set up CR Jacobian : "
1407 result.
build(&dist, 0.0);
1461 <<
"Time to set up CRDoubleMatrix Jacobian: "
1473 if ((result.
built()) &&
1515 oomph_info <<
"\nTime to set up CCDoubleMatrix Jacobian: "
1527 if ((result.
built()) &&
1572 std::ostringstream error_message_stream;
1573 error_message_stream <<
"The vectors rhs must be setup";
1575 OOMPH_CURRENT_FUNCTION,
1576 OOMPH_EXCEPTION_LOCATION);
1580 if (matrix_pt->
nrow() != matrix_pt->
ncol())
1582 std::ostringstream error_message_stream;
1583 error_message_stream <<
"The matrix at matrix_pt must be square.";
1585 OOMPH_CURRENT_FUNCTION,
1586 OOMPH_EXCEPTION_LOCATION);
1595 if (cr_pt->
nnz() == 0)
1597 std::ostringstream error_message_stream;
1598 error_message_stream
1599 <<
"Attempted to call SuperLu on a CRDoubleMatrix with no entries, "
1600 <<
"SuperLU would segfault (because the values array pt is "
1601 <<
"uninitialised or null).";
1603 OOMPH_CURRENT_FUNCTION,
1604 OOMPH_EXCEPTION_LOCATION);
1609 if (matrix_pt->
nrow() != rhs.
nrow())
1611 std::ostringstream error_message_stream;
1612 error_message_stream
1613 <<
"The matrix and the rhs vector must have the same number of rows.";
1615 OOMPH_CURRENT_FUNCTION,
1616 OOMPH_EXCEPTION_LOCATION);
1623 if (dist_matrix_pt != 0)
1627 std::ostringstream error_message_stream;
1628 error_message_stream
1629 <<
"The matrix matrix_pt must have the same distribution as the "
1632 OOMPH_CURRENT_FUNCTION,
1633 OOMPH_EXCEPTION_LOCATION);
1642 std::ostringstream error_message_stream;
1643 error_message_stream
1644 <<
"The matrix (matrix_pt) is not distributable and therefore the rhs"
1645 <<
" vector must not be distributed";
1647 OOMPH_CURRENT_FUNCTION,
1648 OOMPH_EXCEPTION_LOCATION);
1657 std::ostringstream error_message_stream;
1658 error_message_stream
1659 <<
"The result vector distribution has been setup; it must have the "
1660 <<
"same distribution as the rhs vector.";
1662 OOMPH_CURRENT_FUNCTION,
1663 OOMPH_EXCEPTION_LOCATION);
1692 double factorise_time = t_factorise_end - t_factorise_start;
1702 if (cr_pt->
nnz() != 0)
1705 unsigned n_row = cr_pt->
nrow();
1708 unsigned n_nnz = cr_pt->
nnz();
1711 double memory_usage_for_jacobian =
1712 ((2 * ((n_row + 1) *
sizeof(
int))) +
1713 (n_nnz * (
sizeof(int) +
sizeof(
double))));
1721 double total_memory_usage =
1722 memory_usage_for_jacobian + memory_usage_for_lu_storage;
1728 <<
"\n - Memory used to store the Jacobian (MB): "
1729 << memory_usage_for_jacobian / 1.0e+06
1730 <<
"\n - Memory used to store the LU factors (MB): "
1731 << memory_usage_for_lu_storage / 1.0e+06
1732 <<
"\n - Total memory used for matrix storage (MB): "
1733 << total_memory_usage / 1.0e+06 <<
"\n"
1749 double backsub_time = t_backsub_end - t_backsub_start;
1757 <<
"Time for LU factorisation : "
1759 <<
"\nTime for back-substitution: "
1761 <<
"\nTime for SuperLUSolver solve (ndof=" << matrix_pt->
nrow() <<
"): "
1789 oomph_info <<
"Time for SuperLUSolver solve (ndof=" << rhs.
nrow() <<
"): "
1814 oomph_info <<
"Time for SuperLUSolver solve (ndof=" << rhs.
nrow() <<
"): "
1834 #ifdef OOMPH_HAS_MPI
1838 if (dist_matrix_pt != 0)
1847 if (dist_matrix_pt != 0)
1866 #ifdef OOMPH_HAS_MPI
1876 int m = matrix_pt->
ncol();
1877 int n = matrix_pt->
nrow();
1880 std::ostringstream error_message_stream;
1881 error_message_stream <<
"Can only solve for square matrices\n"
1882 <<
"N, M " << n <<
" " << m << std::endl;
1885 OOMPH_CURRENT_FUNCTION,
1886 OOMPH_EXCEPTION_LOCATION);
1902 int nprow = int(sqrt(
double(nproc)));
1907 if (nproc % nprow == 0)
break;
1938 if (!cr_matrix_pt->
built())
1941 "To apply SuperLUSolver to a CRDoubleMatrix - it must be built",
1942 OOMPH_CURRENT_FUNCTION,
1943 OOMPH_EXCEPTION_LOCATION);
1951 const int nnz_local = int(cr_matrix_pt->
nnz());
1960 double* matrix_value_pt = cr_matrix_pt->
value();
1961 for (
int i = 0;
i < nnz_local;
i++)
1969 for (
int i = 0;
i < nnz_local;
i++)
1977 int* matrix_start_pt = cr_matrix_pt->
row_start();
1990 cr_matrix_pt->
clear();
2019 const int nnz = int(cr_matrix_pt->
nnz());
2033 cr_matrix_pt->
value(),
2043 cr_matrix_pt->
clear();
2076 const int nnz = int(serial_matrix_pt->
nnz());
2079 int ndof = int(serial_matrix_pt->
nrow());
2082 int ndof_local = ndof;
2091 double* matrix_value_pt = serial_matrix_pt->
value();
2092 for (
int i = 0;
i < nnz;
i++)
2099 int* matrix_index_pt = serial_matrix_pt->
row_index();
2100 for (
int i = 0;
i < nnz;
i++)
2107 int* matrix_start_pt = serial_matrix_pt->
column_start();
2108 for (
int i = 0;
i <= ndof_local;
i++)
2142 std::ostringstream error_message_stream;
2143 error_message_stream <<
"SuperLUSolver implemented only for "
2144 <<
" CCDoubleMatrix, CRDoubleMatrix\n"
2145 <<
"and DistributedCRDoubleMatrix matrices\n";
2147 OOMPH_CURRENT_FUNCTION,
2148 OOMPH_EXCEPTION_LOCATION);
2154 std::ostringstream error_msg;
2155 error_msg <<
"SuperLU returned the error status code " <<
Dist_info
2156 <<
" . See the SuperLU documentation for what this means.";
2158 error_msg.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
2178 std::ostringstream error_message_stream;
2179 error_message_stream <<
"The matrix must not be distributed.";
2181 OOMPH_CURRENT_FUNCTION,
2182 OOMPH_EXCEPTION_LOCATION);
2188 int n = matrix_pt->
nrow();
2192 int m = matrix_pt->
ncol();
2195 std::ostringstream error_message_stream;
2196 error_message_stream <<
"Can only solve for square matrices\n"
2197 <<
"N, M " << n <<
" " << m << std::endl;
2200 OOMPH_CURRENT_FUNCTION,
2201 OOMPH_EXCEPTION_LOCATION);
2208 int *index = 0, *
start = 0;
2231 nnz = CR_matrix_pt->
nnz();
2232 value = CR_matrix_pt->
value();
2246 nnz = CC_matrix_pt->
nnz();
2247 value = CC_matrix_pt->
value();
2254 throw OomphLibError(
"SuperLU only works with CR or CC Double matrices",
2255 OOMPH_CURRENT_FUNCTION,
2256 OOMPH_EXCEPTION_LOCATION);
2282 std::ostringstream error_msg;
2283 error_msg <<
"SuperLU returned the error status code " <<
Serial_info
2284 <<
" . See the SuperLU documentation for what this means.";
2286 error_msg.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
2301 #ifdef OOMPH_HAS_MPI
2322 #ifdef OOMPH_HAS_MPI
2334 #ifdef OOMPH_HAS_MPI
2354 std::ostringstream error_message_stream;
2355 error_message_stream <<
"The vectors rhs must be setup";
2357 OOMPH_CURRENT_FUNCTION,
2358 OOMPH_EXCEPTION_LOCATION);
2368 std::ostringstream warning_stream;
2369 warning_stream <<
"The distribution of rhs vector does not match that "
2371 warning_stream <<
"The rhs will be redistributed, which is likely to "
2374 <<
"To remove this warning you can either:\n"
2375 <<
" i) Ensure that the rhs vector has the correct distribution\n"
2376 <<
" before calling the resolve() function\n"
2377 <<
"or ii) Set the flag \n"
2378 <<
" SuperLUSolver::Suppress_incorrect_rhs_distribution_warning_in_"
2380 <<
" to be true\n\n";
2383 "SuperLUSolver::resolve()",
2384 OOMPH_EXCEPTION_LOCATION);
2399 std::ostringstream error_message_stream;
2400 error_message_stream
2401 <<
"The result vector distribution has been setup; it must have the "
2402 <<
"same distribution as the rhs vector.";
2404 OOMPH_CURRENT_FUNCTION,
2405 OOMPH_EXCEPTION_LOCATION);
2441 this->distribution_pt()->communicator_pt()->mpi_comm());
2460 this->distribution_pt()->communicator_pt()->mpi_comm());
2464 throw OomphLibError(
"The matrix factors have not been stored",
2465 OOMPH_CURRENT_FUNCTION,
2466 OOMPH_EXCEPTION_LOCATION);
2472 std::ostringstream error_msg;
2473 error_msg <<
"SuperLU returned the error status code " <<
Dist_info
2474 <<
" . See the SuperLU documentation for what this means.";
2476 error_msg.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
2482 const_cast<DoubleVector&
>(rhs).redistribute(&rhs_distribution);
2494 std::ostringstream error_message_stream;
2497 error_message_stream <<
"This function hasn't been implemented yet. If you "
2498 <<
"need it, implement it!" << std::endl;
2502 OOMPH_CURRENT_FUNCTION,
2503 OOMPH_EXCEPTION_LOCATION);
2520 std::ostringstream error_message_stream;
2521 error_message_stream <<
"The rhs vector distribution must be setup.";
2523 OOMPH_CURRENT_FUNCTION,
2524 OOMPH_EXCEPTION_LOCATION);
2530 "RHS does not have the same dimension as the linear system",
2531 OOMPH_CURRENT_FUNCTION,
2532 OOMPH_EXCEPTION_LOCATION);
2537 std::ostringstream error_message_stream;
2538 error_message_stream <<
"The rhs vector must not be distributed.";
2540 OOMPH_CURRENT_FUNCTION,
2541 OOMPH_EXCEPTION_LOCATION);
2549 std::ostringstream error_message_stream;
2550 error_message_stream <<
"If the result distribution is setup then it "
2551 "must be the same as the "
2552 <<
"rhs distribution";
2554 OOMPH_CURRENT_FUNCTION,
2555 OOMPH_EXCEPTION_LOCATION);
2589 std::ostringstream error_msg;
2590 error_msg <<
"SuperLU returned the error status code " <<
Serial_info
2591 <<
" . See the SuperLU documentation for what this means.";
2593 error_msg.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
2610 std::ostringstream error_message_stream;
2611 error_message_stream <<
"The rhs vector distribution must be setup.";
2613 OOMPH_CURRENT_FUNCTION,
2614 OOMPH_EXCEPTION_LOCATION);
2620 "RHS does not have the same dimension as the linear system",
2621 OOMPH_CURRENT_FUNCTION,
2622 OOMPH_EXCEPTION_LOCATION);
2627 std::ostringstream error_message_stream;
2628 error_message_stream <<
"The rhs vector must not be distributed.";
2630 OOMPH_CURRENT_FUNCTION,
2631 OOMPH_EXCEPTION_LOCATION);
2639 std::ostringstream error_message_stream;
2640 error_message_stream <<
"If the result distribution is setup then it "
2641 "must be the same as the "
2642 <<
"rhs distribution";
2644 OOMPH_CURRENT_FUNCTION,
2645 OOMPH_EXCEPTION_LOCATION);
2679 std::ostringstream error_msg;
2680 error_msg <<
"SuperLU returned the error status code " <<
Serial_info
2681 <<
" . See the SuperLU documentation for what this means.";
2683 error_msg.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
2717 #ifdef OOMPH_HAS_MPI
//////////////////////////////////////////////////////////////// ////////////////////////////////////...
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 * column_index()
Access to C-style column index array.
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.
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
LinearAlgebraDistribution * distribution_pt() const
access to the LinearAlgebraDistribution
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
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.
double * values_pt()
access function to the underlying values
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...
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.
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...
OomphCommunicator * communicator_pt()
access function to the oomph-lib communicator
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)