Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/actions/install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ runs:
exit 1
fi

: # DROP BEFORE MERGE: apply PETSc MR 9901
curl -fsSL https://gitlab.com/petsc/petsc/-/merge_requests/9901.diff | git -C petsc apply

if [ ${{ inputs.os }} = 'linux' ]; then
NPROCS=8
elif [ ${{ inputs.os }} = 'macos' ]; then
Expand Down
42 changes: 17 additions & 25 deletions firedrake/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,16 +405,14 @@ def _from_triangle(filename, dim, comm):

with temp_internal_comm(comm) as icomm:
if icomm.rank == 0:
try:
facetfile = open(basename+".face")
tdim = 3
except FileNotFoundError:
try:
facetfile = open(basename+".edge")
tdim = 2
except FileNotFoundError:
facetfile = None
tdim = 1
with open(basename+".ele") as elefile:
header = np.fromfile(elefile, dtype=np.int32, count=2, sep=' ')
elecount = header[0]
eledim = header[1]
eles = np.loadtxt(elefile, usecols=list(range(1, eledim+1)), dtype=np.int32, skiprows=1, ndmin=2)
assert elecount == eles.shape[0]
# Each cell is a simplex with tdim + 1 vertices.
tdim = eledim - 1
if dim is None:
dim = tdim
icomm.bcast(tdim, root=0)
Expand All @@ -427,13 +425,6 @@ def _from_triangle(filename, dim, comm):
coordinates = np.loadtxt(nodefile, usecols=list(range(1, dim+1)), skiprows=1, dtype=np.double)
assert nodecount == coordinates.shape[0]

with open(basename+".ele") as elefile:
header = np.fromfile(elefile, dtype=np.int32, count=2, sep=' ')
elecount = header[0]
eledim = header[1]
eles = np.loadtxt(elefile, usecols=list(range(1, eledim+1)), dtype=np.int32, skiprows=1)
assert elecount == eles.shape[0]

cells = list(map(lambda c: c-1, eles))
else:
tdim = icomm.bcast(None, root=0)
Expand All @@ -443,21 +434,22 @@ def _from_triangle(filename, dim, comm):

# Apply boundary IDs
if icomm.rank == 0:
# Triangle (2D) and TetGen (3D) write the optional facet file.
Comment thread
pbrubeck marked this conversation as resolved.
Resolved
facetfilename = basename + {2: ".edge", 3: ".face"}[tdim]
facets = None
try:
header = np.fromfile(facetfile, dtype=np.int32, count=2, sep=' ')
edgecount = header[0]
facets = np.loadtxt(facetfile, usecols=list(range(1, tdim+2)), dtype=np.int32, skiprows=0)
assert edgecount == facets.shape[0]
finally:
facetfile.close()
if os.path.isfile(facetfilename):
with open(facetfilename) as facetfile:
header = np.fromfile(facetfile, dtype=np.int32, count=2, sep=' ')
edgecount = header[0]
facets = np.loadtxt(facetfile, usecols=list(range(1, tdim+2)), dtype=np.int32, skiprows=0, ndmin=2)
assert edgecount == facets.shape[0]

if facets is not None:
vStart, vEnd = plex.getDepthStratum(0) # vertices
for facet in facets:
bid = facet[-1]
vertices = list(map(lambda v: v + vStart - 1, facet[:-1]))
join = plex.getJoin(vertices)
join = plex.getFullJoin(vertices)
plex.setLabelValue(dmcommon.FACE_SETS_LABEL, join[0], bid)

return plex
Expand Down
75 changes: 63 additions & 12 deletions scripts/firedrake-configure
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,11 @@ class CommunityArch(Arch):
ArchKey = tuple[OS, ScalarType, IntType, GPUPlatform]

