Skip to content

Commit fbd4a5f

Browse files
Lutz Grossclaude
andcommitted
Fix silent convergence failure in Belos solvers and update installation docs
- Throw TrilinosAdapterException when Belos iterative solver does not converge, instead of silently returning the (zero) initial guess. Fixes incorrect solutions being returned without any error (issue seen with GMRES+Jacobi on complex single PDEs). - Fix installation.rst to reflect that all default options files build with MPI enabled: MPI packages are now listed as required (not optional), and a note explains how to use the *_nompi_options.py files for MPI-free builds. Fixes issue #129 (libparmetis-dev missing from Ubuntu 24.04 base install instructions). Also corrects wrong options file names for Arch, Fedora, OpenSUSE, and RHEL. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 851ea0c commit fbd4a5f

3 files changed

Lines changed: 72 additions & 62 deletions

File tree

doc/sphinx_api/installation.rst

Lines changed: 66 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,17 @@ Platform-Specific Instructions
175175
Debian 12+
176176
----------
177177

178-
Install required packages:
178+
The default options file (``debian_options.py``) builds with MPI enabled.
179+
Install all required packages:
179180

180181
.. code-block:: bash
181182
182183
sudo apt-get install python3-dev python3-numpy python3-scipy python3-matplotlib
183184
sudo apt-get install g++ gfortran scons cmake
184185
sudo apt-get install libboost-numpy-dev libboost-python-dev libboost-random-dev libboost-iostreams-dev
185186
sudo apt-get install libhdf5-serial-dev libsilo-dev libnetcdf-dev libsuitesparse-dev liblapacke-dev libmumps-seq-dev zlib1g-dev
186-
187-
For MPI support, additionally install:
188-
189-
.. code-block:: bash
190-
191-
sudo apt-get install python3-mpi4py libparmetis-dev
187+
sudo apt-get install libmetis-dev libparmetis-dev
188+
sudo apt-get install libopenmpi-dev openmpi-bin python3-mpi4py
192189
193190
For building documentation, additionally install:
194191

@@ -209,24 +206,25 @@ Build esys-escript:
209206
210207
scons -j4 options_file=scons/templates/debian_options.py
211208
209+
To build **without MPI**, use ``debian_nompi_options.py`` instead and
210+
``libopenmpi-dev``, ``openmpi-bin``, ``python3-mpi4py``, and ``libparmetis-dev``
211+
can be omitted.
212+
212213

213214
Ubuntu 24.04+
214215
-------------
215216

216-
Install required packages:
217+
The default options file (``ubuntu_options.py``) builds with MPI enabled.
218+
Install all required packages:
217219

218220
.. code-block:: bash
219221
220222
sudo apt-get install python3-dev python3-numpy python3-scipy python3-matplotlib
221223
sudo apt-get install g++ gfortran scons cmake
222224
sudo apt-get install libboost-numpy-dev libboost-python-dev libboost-random-dev libboost-iostreams-dev
223225
sudo apt-get install libhdf5-serial-dev libsilo-dev libnetcdf-dev libsuitesparse-dev liblapacke-dev libmumps-seq-dev zlib1g-dev
224-
225-
For MPI support, additionally install:
226-
227-
.. code-block:: bash
228-
229-
sudo apt-get install python3-mpi4py libparmetis-dev
226+
sudo apt-get install libmetis-dev libparmetis-dev
227+
sudo apt-get install libopenmpi-dev openmpi-bin python3-mpi4py
230228
231229
For building documentation, additionally install:
232230

@@ -247,6 +245,10 @@ Build esys-escript:
247245
248246
scons -j4 options_file=scons/templates/ubuntu_options.py
249247
248+
To build **without MPI**, use ``debian_nompi_options.py`` instead and
249+
``libopenmpi-dev``, ``openmpi-bin``, ``python3-mpi4py``, and ``libparmetis-dev``
250+
can be omitted.
251+
250252

251253
Linux Mint 20.3+
252254
----------------
@@ -257,19 +259,15 @@ Mint Linux is based on Ubuntu, use the same commands as Ubuntu above.
257259
Arch Linux
258260
----------
259261

260-
Install required packages:
262+
The default options file (``arch_options.py``) builds with MPI enabled.
263+
Install all required packages:
261264

262265
.. code-block:: bash
263266
264267
sudo pacman -Sy python python-numpy python-scipy python-matplotlib
265268
sudo pacman -Sy gcc scons cmake
266-
sudo pacman -Sy boost boost-libs suitesparse hdf5 netcdf lapack mumps zlib
267-
268-
For MPI support:
269-
270-
.. code-block:: bash
271-
272-
sudo pacman -Sy python-mpi4py parmetis
269+
sudo pacman -Sy boost boost-libs suitesparse hdf5 netcdf lapack mumps zlib metis
270+
sudo pacman -Sy openmpi python-mpi4py
273271
274272
For building documentation:
275273

