Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Saves committed May 24, 2024
2 parents 9777199 + e7829ce commit 87e31f3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
8 changes: 4 additions & 4 deletions smt/src/rmts/rmtc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ void RMTC::compute_uniq2elem(double * data, int * rows, int * cols) {
}

void RMTC::compute_full_from_block(double * mtx, double * data, int * rows, int * cols){
int inz = 0;
long inz = 0;

for (int ielem = 0; ielem < nelem; ielem++) {
for (int iterm1 = 0; iterm1 < nterm; iterm1++) {
for (int iterm2 = 0; iterm2 < nterm; iterm2++) {
for (long ielem = 0; ielem < nelem; ielem++) {
for (long iterm1 = 0; iterm1 < nterm; iterm1++) {
for (long iterm2 = 0; iterm2 < nterm; iterm2++) {
data[inz] = mtx[iterm1 * nterm + iterm2];
rows[inz] = ielem * nterm + iterm1;
cols[inz] = ielem * nterm + iterm2;
Expand Down
2 changes: 1 addition & 1 deletion smt/src/rmts/rmtc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RMTC : public RMTS {
void find_interval(int ix, int num, double x, int * index, double * xbar);
int * nelem_list;
int * nterm_list;
int nelem, nterm;
long nelem, nterm;
};

#endif
26 changes: 23 additions & 3 deletions smt/utils/linear_solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,24 +264,44 @@ def _setup(self, mtx, printer, mg_matrices=[]):
self.callback_func = self.callback._print_sol
self.solver_kwargs = {
"atol": 0.0,
"tol": self.options["atol"],
"rtol": self.options["rtol"],
"maxiter": self.options["ilimit"],
}
elif self.options["solver"] == "bicgstab":
self.solver = scipy.sparse.linalg.bicgstab
self.callback_func = self.callback._print_sol
self.solver_kwargs = {
"tol": self.options["atol"],
"rtol": self.options["rtol"],
"maxiter": self.options["ilimit"],
}
elif self.options["solver"] == "gmres":
self.solver = scipy.sparse.linalg.gmres
self.callback_func = self.callback._print_res
self.solver_kwargs = {
"tol": self.options["atol"],
"rtol": self.options["rtol"],
"maxiter": self.options["ilimit"],
"restart": min(self.options["ilimit"], mtx.shape[0]),
}
self._patch_when_scipy_lessthan_v111()

def _patch_when_scipy_lessthan_v111(self):
"""
From scipy 1.11.0 release notes
The tol argument of scipy.sparse.linalg.{bcg,bicstab,cg,cgs,gcrotmk,gmres,lgmres,minres,qmr,tfqmr}
is now deprecated in favour of rtol and will be removed in SciPy 1.14.
Furthermore, the default value of atol for these functions is due to change to 0.0 in SciPy 1.14.
"""
import scipy

scipy_version = scipy.__version__
version_tuple = tuple(map(int, scipy_version.split(".")))
is_greater_than_1_11 = version_tuple[0] > 1 or (
version_tuple[0] == 1 and version_tuple[1] >= 11
)

if not is_greater_than_1_11:
self.solver_kwargs["tol"] = self.solver_kwargs["rtol"]
del self.solver_kwargs["rtol"]

def _solve(self, rhs, sol=None, ind_y=0):
with self._active(self.options["print_solve"]) as printer:
Expand Down

0 comments on commit 87e31f3

Please sign in to comment.