BOUT-dev icon indicating copy to clipboard operation
BOUT-dev copied to clipboard

Eliminate boundary equations to improve HYPRE solves

Open rfalgout opened this issue 8 months ago • 1 comments

This PR adds code to eliminate boundary equations to get better behavior in HYPRE solvers.

This is not fully tested yet and likely requires some reorganization and cleaning up.

rfalgout avatar Mar 05 '25 01:03 rfalgout

Hi @bendudson . I needed the rhs vector in the routine that updates the solution values https://github.com/boutproject/BOUT-dev/blob/5ce6cae6ea94a76417a4c058fdd848db384d36d1/src/invert/laplace/impls/hypre3d/hypre_boundary.c#L211 I couldn't figure out a nice way to do that so I added the following member function to the HypreVector class https://github.com/boutproject/BOUT-dev/blob/5ce6cae6ea94a76417a4c058fdd848db384d36d1/include/bout/hypre_interface.hxx#L241 If you have better ideas for passing the information around, please let me know.

Also, I've made a number of assumptions about the structure of the boundary equations relative to internal equations. See the comments at the top of the file in the first link above. One thing I don't think I mention in this file is the assumption that internal equations that couple to a boundary equation are assumed to live on the same processor as that boundary equation.

rfalgout avatar Mar 05 '25 01:03 rfalgout

Unfortunately this PR has broken some of the Hypre tests:

The integrated test test-laplace3d-hypre:

Making Laplace 3D with Hypre
running on 1 processors: ./test-laplace3d -d data_slab_core
 => data_slab_core passed with maximum error 6.382497419465949e-09
running on 1 processors: ./test-laplace3d -d data_slab_sol
 => data_slab_sol passed with maximum error 2.7718056405667824e-08
running on 1 processors: ./test-laplace3d -d data_circular_core
 => data_circular_core passed with maximum error 1.478270839072593e-10
running on 1 processors: ./test-laplace3d -d data_circular_core-sol
 => data_circular_core-sol failed with maximum error 0.00034150972873735197
=> Some tests failed

And the unit test (just showing the first few points, because it's very noisy):

/home/runner/work/BOUT-dev/BOUT-dev/tests/unit/invert/laplace/test_laplace_hypre3d.cxx:165: Failure
The difference between expected[i] and actual[i] is 2.880420150274329e-06, which exceeds tol, where
expected[i] evaluates to 2.4848271042405023e-06,
actual[i] evaluates to -3.9559304603382663e-07, and
tol evaluates to 1e-08.

/home/runner/work/BOUT-dev/BOUT-dev/tests/unit/invert/laplace/test_laplace_hypre3d.cxx:165: Failure
The difference between expected[i] and actual[i] is 0.025529941378404492, which exceeds tol, where
expected[i] evaluates to 0.021339352519864602,
actual[i] evaluates to -0.0041905888585398914, and
tol evaluates to 1e-08.

/home/runner/work/BOUT-dev/BOUT-dev/tests/unit/invert/laplace/test_laplace_hypre3d.cxx:165: Failure
The difference between expected[i] and actual[i] is 2.2593733713480629e-05, which exceeds tol, where
expected[i] evaluates to 2.0087612157650606e-05,
actual[i] evaluates to -2.5061215558300253e-06, and
tol evaluates to 1e-08.

/home/runner/work/BOUT-dev/BOUT-dev/tests/unit/invert/laplace/test_laplace_hypre3d.cxx:165: Failure
The difference between expected[i] and actual[i] is 0.42204141661955613, which exceeds tol, where
expected[i] evaluates to 0.38156718593235334,
actual[i] evaluates to -0.040474230687202815, and
tol evaluates to 1e-08.

/home/runner/work/BOUT-dev/BOUT-dev/tests/unit/invert/laplace/test_laplace_hypre3d.cxx:165: Failure
The difference between expected[i] and actual[i] is 3.0573430513351925, which exceeds tol, where
expected[i] evaluates to 2.9010150915766806,
actual[i] evaluates to -0.15632795975851177, and
tol evaluates to 1e-08.

This is in the first test TEST_P(LaplaceHypre3dTest, TestMatrixConstruction3D), and then gtest crashes completely.

@rfalgout This test compares the inverse to the forward solution. It's possible our forward operator in the test has some issues at the boundaries

@bendudson It might be wise to back out these changes until we get this sorted?

ZedThree avatar Jun 24 '25 14:06 ZedThree