@@ -288,26 +286,29 @@ Build esys-escript:
288286

289287
.. code-block:: bash
290288
291-
scons -j4 options_file=scons/templates/arch_py3_options.py
289+
scons -j4 options_file=scons/templates/arch_options.py
290+
291+
To build **without MPI**, use ``arch_nompi_options.py`` instead and
292+
``openmpi`` and ``python-mpi4py`` can be omitted.
292293

293294

294295
Fedora
295296
------
296297

297-
Install required packages:
298+
The default options file (``fedora_options.py``) builds with MPI enabled.
299+
Install all required packages:
298300

299301
.. code-block:: bash
300302
301303
sudo dnf install python3-devel python3-numpy python3-scipy python3-matplotlib
302304
sudo dnf install gcc-c++ gcc-gfortran scons cmake
303305
sudo dnf install boost-devel boost-python3-devel boost-python3 boost-numpy3 boost-iostreams boost-random
304-
sudo dnf install hdf5-devel netcdf-devel suitesparse-devel lapack-devel MUMPS-devel zlib-devel
305-
306-
For MPI support:
306+
sudo dnf install hdf5-devel netcdf-devel suitesparse-devel lapack-devel MUMPS-devel zlib-devel metis-devel
307+
sudo dnf install openmpi-devel python3-mpi4py-openmpi
307308
308-
.. code-block:: bash
309-
310-
sudo dnf install python3-mpi4py parmetis-devel
309+
.. note::
310+
On Fedora, activate the MPI environment before building:
311+
``module load mpi/openmpi-x86_64``
311312

312313
For building documentation:
313314

@@ -326,26 +327,25 @@ Build esys-escript:
326327

327328
.. code-block:: bash
328329
329-
scons -j4 options_file=scons/templates/fedora_py3_options.py
330+
scons -j4 options_file=scons/templates/fedora_options.py
331+
332+
To build **without MPI**, use ``fedora_nompi_options.py`` instead and
333+
``openmpi-devel`` and ``python3-mpi4py-openmpi`` can be omitted.
330334

331335

332336
OpenSUSE
333337
--------
334338

335-
Install required packages:
339+
The default options file (``opensuse_options.py``) builds with MPI enabled.
340+
Install all required packages:
336341

337342
.. code-block:: bash
338343
339344
sudo zypper in python3-devel python3-numpy python3-scipy python3-matplotlib
340345
sudo zypper in gcc gcc-c++ gcc-fortran scons cmake
341346
sudo zypper in libboost_python3-devel libboost_numpy3-devel libboost_random-devel libboost_iostreams-devel
342-
sudo zypper in hdf5-devel netcdf-devel suitesparse-devel lapack-devel mumps-devel zlib-devel
343-
344-
For MPI support:
345-
346-
.. code-block:: bash
347-
348-
sudo zypper in python3-mpi4py parmetis-devel
347+
sudo zypper in hdf5-devel netcdf-devel suitesparse-devel lapack-devel mumps-devel zlib-devel metis-devel
348+
sudo zypper in openmpi-devel python3-mpi4py
349349
350350
For building documentation:
351351

@@ -364,33 +364,37 @@ Build esys-escript:
364364

365365
.. code-block:: bash
366366
367-
scons -j4 options_file=scons/templates/opensuse_py3_options.py
367+
scons -j4 options_file=scons/templates/opensuse_options.py
368+
369+
To build **without MPI**, use ``opensuse_nompi_options.py`` instead and
370+
``openmpi-devel`` and ``python3-mpi4py`` can be omitted.
368371

369372

370373
CentOS 8 / Rocky Linux / AlmaLinux
371374
----------------------------------
372375

376+
The default options file (``rhel_options.py``) builds with MPI enabled.
377+
373378
Enable required repositories:
374379

375380
.. code-block:: bash
376381
377382
sudo dnf install epel-release
378383
sudo dnf config-manager --set-enabled powertools
379384
380-
Install required packages:
385+
Install all required packages:
381386

