Skip to content

Commit 5ff6ea6

Browse files
authored
Merge pull request #266 from mfem/mfem_48_dev
MFEM 4.8 support
2 parents a1f8ff4 + e287778 commit 5ff6ea6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+3833
-1920
lines changed

.github/workflows/build-and-test-callable.yml

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ on:
4949
phases:
5050
description: 'When true, run each build step individually (mfem, swig, pymfem)'
5151
type: boolean
52-
default: true
52+
default: false
5353

5454
jobs:
5555
build-and-test:
@@ -67,11 +67,11 @@ jobs:
6767
CUDA_HOME: '/usr/local/cuda'
6868
# These are all passed to setup.py as one concatenated string
6969
build-flags: >-
70-
${{ inputs.parallel && '--with-parallel' || '' }}
71-
${{ inputs.cuda && '--with-cuda' || '' }}
72-
${{ inputs.libceed && '--with-libceed' || '' }}
73-
${{ inputs.gslib && '--with-gslib' || '' }}
74-
${{ (!(inputs.mfem-branch == 'default') && format('--mfem-branch=''{0}''', inputs.mfem-branch)) || '' }}
70+
${{ inputs.parallel && '-C"with-parallel=Yes"' || '' }}
71+
${{ inputs.cuda && '-C"with-cuda=Yes"' || '' }}
72+
${{ inputs.libceed && '-C"with-libceed=Yes"' || '' }}
73+
${{ inputs.gslib && '-C"with-gslib=Yes"' || '' }}
74+
${{ (!(inputs.mfem-branch == 'default') && format('-C"mfem-branch={0}"', inputs.mfem-branch)) || '' }}
7575
7676
# -------------------------------------------------------------------------------------------------
7777
# Begin workflow
@@ -89,14 +89,25 @@ jobs:
8989
# Download/install dependencies
9090
# -------------------------------------------------------------------------------------------------
9191
- name: Install core dependencies via requirements.txt
92-
run: pip install -r requirements.txt --verbose
92+
run: |
93+
pip install -U setuptools>=79.0.1
94+
pip install -U numpy>=2.0.0
95+
pip install -U cmake>=4.0.0
96+
pip install -U swig>=4.3
97+
98+
#- name: Install chrpath on ubuntu
99+
# if: inputs.os == 'ubuntu-latest'
100+
# run: |
101+
# sudo apt-get install chrpath
93102

94103
- name: Install MPI
95104
if: inputs.parallel
96105
run: |
97-
sudo apt-get install mpich libmpich-dev
106+
sudo apt-get install openmpi-bin libopenmpi-dev
107+
export OMPI_MCA_rmaps_base_oversubscribe=1
108+
# (broken?) sudo apt-get install mpich libmpich-dev
98109
pip install mpi4py
99-
110+
mpirun -np 2 python -c "from mpi4py import MPI;print(MPI.COMM_WORLD.rank)"
100111
101112
- name: Purge PIP chach
102113
run: pip cache purge
@@ -133,21 +144,26 @@ jobs:
133144
# -------------------------------------------------------------------------------------------------
134145
# Build MFEM + SWIG Bindings + PyMFEM
135146
# -------------------------------------------------------------------------------------------------
136-
- name: Build MFEM (step 1)
137-
if: inputs.phases
138-
run: python setup.py install --ext-only --vv ${{ env.build-flags }}
147+
# - name: Build MFEM (step 1)
148+
# if: inputs.phases
149+
# run: pip install -e . -C"--build-option=--ext-only" -C"--build-option=--vv" ${{ env.build-flags }}
150+
# run: python setup.py install --ext-only --vv ${{ env.build-flags }}
151+
152+
# - name: Build SWIG wrappers (step 2)
153+
# if: inputs.phases
154+
# run: python setup.py install --swig --vv ${{ env.build-flags }}
139155

140-
- name: Build SWIG wrappers (step 2)
141-
if: inputs.phases
142-
run: python setup.py install --swig --vv ${{ env.build-flags }}
156+
# - name: Build PyMFEM (step 3)
157+
# if: inputs.phases
158+
# run: python setup.py install --skip-ext --skip-swig --vv ${{ env.build-flags }}
143159

144-
- name: Build PyMFEM (step 3)
145-
if: inputs.phases
146-
run: python setup.py install --skip-ext --skip-swig --vv ${{ env.build-flags }}
160+
#- name: Build all (steps 1-3)
161+
# if: inputs.phases == false
162+
# run: pip install -e . -C"--build-option=--vv" ${{ env.build-flags }}
147163

