Skip to content
Merged
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
12 changes: 8 additions & 4 deletions src/scifem/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ def find_cell_extrema(
else:
raise NotImplementedError(f"Unknown type of extrema ({kind}), expected {min} or {max}")

ud = u.ufl_domain()
assert ud is not None
uds = ufl.domain.extract_domains(u)
if uds is None or len(uds) != 1:
raise ValueError(f"Expression {u:s} must be defined on a single domain")
ud = uds[0]
mesh = dolfinx.mesh.Mesh(ud.ufl_cargo(), ud)

if x0 is None:
Expand Down Expand Up @@ -307,8 +309,10 @@ def compute_extrema(
"""

# Extract DOLFINx mesh
ud = u.ufl_domain()
assert ud is not None
uds = ufl.domain.extract_domains(u)
if uds is None or len(uds) != 1:
raise ValueError(f"Expression {u:s} must be defined on a single domain")
ud = uds[0]
mesh = dolfinx.mesh.Mesh(ud.ufl_cargo(), ud)

if kind is builtins.max:
Expand Down
12 changes: 12 additions & 0 deletions src/scifem/mesh.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from __future__ import annotations
import sys

if sys.version_info >= (3, 13):
from warnings import deprecated
else:
from typing_extensions import deprecated

from . import _scifem # type: ignore
import collections
Expand Down Expand Up @@ -118,6 +124,12 @@ def create_entity_markers(
return dolfinx.mesh.meshtags(domain, dim, facets, markers[facets])


@deprecated(
"This function is deprecated and will be removed in a future version. "
+ "Please use `dolfinx.mesh.transfer_meshtags_to_submesh()` instead.",
category=DeprecationWarning,
stacklevel=2,
)
def transfer_meshtags_to_submesh(
entity_tag: dolfinx.mesh.MeshTags,
submesh: dolfinx.mesh.Mesh,
Expand Down
3 changes: 3 additions & 0 deletions src/scifem/petsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ def apply_lifting_and_set_bc(
except AssertionError:
bcs0 = bcs
bcs1 = bcs
except ValueError: # Changed error type post https://github.com/FEniCS/dolfinx/pull/4312
bcs0 = bcs
bcs1 = bcs

dolfinx.fem.petsc.apply_lifting(b, a, bcs=bcs1, x0=x, alpha=alpha)
ghost_update(b, PETSc.InsertMode.ADD_VALUES, PETSc.ScatterMode.REVERSE)
Expand Down
12 changes: 12 additions & 0 deletions src/scifem/solvers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
from __future__ import annotations

import sys
from typing import Callable
import logging

if sys.version_info >= (3, 13):
from warnings import deprecated
else:
from typing_extensions import deprecated


from packaging.version import parse as _v

import numpy as np
Expand All @@ -23,6 +31,7 @@
if _v(dolfinx.__version__) < _v("0.9"):
_alpha_kw = "scale"

@deprecated("NewtonSolver is deprecated in favor of `dolfinx.fem.petsc.NonlinearProblem`.")
class NewtonSolver:
max_iterations: int
_bcs: list[dolfinx.fem.DirichletBC]
Expand Down Expand Up @@ -307,6 +316,9 @@ def __del__(self):
self._solver.destroy()
self.x.destroy()

@deprecated(
"BlockedNewtonSolver is deprecated in favor of `dolfinx.fem.petsc.NonlinearProblem`."
)
class BlockedNewtonSolver(dolfinx.cpp.nls.petsc.NewtonSolver):
def __init__(
self,
Expand Down
10 changes: 9 additions & 1 deletion src/scifem/spaces.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from warnings import warn

from mpi4py import MPI
import dolfinx
import basix
Expand All @@ -22,7 +24,13 @@ def create_real_functionspace(
For scalar elements value shape is ``()``.

"""

if Version(dolfinx.__version__) >= Version("0.11.0"):
warn(
"`create_real_functionspace()` is deprecated and will be removed in a future version."
+ "Please use `basix.ufl.create_real_element()` instead.",
category=DeprecationWarning,
stacklevel=2,
)
dtype = mesh.geometry.x.dtype
ufl_e = basix.ufl.element(
"P", mesh.basix_cell(), 0, dtype=dtype, discontinuous=True, shape=value_shape
Expand Down
Loading