Skip to content

Commit

Permalink
Revert moving feature to booleans to common.
Browse files Browse the repository at this point in the history
  • Loading branch information
jhale committed Sep 11, 2024
1 parent d9edd71 commit 6119ef9
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 30 deletions.
2 changes: 1 addition & 1 deletion python/demo/demo_axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
scalar_type = PETSc.ScalarType
real_type = PETSc.RealType

if not dolfinx.common.has_petsc:
if not dolfinx.has_petsc:
print("This demo requires DOLFINx to be compiled with PETSc enabled.")
exit(0)
except ModuleNotFoundError:
Expand Down
2 changes: 1 addition & 1 deletion python/demo/demo_biharmonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
if importlib.util.find_spec("petsc4py") is not None:
import dolfinx

if not dolfinx.common.has_petsc:
if not dolfinx.has_petsc:
print("This demo requires DOLFINx to be compiled with PETSc enabled.")
exit(0)
from petsc4py.PETSc import ScalarType # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion python/demo/demo_cahn-hilliard.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@

import dolfinx

if not dolfinx.common.has_petsc:
if not dolfinx.has_petsc:
print("This demo requires DOLFINx to be compiled with PETSc enabled.")
exit(0)
except ModuleNotFoundError:
Expand Down
2 changes: 1 addition & 1 deletion python/demo/demo_elasticity.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import dolfinx

if not dolfinx.common.has_petsc:
if not dolfinx.has_petsc:
print("This demo requires DOLFINx to be compiled with PETSc enabled.")
exit(0)
except ModuleNotFoundError:
Expand Down
2 changes: 1 addition & 1 deletion python/demo/demo_half_loaded_waveguide.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

import dolfinx

if not dolfinx.common.has_petsc:
if not dolfinx.has_petsc:
print("This demo requires DOLFINx to be compiled with PETSc enabled.")
exit(0)
if PETSc.IntType == np.int64 and MPI.COMM_WORLD.size > 1:
Expand Down
21 changes: 11 additions & 10 deletions python/demo/demo_hdg.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,31 @@
# - Solve Poisson's equation using an HDG scheme.

# +
from mpi4py import MPI

import dolfinx.common

if not dolfinx.common.has_petsc4py:
print("DOLFINx Python was built without petsc4py support.")
exit(0)

import importlib.util

if importlib.util.find_spec("petsc4py") is not None:
import dolfinx

if not dolfinx.has_petsc:
print("This demo requires DOLFINx to be compiled with PETSc enabled.")
exit(0)
from petsc4py import PETSc

from dolfinx.fem.petsc import assemble_matrix_block, assemble_vector_block

else:
print("Could not find petsc4py module.")
print("This demo requires petsc4py.")
exit(0)

import sys

from mpi4py import MPI

import numpy as np

import ufl
from dolfinx import fem, mesh
from dolfinx.cpp.mesh import cell_num_entities
from dolfinx.fem.petsc import assemble_matrix_block, assemble_vector_block
from ufl import div, dot, grad, inner


Expand Down
2 changes: 1 addition & 1 deletion python/demo/demo_helmholtz.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import dolfinx

if not dolfinx.common.has_petsc:
if not dolfinx.has_petsc:
print("This demo requires DOLFINx to be compiled with PETSc enabled.")
exit(0)
except ModuleNotFoundError:
Expand Down
2 changes: 1 addition & 1 deletion python/demo/demo_mixed-poisson.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@

import dolfinx

if not dolfinx.common.has_petsc:
if not dolfinx.has_petsc:
print("This demo requires DOLFINx to be compiled with PETSc enabled.")
exit(0)
except ModuleNotFoundError:
Expand Down
16 changes: 14 additions & 2 deletions python/demo/demo_navier-stokes.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,14 @@
if importlib.util.find_spec("petsc4py") is not None:
import dolfinx

if not dolfinx.common.has_petsc:
if not dolfinx.has_petsc:
print("This demo requires DOLFINx to be compiled with PETSc enabled.")
exit(0)
else:
print("This demo requires petsc4py.")
exit(0)

from mpi4py import MPI
from petsc4py import PETSc