148164
- name: Build all (steps 1-3)
149165
if: inputs.phases == false
150-
run: python setup.py install --vv ${{ env.build-flags }}
166+
run: pip install . ${{ env.build-flags }} --verbose
151167

152168
# -------------------------------------------------------------------------------------------------
153169
# Run tests

.github/workflows/build-and-test-dispatch.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
fail-fast: false
3131
matrix:
3232
mfem-branch: [master, default] # 'default' uses a specific commit hash defined in setup.py:repos_sha
33-
python-version: ['3.8', '3.9', '3.10', '3.11'] # 3.12 is not supported by scipy
33+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
3434
parallel: [false]
3535
name: test-linux | ${{ matrix.mfem-branch }} | ${{ matrix.python-version }} | ${{ matrix.parallel && 'parallel' || 'serial' }}
3636
uses: ./.github/workflows/build-and-test-callable.yml
@@ -46,7 +46,7 @@ jobs:
4646
fail-fast: false
4747
matrix:
4848
mfem-branch: [master, default] # 'default' uses a specific commit hash defined in setup.py:repos_sha
49-
python-version: ['3.9', '3.10', '3.11'] # 3.12 is not supported by scipy
49+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
5050
parallel: [true]
5151
name: test-linux | ${{ matrix.mfem-branch }} | ${{ matrix.python-version }} | ${{ matrix.parallel && 'parallel' || 'serial' }}
5252
uses: ./.github/workflows/build-and-test-callable.yml