382387
.. code-block:: bash
383388
384389
sudo dnf install python3-devel python3-numpy python3-scipy python3-matplotlib
385390
sudo dnf install gcc gcc-c++ gcc-gfortran scons cmake
386391
sudo dnf install boost-devel boost-python3 boost-python3-devel
387-
sudo dnf install hdf5-devel netcdf-devel suitesparse suitesparse-devel lapack-devel MUMPS-devel zlib-devel
388-
389-
For MPI support:
392+
sudo dnf install hdf5-devel netcdf-devel suitesparse suitesparse-devel lapack-devel MUMPS-devel zlib-devel metis-devel
393+
sudo dnf install openmpi-devel python3-mpi4py-openmpi
390394
391-
.. code-block:: bash
392-
393-
sudo dnf install python3-mpi4py parmetis-devel
395+
.. note::
396+
On RHEL-based systems, activate the MPI environment before building:
397+
``module load mpi/openmpi-x86_64``
394398

395399
For building documentation:
396400

@@ -409,7 +413,10 @@ Build esys-escript:
409413

410414
.. code-block:: bash
411415
412-
scons -j4 options_file=scons/templates/centos8_options.py
416+
scons -j4 options_file=scons/templates/rhel_options.py
417+
418+
To build **without MPI**, use ``rhel_nompi_options.py`` instead and
419+
``openmpi-devel`` and ``python3-mpi4py-openmpi`` can be omitted.
413420

414421

415422
macOS with Homebrew
@@ -419,27 +426,22 @@ macOS with Homebrew
419426

420427
macOS support is limited. Requires Xcode Command Line Tools.
421428

429+
The default options file (``homebrew_options.py``) builds with MPI enabled.
422430
Install Homebrew from https://brew.sh, then:
423431

424432
.. code-block:: bash
425433
426434
brew install python3 numpy scipy matplotlib
427435
brew install scons cmake
428436
brew install boost boost-python3
429-
brew install hdf5 netcdf suite-sparse lapack mumps
437+
brew install hdf5 netcdf suite-sparse lapack mumps metis
438+
brew install open-mpi
430439
431440
Some Python packages may need pip:
432441

433442
.. code-block:: bash
434443
435-
pip3 install numpy scipy matplotlib
436-
437-
For MPI support:
438-
439-
.. code-block:: bash
440-
441-
brew install open-mpi
442-
pip3 install mpi4py
444+
pip3 install numpy scipy matplotlib mpi4py
443445
444446
For building documentation:
445447

@@ -460,6 +462,9 @@ Build esys-escript:
460462
461463
scons -j4 options_file=scons/templates/homebrew_options.py
462464
465+
To build **without MPI**, use ``homebrew_nompi_options.py`` instead and
466+
``open-mpi`` and ``mpi4py`` can be omitted.
467+
463468

464469
macOS with MacPorts
465470
-------------------
@@ -468,6 +473,7 @@ macOS with MacPorts
468473

469474
macOS support is limited. Requires Xcode Command Line Tools.
470475

476+
The default options file (``macports_options.py``) builds with MPI enabled.
471477
Install MacPorts from https://www.macports.org, then:
472478

473479
.. code-block:: bash
@@ -477,11 +483,6 @@ Install MacPorts from https://www.macports.org, then:
477483
sudo port select --set python3 python311
478484
sudo port install py311-numpy py311-scipy py311-matplotlib
479485
sudo port install scons cmake boost hdf5 netcdf suitesparse lapack mumps
480-
481-
For MPI support:
482-
483-
.. code-block:: bash
484-
485486
sudo port install openmpi py311-mpi4py
486487
487488
For building documentation:
@@ -503,6 +504,9 @@ Build esys-escript:
503504
504505
scons -j4 options_file=scons/templates/macports_options.py
505506
507+
To build **without MPI**, use ``macports_nompi_options.py`` instead and
508+
``openmpi`` and ``py311-mpi4py`` can be omitted.
509+
506510
507511
FreeBSD
508512
-------

trilinoswrap/src/BlockCrsMatrixWrapper.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ void BlockCrsMatrixWrapper<ST>::solve(const Teuchos::ArrayView<ST>& x,
202202
"tolerance of " << sb.getTolerance() << "." << std::endl;
203203
}
204204
}
205+
if (result != Belos::Converged) {
206+
throw TrilinosAdapterException("Belos iterative solver did not converge.");
207+
}
205208
double solverTime = 0.;
206209
for (auto t: problem->getTimers()) {
207210
solverTime += t->totalElapsedTime();

trilinoswrap/src/CrsMatrixWrapper.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ void CrsMatrixWrapper<ST>::solve(const Teuchos::ArrayView<ST>& x,
221221
"tolerance of " << sb.getTolerance() << "." << std::endl;
222222
}
223223
}
224+
if (result != Belos::Converged) {
225+
throw TrilinosAdapterException("Belos iterative solver did not converge.");
226+
}
224227
double solverTime = 0.;
225228
for (auto t: problem->getTimers()) {
226229
solverTime += t->totalElapsedTime();

0 commit comments

Comments
 (0)