From 01cc4d0548d5591de899cb3a0f8240ee125886f8 Mon Sep 17 00:00:00 2001 From: Jonathan Guyer Date: Fri, 16 Feb 2024 14:19:35 -0500 Subject: [PATCH 1/3] Fix explanation for no-flux steady-state failure --- examples/diffusion/mesh1D.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/examples/diffusion/mesh1D.py b/examples/diffusion/mesh1D.py index a9f8e71a4f..a52e36b34a 100755 --- a/examples/diffusion/mesh1D.py +++ b/examples/diffusion/mesh1D.py @@ -720,24 +720,30 @@ and solve the steady-state problem ->>> DiffusionTerm(coeff=D).solve(var=phi) #doctest: +PYSPARSE_SOLVER +>>> try: +... DiffusionTerm(coeff=D).solve(var=phi) +... except: +... pass >>> if __name__ == '__main__': ... viewer.plot() >>> from fipy import input >>> if __name__ == '__main__': -... input("No-flux - stead-state failure. \ +... input("No-flux - steady-state failure. \ ... Press to proceed...") ->>> print(numerix.allclose(phi, 0.0)) #doctest: +PYSPARSE_SOLVER -True +>>> print(numerix.allclose(phi, 0.2, atol=1e-5)) +False + +>>> print(phi) .. image:: /figures/examples/diffusion/mesh1D-noflux_steady_fail.* :width: 90% :align: center :alt: (failed) steady-state solution for no-flux boundary conditions -we find that the value is uniformly zero! What happened to our no-flux boundary -conditions? +Depending on the solver, we find that the value may be uniformly zero, +infinity, or NaN, or the solver may just fail! +What happened to our no-flux boundary conditions? The problem is that in the implicit discretization of :math:`\nabla\cdot(D\nabla\phi) = 0`, From d6c792c7c5e3bfc691d7bd4c84ab1533466d581b Mon Sep 17 00:00:00 2001 From: Jonathan Guyer Date: Wed, 21 Feb 2024 19:43:35 -0500 Subject: [PATCH 2/3] Remove stray diagnostic --- examples/diffusion/mesh1D.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/diffusion/mesh1D.py b/examples/diffusion/mesh1D.py index a52e36b34a..cc5adac08a 100755 --- a/examples/diffusion/mesh1D.py +++ b/examples/diffusion/mesh1D.py @@ -734,8 +734,6 @@ >>> print(numerix.allclose(phi, 0.2, atol=1e-5)) False ->>> print(phi) - .. image:: /figures/examples/diffusion/mesh1D-noflux_steady_fail.* :width: 90% :align: center From 65980c4ecc102ab49d364a4b37c0f8bfa745bc49 Mon Sep 17 00:00:00 2001 From: Jonathan Guyer Date: Wed, 21 Feb 2024 21:32:54 -0500 Subject: [PATCH 3/3] Skip test on Trilinos Trilinos actually manages to get the correct answer somehow --- examples/diffusion/mesh1D.py | 4 +++- fipy/solvers/__init__.py | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/diffusion/mesh1D.py b/examples/diffusion/mesh1D.py index cc5adac08a..6c64b8a65d 100755 --- a/examples/diffusion/mesh1D.py +++ b/examples/diffusion/mesh1D.py @@ -731,7 +731,7 @@ ... input("No-flux - steady-state failure. \ ... Press to proceed...") ->>> print(numerix.allclose(phi, 0.2, atol=1e-5)) +>>> print(numerix.allclose(phi, 0.2, atol=1e-5)) # doctest: +NOT_TRILINOS_SOLVER False .. image:: /figures/examples/diffusion/mesh1D-noflux_steady_fail.* @@ -742,6 +742,8 @@ Depending on the solver, we find that the value may be uniformly zero, infinity, or NaN, or the solver may just fail! What happened to our no-flux boundary conditions? +Trilinos actually manages to get the correct solution, but this should not +be relied on; this problem has an infinite number of solutions. The problem is that in the implicit discretization of :math:`\nabla\cdot(D\nabla\phi) = 0`, diff --git a/fipy/solvers/__init__.py b/fipy/solvers/__init__.py index 01180b9267..613e68b9ec 100644 --- a/fipy/solvers/__init__.py +++ b/fipy/solvers/__init__.py @@ -190,6 +190,12 @@ def _import_mesh_matrices(suite): test=lambda: solver_suite != 'pyamgx', why="the PyAMGX solver is being used.", skipWarning=True) + +register_skipper(flag='NOT_TRILINOS_SOLVER', + test=lambda: solver_suite not in ['trilinos', 'no-pysparse'], + why="the Trilinos solvers are being used.", + skipWarning=True) + del register_skipper _log.info("Solver suite is %s", solver_suite)