.github/workflows/release_binary.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ jobs:
2222
echo "!!!!!: "$REF
2323
git checkout $REF
2424
#
25-
export PATH=/opt/python/cp37-cp37m/bin:$PATH
25+
export PATH=/opt/python/cp38-cp38/bin:$PATH
2626
27+
pip install -U packaging
2728
pip3 install wheel six auditwheel twine
2829
pip3 install urllib3==1.26.6 # use older version to avoid OpenSSL vesion issue
2930
pip3 install numpy==1.21.6
@@ -36,11 +37,11 @@ jobs:
3637
ls -l dist/
3738
#python3 -m twine upload --repository-url https://test.pypi.org/legacy/ --password ${{ secrets.TEST_PYPI_TOKEN }} --username __token__ --verbose dist/*
3839
python3 -m twine upload --password ${{ secrets.PYPI_TOKEN }} --username __token__ --verbose dist/*
39-
make_binary_3_8_9_10_11:
40+
make_binary_3_8_9_10_11_12:
4041
needs: make_sdist
4142
strategy:
4243
matrix:
43-
pythonpath: ["cp38-cp38", "cp39-cp39", "cp310-cp310", "cp311-cp311"]
44+
pythonpath: ["cp38-cp38", "cp39-cp39", "cp310-cp310", "cp311-cp311", "cp312-cp312"]
4445

4546
runs-on: ubuntu-latest
4647
container: quay.io/pypa/manylinux2014_x86_64
@@ -59,14 +60,17 @@ jobs:
5960
#
6061
ls -l /opt/python/
6162
export PATH=/opt/python/${{ matrix.pythonpath }}/bin:$PATH
63+
64+
pip install setuptools
65+
pip install -U packaging
6266
pip3 install auditwheel twine
6367
pip3 install urllib3==1.26.6 # use older version to avoid OpenSSL vesion issue
6468
6569
pip3 install -r requirements.txt
6670
6771
CWD=$PWD
6872
yum install -y zlib-devel
69-
yum install -y chrpath
73+
#yum install -y chrpath
7074
7175
mkdir dist
7276

.github/workflows/testrelease_binary.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ jobs:
2222
echo "!!!!!: "$REF
2323
git checkout $REF
2424
#
25-
export PATH=/opt/python/cp37-cp37m/bin:$PATH
25+
export PATH=/opt/python/cp38-cp38/bin:$PATH
2626
27+
pip install -U packaging
2728
pip3 install wheel six auditwheel twine
2829
pip3 install urllib3==1.26.6 # use older version to avoid OpenSSL vesion issue
2930
pip3 install numpy==1.21.6
@@ -35,12 +36,11 @@ jobs:
3536
python3 setup.py sdist
3637
ls -l dist/
3738
python3 -m twine upload --repository-url https://test.pypi.org/legacy/ --password ${{ secrets.TEST_PYPI_TOKEN }} --username __token__ --verbose dist/*
38-
#python3 -m twine upload --password ${{ secrets.PYPI_TOKEN }} --username __token__ --verbose dist/*
39-
make_binary_3_8_9_10_11:
39+
make_binary_3_8_9_10_11_12:
4040
needs: make_sdist
4141
strategy:
4242
matrix:
43-
pythonpath: ["cp38-cp38", "cp39-cp39", "cp310-cp310", "cp311-cp311"]
43+
pythonpath: ["cp38-cp38", "cp39-cp39", "cp310-cp310", "cp311-cp311", "cp312-cp312"]
4444

4545
runs-on: ubuntu-latest
4646
container: quay.io/pypa/manylinux2014_x86_64
@@ -60,14 +60,16 @@ jobs:
6060
ls -l /opt/python/
6161
export PATH=/opt/python/${{ matrix.pythonpath }}/bin:$PATH
6262
63+
pip install setuptools
64+
pip install -U packaging
6365
pip3 install auditwheel twine
6466
pip3 install urllib3==1.26.6 # use older version to avoid OpenSSL vesion issue
6567
6668
pip3 install -r requirements.txt
6769
6870
CWD=$PWD
6971
yum install -y zlib-devel
70-
yum install -y chrpath
72+
#yum install -y chrpath
7173
7274
mkdir dist
7375

INSTALL.md

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
# Installation Guide
22

3-
## Basic install
3+
## Basic serial install
44

5-
Most users will be fine using the binary bundled in the default `pip` install:
5+
Most users (on Linux and Mac) will be fine using the binary bundled in the default `pip` install:
66

77
```shell
88
pip install mfem
99
```
1010
The above installation will download and install a *serial* version of `MFEM`.
1111

12+
## Environmental variables
13+
Build script checks the following environmental variables
14+
- CC : c compiler for parallel build
15+
- CXX : c++ compiler for serial build
16+
- MPICC : c compiler for parallel build
17+
- MPICXX : c++ compiler for parallel build
18+
- CXX11FLAG : C++11 flag for C++ compiler
19+
- MPIINC : the location of MPI.h (if this variable is set, the parallle PyMFEM is build with CXX, not MPICXX)
20+
21+
1222
## Building from source
1323
PyMFEM has many options for installation, when building from source, including:
1424
- Serial and parallel (MPI) wrappers
@@ -19,15 +29,28 @@ PyMFEM has many options for installation, when building from source, including:
1929
- `libceed`
2030
- `metis`
2131

22-
Most of the options for PyMFEM can be used directly when installing via `python setup.py install`, e.g.
32+
Most of the options for PyMFEM can be used directly when installing via `pip install . or python setup.py install`, e.g.
2333
```shell
2434
git clone git@github:mfem/PyMFEM.git
2535
cd PyMFEM
36+
pip install . --user
37+
38+
or
39+
2640
python setup.py install --user
2741
```
28-
For example, parallel (MPI) support is built with the `--with-parallel` flag:
42+
43+
Note that `python setup.py install` is deprecated and will be removed soon in favor of `pip`.
44+
When installing via `pip`, options are specified using the `-C` flag using the syntax `-C"name=value"`; e.g. the `--with-parallel` option is now specified as `-C"with-parallel=Yes`.
45+
The name and value of each option should be written explicitly with a dedicated -C flag.
46+
47+
For example, parallel (MPI) support and GSlib support is built with `--with-parallel`
48+
and `--with-gslib' flags as follows.
49+
2950
```shell
30-
python setup.py install --with-parallel
51+
python setup.py install --with-parallel --with-gslib
52+
or
53+
pip install . -C"with-parallel=Yes" -C"with-gslib=Yes"
3154
```
3255

3356
Note: this option turns on building `metis` and `Hypre`
@@ -105,7 +128,7 @@ option.
105128

106129
(example)
107130
```shell
108-
python setup.py install --mfem-branch=master
131+
pip install . -C"mfem-branch=master"
109132
```
110133

111134
### Using MFEM build externally.
@@ -136,43 +159,38 @@ and `--mfem-prefix`
136159
| `--ext-only` | build exteranl libraries and exit.|
137160

138161
During the development, often we update depenencies (such as MFEM) and edit `*.i` file.
162+
These options allows for building PyMFEM in a step-by-step manner, without rebuilding
163+
the entire wrapper everytime.
139164

140-
141-
First clean everything.
165+
First clone the repository or clean everything.
142166

143167
```shell
168+
git clone git@github.com:mfem/PyMFEM.git;cd PyMFEM
144169
python setup.py clean --all
145170
```
146171

147-
Then, build externals alone
172+
Then, build externals alone using the ext-only option
148173
```shell
149-
python setup.py install --with-parallel --ext-only --mfem-branch=master
174+
pip install . -C"ext-only=Yes" --verbose
175+
pip install . -C"with-parallel=Yes" -C"ext-only=Yes" --verbose
150176
```
151177

152-
Then, genrate swig wrappers.
178+
Then, generate swig wrappers, using the swig option, together with skip-ext, so that
179+
external libraies are not rebuild.
153180
```shell
154-
python setup.py install --with-parallel --swig --mfem-branch=master
181+
pip install . -C"skip-ext=Yes" -C"swig=Yes" --verbose
182+
pip install . -C"with-parallel=Yes" -C"skip-ext=Yes" -C"swig=Yes" --verbose
155183
```
156184

157185
If you are not happy with the wrapper (`*.cxx` and `*.py`), you edit `*.i` and redo
158-
the same. When you are happy, build the wrapper. `--swig` does not clean the
159-
existing wrapper. So, it will only update wrapper for updated `*.i`
160-
161-
When building a wrapper, you can use `--skip-ext` option. By default, it will re-run
162-
swig to generate entire wrapper codes.
163-
```shell
164-
python setup.py install --with-parallel --skip-ext --mfem-branch=master
165-
```
186+
the same. When you are happy, build the wrapper with skip-swig and skip-ext.
166187

167-
If you are sure, you could use `--skip-swig` option, so that it compiles the wrapper
168-
codes without re-generating it.
169188
```shell
170-
python setup.py install --with-parallel --skip-ext --skip-swig --mfem-branch=master
189+
pip install . -C"skip-ext=Yes" -C"skip-swig=Yes" --verbose
190+
pip install . -C"with-parallel=Yes" -C"skip-ext=Yes" -C"skip-swig=Yes" --verbose
171191
```
172192

173193
### Other options
174194
`--unverifiedSSL` :
175195
This addresses error relating SSL certificate. Typical error message is
176196
`<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:xxx)>`
177-
178-

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2020, Princeton Plasma Physics Laboratory
3+
Copyright (c) 2020-2025, Princeton Plasma Physics Laboratory
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

README.md

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,32 @@ By default, "pip install mfem" downloads and builds the serial version of MFEM a
1010
Additionally, the installer supports building MFEM with specific options together with other external libraries, including MPI version.
1111

1212
## Install
13+
### Using pip (Serial MFEM)
1314
```shell
14-
pip install mfem # binary install is available only on linux platforms (Py36-310)
15+
pip install mfem # binary install is available only on linux platforms (Py38-312)
1516

1617
```
1718

18-
## Build with additional features (MPI, GPU, GPU-Hypre, GSLIB, SuiteSparse, libCEED, LAPACK)
19-
The setup script accept various options. TO use it, one can either use --install-option flag
20-
with pip, or download the package manually and run the script. For example, the one below downloads
21-
and build parallel version of MFEM library (linked with Metis and Hypre)
22-
and installs under <prefix>/mfem. See also, docs/install.txt
19+
### Build with additional features (MPI, GPU, GPU-Hypre, GSLIB, SuiteSparse, libCEED, LAPACK)
2320

21+
The setup script accept various options. Download the package manually and run the script. Examples below downloads and build parallel version of MFEM library (linked with Metis and Hypre) and installs under <prefix>/mfem. See INSTALL.md for various other options
2422

25-
### Build from local source file
2623
```shell
2724
# Download source and build
28-
$ pip download mfem --no-binary mfem (expand tar.gz file and move to the downloaded directory)
29-
or clone this repository
3025
$ git clone https://github.com/mfem/PyMFEM.git
3126

32-
# Then, build it from local source
33-
$ python -m pip install ./ --install-option="--with-parallel" --install-option="--mfem-branch=master"
34-
or
35-
$ python setup.py install --with-parallel # it download and build metis/hypre/mfem
27+
# Build it from local source with MPI
28+
$ pip install ./ -C"with-parallel=Yes" --verbose
3629

37-
# Verbose output
38-
$ python setup.py install --verbose # SWIG output and CMAKE_VERBOSE_MAKEFILE is on
3930

4031
# Cleaning
4132
$ python setup.py clean --all # clean external dependencies + wrapper code
4233

43-
# Choosing compiler
44-
$ python setup.py install --with-parallel --CC=icc --CXX=icpc --MPICC=mpiicc --MPICXX=mpiicpc
45-
4634
# Run test
4735
cd test
4836
python test_examples.py -serial
4937

50-
# For other configurations, see docs/install.txt or help
51-
$ python setup.py install --help
52-
53-
```
38+
# For other configurations, see INSTALL.md
5439

5540
## Usage
5641
This example (modified from `ex1.cpp`) solves the Poisson equation,

_build_system/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
k

0 commit comments

Comments
 (0)