# Configurations with official support that are tested in CI
#
# On Ubuntu, we tell PETSc to download Exodus II, because the Exodus II library
# from apt does not have ex_open_par, which PETSc needs. We also tell PETSc the
# paths to the HDF5 and NetCDF libraries from apt, because the CMake builds of
# CGNS and Exodus II cannot find them.
OFFICIAL_ARCHS: Mapping[ArchKey, Arch] = {

# Ubuntu 26.04 x86
Expand Down Expand Up @@ -467,7 +472,7 @@ OFFICIAL_ARCHS: Mapping[ArchKey, Arch] = {
"libhypre-dev",
"libmumps-ptscotch-dev",
"libmetis-dev",
"libnetcdf-dev",
"libnetcdf-pnetcdf-dev",
"libopenblas-dev",
"libopenmpi-dev",
"libpnetcdf-dev",
Expand All @@ -486,8 +491,15 @@ OFFICIAL_ARCHS: Mapping[ArchKey, Arch] = {
"--with-hypre",
"--with-metis",
"--with-mumps",
"--with-netcdf",
"--with-netcdf-dir=/usr/lib/x86_64-linux-gnu/netcdf/pnetcdf",
"--with-pnetcdf",
"--download-cgns",
"--download-cgns-cmake-arguments=-DHDF5_ROOT:PATH=/usr/lib/x86_64-linux-gnu/hdf5/openmpi",
"--download-exodusii",
"--download-exodusii-cmake-arguments='"
"-DHDF5_ROOT:PATH=/usr/lib/x86_64-linux-gnu/hdf5/openmpi "
"-DPnetcdf_LIBRARY_DIRS:PATH=/usr/lib/x86_64-linux-gnu "
"-DnetCDF_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/netCDF_pnetcdf'",
"--with-ptscotch",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"--with-ptscotch-lib='-lptesmumps -lptscotch -lptscotcherr -lesmumps -lscotch -lscotcherr'",
"--with-ptscotch-include=/usr/include/scotch",
Expand Down Expand Up @@ -528,7 +540,7 @@ OFFICIAL_ARCHS: Mapping[ArchKey, Arch] = {
"libhdf5-mpi-dev",
"libmumps-ptscotch-dev",
"libmetis-dev",
"libnetcdf-dev",
"libnetcdf-pnetcdf-dev",
"libopenblas-dev",
"libopenmpi-dev",
"libpnetcdf-dev",
Expand All @@ -547,8 +559,15 @@ OFFICIAL_ARCHS: Mapping[ArchKey, Arch] = {
"--with-hwloc",
"--with-metis",
"--with-mumps",
"--with-netcdf",
"--with-netcdf-dir=/usr/lib/x86_64-linux-gnu/netcdf/pnetcdf",
"--with-pnetcdf",
"--download-cgns",
"--download-cgns-cmake-arguments=-DHDF5_ROOT:PATH=/usr/lib/x86_64-linux-gnu/hdf5/openmpi",
"--download-exodusii",
"--download-exodusii-cmake-arguments='"
"-DHDF5_ROOT:PATH=/usr/lib/x86_64-linux-gnu/hdf5/openmpi "
"-DPnetcdf_LIBRARY_DIRS:PATH=/usr/lib/x86_64-linux-gnu "
"-DnetCDF_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/netCDF_pnetcdf'",
"--with-ptscotch",
"--with-ptscotch-lib='-lptesmumps -lptscotch -lptscotcherr -lesmumps -lscotch -lscotcherr'",
"--with-ptscotch-include=/usr/include/scotch",
Expand Down Expand Up @@ -585,7 +604,7 @@ OFFICIAL_ARCHS: Mapping[ArchKey, Arch] = {
"libfftw3-mpi-dev",
"libhdf5-mpi-dev",
"libhwloc-dev",
"libnetcdf-dev",
"libnetcdf-pnetcdf-dev",
"libopenblas-dev",
"libopenmpi-dev",
"libpnetcdf-dev",
Expand All @@ -602,8 +621,15 @@ OFFICIAL_ARCHS: Mapping[ArchKey, Arch] = {
"--download-hypre",
"--download-metis",
"--download-mumps",
"--with-netcdf",
"--with-netcdf-dir=/usr/lib/x86_64-linux-gnu/netcdf/pnetcdf",
"--with-pnetcdf",
"--download-cgns",
"--download-cgns-cmake-arguments=-DHDF5_ROOT:PATH=/usr/lib/x86_64-linux-gnu/hdf5/openmpi",
"--download-exodusii",
"--download-exodusii-cmake-arguments='"
"-DHDF5_ROOT:PATH=/usr/lib/x86_64-linux-gnu/hdf5/openmpi "
"-DPnetcdf_LIBRARY_DIRS:PATH=/usr/lib/x86_64-linux-gnu "
"-DnetCDF_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/netCDF_pnetcdf'",
"--download-ptscotch",
"--with-scalapack-lib=-lscalapack-openmpi",
"--with-suitesparse",
Expand Down Expand Up @@ -647,7 +673,7 @@ OFFICIAL_ARCHS: Mapping[ArchKey, Arch] = {
"libhypre-dev",
"libmumps-ptscotch-dev",
"libmetis-dev",
"libnetcdf-dev",
"libnetcdf-pnetcdf-dev",
"libopenblas-dev",
"libopenmpi-dev",
"libpnetcdf-dev",
Expand All @@ -666,8 +692,15 @@ OFFICIAL_ARCHS: Mapping[ArchKey, Arch] = {
"--with-hypre",
"--with-metis",
"--with-mumps",
"--with-netcdf",
"--with-netcdf-dir=/usr/lib/aarch64-linux-gnu/netcdf/pnetcdf",
"--with-pnetcdf",
"--download-cgns",
"--download-cgns-cmake-arguments=-DHDF5_ROOT:PATH=/usr/lib/aarch64-linux-gnu/hdf5/openmpi",
"--download-exodusii",
"--download-exodusii-cmake-arguments='"
"-DHDF5_ROOT:PATH=/usr/lib/aarch64-linux-gnu/hdf5/openmpi "
"-DPnetcdf_LIBRARY_DIRS:PATH=/usr/lib/aarch64-linux-gnu "
"-DnetCDF_DIR:PATH=/usr/lib/aarch64-linux-gnu/cmake/netCDF_pnetcdf'",
"--with-ptscotch",
"--with-ptscotch-lib='-lptesmumps -lptscotch -lptscotcherr -lesmumps -lscotch -lscotcherr'",
"--with-ptscotch-include=/usr/include/scotch",
Expand Down Expand Up @@ -708,7 +741,7 @@ OFFICIAL_ARCHS: Mapping[ArchKey, Arch] = {
"libhdf5-mpi-dev",
"libmumps-ptscotch-dev",
"libmetis-dev",
"libnetcdf-dev",
"libnetcdf-pnetcdf-dev",
"libopenblas-dev",
"libopenmpi-dev",
"libpnetcdf-dev",
Expand All @@ -727,8 +760,15 @@ OFFICIAL_ARCHS: Mapping[ArchKey, Arch] = {
"--with-hwloc",
"--with-metis",
"--with-mumps",
"--with-netcdf",
"--with-netcdf-dir=/usr/lib/aarch64-linux-gnu/netcdf/pnetcdf",
"--with-pnetcdf",
"--download-cgns",
"--download-cgns-cmake-arguments=-DHDF5_ROOT:PATH=/usr/lib/aarch64-linux-gnu/hdf5/openmpi",
"--download-exodusii",
"--download-exodusii-cmake-arguments='"
"-DHDF5_ROOT:PATH=/usr/lib/aarch64-linux-gnu/hdf5/openmpi "
"-DPnetcdf_LIBRARY_DIRS:PATH=/usr/lib/aarch64-linux-gnu "
"-DnetCDF_DIR:PATH=/usr/lib/aarch64-linux-gnu/cmake/netCDF_pnetcdf'",
"--with-ptscotch",
"--with-ptscotch-lib='-lptesmumps -lptscotch -lptscotcherr -lesmumps -lscotch -lscotcherr'",
"--with-ptscotch-include=/usr/include/scotch",
Expand Down Expand Up @@ -770,7 +810,7 @@ OFFICIAL_ARCHS: Mapping[ArchKey, Arch] = {
"libhwloc-dev",
"libmumps-ptscotch-dev",
"libmetis-dev",
"libnetcdf-dev",
"libnetcdf-pnetcdf-dev",
"libopenblas-dev",
"libopenmpi-dev",
"libpnetcdf-dev",
Expand All @@ -797,8 +837,15 @@ OFFICIAL_ARCHS: Mapping[ArchKey, Arch] = {
"--with-hwloc",
"--with-metis",
"--with-mumps",
"--with-netcdf",
"--with-netcdf-dir=/usr/lib/x86_64-linux-gnu/netcdf/pnetcdf",
"--with-pnetcdf",
"--download-cgns",
"--download-cgns-cmake-arguments=-DHDF5_ROOT:PATH=/usr/lib/x86_64-linux-gnu/hdf5/openmpi",
"--download-exodusii",
"--download-exodusii-cmake-arguments='"
"-DHDF5_ROOT:PATH=/usr/lib/x86_64-linux-gnu/hdf5/openmpi "
"-DPnetcdf_LIBRARY_DIRS:PATH=/usr/lib/x86_64-linux-gnu "
"-DnetCDF_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/netCDF_pnetcdf'",
"--with-ptscotch",
"--with-ptscotch-lib='-lptesmumps -lptscotch -lptscotcherr -lesmumps -lscotch -lscotcherr'",
"--with-ptscotch-include=/usr/include/scotch",
Expand Down Expand Up @@ -864,6 +911,8 @@ OFFICIAL_ARCHS: Mapping[ArchKey, Arch] = {
"--download-mumps",
"--download-netcdf",
"--download-pnetcdf",
"--download-cgns",
"--download-exodusii",
"--download-ptscotch",
"--download-superlu_dist",

Expand Down Expand Up @@ -920,6 +969,8 @@ OFFICIAL_ARCHS: Mapping[ArchKey, Arch] = {
"--download-mumps",
"--download-netcdf",
"--download-pnetcdf",
"--download-cgns",
"--download-exodusii",
"--download-ptscotch",
"--download-superlu_dist",

Expand Down
14 changes: 12 additions & 2 deletions tests/firedrake/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,18 @@ def _skip_test_dependency(dependency):
except ImportError:
return skip

elif dependency in ("mumps", "hypre"):
elif dependency in ("mumps", "hypre", "exodusii", "cgns"):
return dependency not in get_external_packages()
Comment thread
connorjward marked this conversation as resolved.
Resolved

else:
raise ValueError("Unrecognised dependency to check: {dependency = }")
raise ValueError(f"Unrecognised dependency to check: {dependency}")


dependency_skip_markers_and_reasons = (
("mumps", "skipmumps", "MUMPS not installed with PETSc"),
("hypre", "skiphypre", "hypre not installed with PETSc"),
("exodusii", "skipexodusii", "ExodusII not installed with PETSc"),
("cgns", "skipcgns", "CGNS not installed with PETSc"),
("slepc", "skipslepc", "SLEPc is not installed"),
("pytorch", "skiptorch", "PyTorch is not installed"),
("jax", "skipjax", "JAX is not installed"),
Expand All @@ -139,6 +141,14 @@ def pytest_configure(config):
"markers",
"skiphypre: mark as skipped unless hypre is installed"
)
config.addinivalue_line(
"markers",
"skipexodusii: mark as skipped unless ExodusII is installed"
)
config.addinivalue_line(
"markers",
"skipcgns: mark as skipped unless CGNS is installed"
)
config.addinivalue_line(
"markers",
"skipcomplex: mark as skipped in complex mode"
Expand Down
18 changes: 5 additions & 13 deletions tests/firedrake/regression/test_exodus_mesh.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
from os.path import abspath, dirname, join
import pytest
from firedrake import *
from firedrake.petsc import PETSc

pytestmark = pytest.mark.skipexodusii

cwd = abspath(dirname(__file__))


@pytest.fixture
def exodus_mesh():
try:
return Mesh(join(cwd, "..", "meshes", "brick.e"))
except PETSc.Error as e:
assert e.ierr == 56
return Mesh(join(cwd, "..", "meshes", "brick.e"))


@pytest.mark.parallel(nprocs=2)
def test_create_from_file(exodus_mesh):
if exodus_mesh is None:
pytest.skip("PETSc not configured with exodusII")
else:
assert exodus_mesh
assert exodus_mesh


@pytest.mark.parallel(nprocs=2)
def test_sidesets(exodus_mesh):
if exodus_mesh is None:
pytest.skip("PETSc not configured with exodusII")
else:
assert (exodus_mesh.exterior_facets.unique_markers == [200, 201]).all()
assert (exodus_mesh.exterior_facets.unique_markers == [200, 201]).all()
Loading
Loading