Skip to content
Merged
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
17 changes: 9 additions & 8 deletions src/scifem/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,18 +209,19 @@ def eval_dJ(x_ref):
# In SciPy, 'ineq' means the function must be >= 0.
# So, x + y <= 1 becomes 1 - x - y >= 0.
cell_type = mesh.topology.cell_type
if cell_type == dolfinx.mesh.CellType.triangle:
if cell_type in (dolfinx.mesh.CellType.triangle, dolfinx.mesh.CellType.tetrahedron):
method = method or "SLSQP"
constraint = {"type": "ineq", "fun": lambda x: 1.0 - x[0] - x[1]}
elif (
cell_type == dolfinx.mesh.CellType.quadrilateral
or cell_type == dolfinx.mesh.CellType.hexahedron
constraint = {
"type": "ineq",
"fun": lambda x: 1.0 - sum(x[i] for i in range(mesh.topology.dim)),
}
elif cell_type in (
dolfinx.mesh.CellType.interval,
dolfinx.mesh.CellType.quadrilateral,
dolfinx.mesh.CellType.hexahedron,
):
method = method or "L-BFGS-B"
constraint = {}
elif cell_type == dolfinx.mesh.CellType.tetrahedron:
method = method or "SLSQP"
constraint = {"type": "ineq", "fun": lambda x: 1.0 - x[0] - x[1] - x[2]}
else:
raise RuntimeError(f"Unsupported {cell_type=}")

Expand Down
Loading