# +
import numpy as np
Expand All @@ -201,6 +200,19 @@
outer,
)

try:
from petsc4py import PETSc

import dolfinx

if not dolfinx.has_petsc:
print("This demo requires DOLFINx to be compiled with PETSc enabled.")
exit(0)
except ModuleNotFoundError:
print("This demo requires petsc4py.")
exit(0)


if np.issubdtype(PETSc.ScalarType, np.complexfloating): # type: ignore
print("Demo should only be executed with DOLFINx real mode")
exit(0)
Expand Down
2 changes: 1 addition & 1 deletion python/demo/demo_pml.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
if importlib.util.find_spec("petsc4py") is not None:
import dolfinx

if not dolfinx.common.has_petsc:
if not dolfinx.has_petsc:
print("This demo requires DOLFINx to be compiled with PETSc enabled.")
exit(0)
else:
Expand Down
2 changes: 1 addition & 1 deletion python/demo/demo_poisson.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
if importlib.util.find_spec("petsc4py") is not None:
import dolfinx

if not dolfinx.common.has_petsc:
if not dolfinx.has_petsc:
print("This demo requires DOLFINx to be compiled with PETSc enabled.")
exit(0)
from petsc4py.PETSc import ScalarType # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion python/demo/demo_scattering_boundary_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
if importlib.util.find_spec("petsc4py") is not None:
import dolfinx

if not dolfinx.common.has_petsc:
if not dolfinx.has_petsc:
print("This demo requires DOLFINx to be compiled with PETSc enabled.")
exit(0)

Expand Down
2 changes: 1 addition & 1 deletion python/demo/demo_static-condensation.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import dolfinx

if not dolfinx.common.has_petsc:
if not dolfinx.has_petsc:
print("This demo requires DOLFINx to be compiled with PETSc enabled.")
exit(0)
except ModuleNotFoundError:
Expand Down
2 changes: 1 addition & 1 deletion python/demo/demo_stokes.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

import dolfinx

if not dolfinx.common.has_petsc:
if not dolfinx.has_petsc:
print("This demo requires DOLFINx to be compiled with PETSc enabled.")
exit(0)
except ModuleNotFoundError:
Expand Down
2 changes: 1 addition & 1 deletion python/demo/demo_tnt-elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
if importlib.util.find_spec("petsc4py") is not None:
import dolfinx

if not dolfinx.common.has_petsc:
if not dolfinx.has_petsc:
print("This demo requires DOLFINx to be compiled with PETSc enabled.")
exit(0)
else:
Expand Down
21 changes: 20 additions & 1 deletion python/dolfinx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,18 @@
from dolfinx import cpp as _cpp
from dolfinx import fem, geometry, graph, io, jit, la, log, mesh, nls, plot, utils

# Initialise logging
from dolfinx.common import (
git_commit_hash,
has_adios2,
has_complex_ufcx_kernels,
has_debug,
has_kahip,
has_parmetis,
has_petsc,
has_petsc4py,
has_ptscotch,
has_slepc,
ufcx_signature
)
from dolfinx.cpp import __version__

Expand Down Expand Up @@ -67,4 +76,14 @@ def get_include(user=False):
"plot",
"utils",
"git_commit_hash",
"has_adios2",
"has_complex_ufcx_kernels",
"has_debug",
"has_kahip",
"has_parmetis",
"has_petsc",
"has_petsc4py",
"has_ptscotch",
"has_slepc",
"ufcx_signature"
]
4 changes: 2 additions & 2 deletions python/dolfinx/fem/petsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
from petsc4py import PETSc

# ruff: noqa: E402
import dolfinx.common
import dolfinx

assert dolfinx.common.has_petsc4py
assert dolfinx.has_petsc4py

import numpy as np

Expand Down
4 changes: 2 additions & 2 deletions python/dolfinx/nls/petsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
from mpi4py import MPI
from petsc4py import PETSc

import dolfinx.common
import dolfinx

assert dolfinx.common.has_petsc4py
assert dolfinx.has_petsc4py

from dolfinx.fem.problem import NonlinearProblem

Expand Down

0 comments on commit 6119ef9

Please sign in to comment.