Skip to content

Commit

Permalink
mumps interface test
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbynum committed Feb 24, 2020
1 parent d64a94e commit 6c67c91
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
6 changes: 3 additions & 3 deletions pyomo/contrib/pynumero/linalg/mumps_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ def do_back_solve(self, rhs):
will be a BlockVector with the same block structure as rhs.
"""
if isinstance(rhs, BlockVector):
rhs = rhs.flatten()
result = rhs
_rhs = rhs.flatten()
result = _rhs
else:
result = rhs.copy()

Expand All @@ -138,7 +138,7 @@ def do_back_solve(self, rhs):

if isinstance(rhs, BlockVector):
_result = rhs.copy_structure()
_result.copy_from(result)
_result.copyfrom(result)
result = _result

return result
Expand Down
28 changes: 24 additions & 4 deletions pyomo/contrib/pynumero/linalg/tests/test_mumps_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,29 @@ def test_mumps_linear_solver(self):
self.assertTrue(np.allclose(x, x2))

solver = MumpsCentralizedAssembledLinearSolver(sym=2)
solver.do_symbolic_factorization(A_lower)
solver.do_numeric_factorization(A_lower)
x = solver.do_back_solve(b1)
x = solver.solve(A_lower, b1)
self.assertTrue(np.allclose(x, x1))
x = solver.do_back_solve(b2)

block_A = BlockMatrix(2, 2)
block_A.set_row_size(0, 2)
block_A.set_row_size(1, 1)
block_A.set_col_size(0, 2)
block_A.set_col_size(1, 1)
block_A.copyfrom(A)

block_b1 = BlockVector(2)
block_b1.set_block(0, b1[0:2])
block_b1.set_block(1, b1[2:])

block_b2 = BlockVector(2)
block_b2.set_block(0, b2[0:2])
block_b2.set_block(1, b2[2:])

solver = MumpsCentralizedAssembledLinearSolver(icntl_options={10: -3}, cntl_options={2: 1e-16})
solver.do_symbolic_factorization(block_A)
solver.do_numeric_factorization(block_A)
x = solver.do_back_solve(block_b1)
self.assertTrue(np.allclose(x, x1))
x = solver.do_back_solve(block_b2)
self.assertTrue(np.allclose(x, x2))
self.assertEqual(solver.get_infog(15), 3)

0 comments on commit 6c67c91

Please sign in to comment.