Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pin Scotch version to <7 #472

Merged
merged 1 commit into from
Jul 16, 2024
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
7 changes: 4 additions & 3 deletions .github/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ USER $MAMBA_USER

RUN micromamba install -y -n base -c conda-forge \
fenics=2019 \
meshio">=5.3.0" \
pytest">=7.2.0" \
meshio">=5.3" \
pytest \
gmsh">=4.8" \
coverage">=7.1.0" \
coverage \
mpich \
scipy \
scotch"<7" \
python=3.11 && \
micromamba clean --all --yes

Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/test_demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ jobs:
environment-file: .github/micromamba/testenv.yml
create-args: >-
fenics=2019
meshio>=5.3.0
pytest>=7.2.0
meshio>=5.3
pytest
gmsh>=4.8
matplotlib
scipy
scotch<7
python=3.12

- name: Install package
Expand Down Expand Up @@ -63,12 +64,13 @@ jobs:
environment-file: .github/micromamba/testenv.yml
create-args: >-
fenics=2019
meshio>=5.3.0
pytest>=7.2.0
meshio>=5.3
pytest
gmsh>=4.8
mpich
matplotlib
scipy
scotch<7
python=3.12

- name: Install package
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/tests_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ jobs:
create-args: >-
python=${{ matrix.python-version }}
fenics=2019
meshio>=5.3.0
pytest>=7.2.0
meshio>=5.3
pytest
gmsh>=4.8
scipy
scotch<7

- name: Install package
run: |
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/tests_parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ jobs:
environment-file: .github/micromamba/testenv.yml
create-args: >-
fenics=2019
meshio>=5.3.0
pytest>=7.2.0
meshio>=5.3
pytest
gmsh>=4.8
scipy
scotch<7
${{ matrix.mpi }}
python=${{ matrix.python-version }}

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/tests_serial.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ jobs:
environment-file: .github/micromamba/testenv.yml
create-args: >-
fenics=2019
meshio>=5.3.0
pytest>=7.2.0
meshio>=5.3
pytest
gmsh>=4.8
scipy
scotch<7
python=${{ matrix.python-version }}

- name: Install package
Expand Down
6 changes: 3 additions & 3 deletions tests/test_optimal_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@ def test_scalar_tracking_weight(rng, geometry, config_ocp, F, bcs, y, u, p):
val = test_ocp.reduced_cost_functional.evaluate()
assert np.abs(val - weight) < 1e-15

assert cashocs.verification.control_gradient_test(test_ocp, rng=rng) > 1.85
assert cashocs.verification.control_gradient_test(test_ocp, rng=rng) > 1.85
assert cashocs.verification.control_gradient_test(test_ocp, rng=rng) > 1.85
assert cashocs.verification.control_gradient_test(test_ocp, rng=rng) > 1.9
assert cashocs.verification.control_gradient_test(test_ocp, rng=rng) > 1.9
assert cashocs.verification.control_gradient_test(test_ocp, rng=rng) > 1.9


def test_scalar_multiple_norms(rng, config_ocp, geometry, F, bcs, y, u, p):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_p_laplacian.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,6 @@ def test_p_laplacian_iterative(rng, config_sop, e, bcs, J, u, p, geometry):
sop = cashocs.ShapeOptimizationProblem(
e, bcs, J, u, p, geometry.boundaries, config=config_sop
)
assert sop.gradient_test(rng=rng) > 1.8
assert sop.gradient_test(rng=rng) > 1.8
assert sop.gradient_test(rng=rng) > 1.8
assert sop.gradient_test(rng=rng) > 1.9
assert sop.gradient_test(rng=rng) > 1.9
assert sop.gradient_test(rng=rng) > 1.9
134 changes: 67 additions & 67 deletions tests/test_shape_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ def test_shape_gradient(config_sop, rng):
mesh.bounding_box_tree().build(mesh)
sop = cashocs.ShapeOptimizationProblem(e, bcs, J, u, p, boundaries, config_sop)

assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9


def test_shape_gradient_iterative(rng):
Expand All @@ -319,9 +319,9 @@ def test_shape_gradient_iterative(rng):
mesh.bounding_box_tree().build(mesh)
sop = cashocs.ShapeOptimizationProblem(e, bcs, J, u, p, boundaries, config)

assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9


def test_shape_gd():
Expand Down Expand Up @@ -418,9 +418,9 @@ def test_shape_volume_regularization():
J_vol = cashocs.IntegralFunctional(Constant(0) * dx)
sop = cashocs.ShapeOptimizationProblem(e, bcs, J_vol, u, p, boundaries, config)

assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9

sop.solve(algorithm="bfgs", rtol=1e-6, max_iter=50)
coords = cashocs.io.mesh.gather_coordinates(mesh)
Expand All @@ -445,9 +445,9 @@ def test_shape_surface_regularization():
J_vol = cashocs.IntegralFunctional(Constant(0) * dx)
sop = cashocs.ShapeOptimizationProblem(e, bcs, J_vol, u, p, boundaries, config)

assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9

sop.solve(algorithm="bfgs", rtol=1e-6, max_iter=50)
coords = cashocs.io.mesh.gather_coordinates(mesh)
Expand Down Expand Up @@ -476,9 +476,9 @@ def test_shape_barycenter_regularization():
J_vol = cashocs.IntegralFunctional(Constant(0) * dx)
sop = cashocs.ShapeOptimizationProblem(e, bcs, J_vol, u, p, boundaries, config)

assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9

sop.solve(algorithm="bfgs", rtol=1e-5, max_iter=50)

Expand Down Expand Up @@ -510,15 +510,15 @@ def test_custom_supply_shape(rng):

user_sop.supply_custom_forms(dJ, adjoint_form, bcs)

assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.9

user_sop.supply_custom_forms(dJ, [adjoint_form], [bcs])

assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.9


def test_supply_from_custom_fspace(rng):
Expand All @@ -540,9 +540,9 @@ def test_supply_from_custom_fspace(rng):

user_sop.supply_custom_forms(dJ, adjoint_form, bcs)

assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.9


def test_custom_shape_scalar_product(rng):
Expand Down Expand Up @@ -570,9 +570,9 @@ def test_custom_shape_scalar_product(rng):

assert sop.solver.relative_norm < sop.solver.rtol

assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
mesh.coordinates()[:, :] = initial_coordinates
mesh.bounding_box_tree().build(mesh)
user_sop = cashocs.ShapeOptimizationProblem(e, bcs, J, u, p, boundaries, config)
Expand All @@ -588,15 +588,15 @@ def test_custom_shape_scalar_product(rng):

user_sop.supply_custom_forms(dJ, adjoint_form, bcs)

assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.9

user_sop.supply_custom_forms(dJ, [adjoint_form], [bcs])

assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(user_sop, rng=rng) > 1.9


def test_curvature_computation():
Expand Down Expand Up @@ -632,9 +632,9 @@ def test_scalar_tracking_regularization():
J_tracking = cashocs.ScalarTrackingFunctional(Constant(1) * dx, tracking_goal)
sop = cashocs.ShapeOptimizationProblem(e, bcs, J_tracking, u, p, boundaries, config)

assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9

sop.solve(algorithm="bfgs", rtol=1e-6, max_iter=50)
coords = cashocs.io.mesh.gather_coordinates(mesh)
Expand Down Expand Up @@ -662,9 +662,9 @@ def test_scalar_tracking_norm():

sop = cashocs.ShapeOptimizationProblem(e, bcs, J_tracking, u, p, boundaries, config)

assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9

sop.solve(algorithm="bfgs", rtol=1e-5, max_iter=50)
assert 0.5 * pow(assemble(norm_u) - tracking_goal, 2) < 1e-14
Expand Down Expand Up @@ -693,11 +693,11 @@ def test_scalar_tracking_weight():
sop.compute_state_variables()
val = sop.reduced_cost_functional.evaluate()

assert np.abs(val - weight) / weight < 1e-10
assert np.abs(val - weight) < 1e-15

assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9


def test_scalar_tracking_multiple():
Expand All @@ -716,9 +716,9 @@ def test_scalar_tracking_multiple():

sop = cashocs.ShapeOptimizationProblem(e, bcs, J, u, p, boundaries, config)

assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9

sop.solve(algorithm="bfgs", rtol=1e-7, max_iter=50)
assert 0.5 * pow(assemble(norm_u) - tracking_goals[0], 2) < 1e-13
Expand Down Expand Up @@ -750,9 +750,9 @@ def test_inhomogeneous_mu():

sop = cashocs.ShapeOptimizationProblem(e, bcs, J, u, p, boundaries, config)
rng = np.random.RandomState(300696)
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(sop, rng=rng) > 1.9


def test_save_xdmf_files():
Expand Down Expand Up @@ -879,9 +879,9 @@ def test_scaling_shape():

assert abs(val - diff) < 1e-14

assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.9


def test_scaling_shape_regularization():
Expand Down Expand Up @@ -947,9 +947,9 @@ def test_scaling_scalar_only():

assert abs(val - summ) < 1e-14

assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.9


def test_scaling_scalar_and_single_cost():
Expand Down Expand Up @@ -982,9 +982,9 @@ def test_scaling_scalar_and_single_cost():

assert abs(val - summ) < 1e-14

assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.9


def test_scaling_all():
Expand Down Expand Up @@ -1019,9 +1019,9 @@ def test_scaling_all():

assert abs(val - summ) < 1e-14

assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.85
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.9
assert cashocs.verification.shape_gradient_test(test_sop, rng=rng) > 1.9


def test_angle_change():
Expand All @@ -1045,9 +1045,9 @@ def test_fixed_dimensions(rng):
sop = cashocs.ShapeOptimizationProblem(e, bcs, J, u, p, boundaries, config)
grad_x = sop.compute_shape_gradient()
assert assemble(grad_x[0][0] * grad_x[0][0] * dx) == 0
assert sop.gradient_test(rng=rng) > 1.85
assert sop.gradient_test(rng=rng) > 1.85
assert sop.gradient_test(rng=rng) > 1.85
assert sop.gradient_test(rng=rng) > 1.9
assert sop.gradient_test(rng=rng) > 1.9
assert sop.gradient_test(rng=rng) > 1.9

config.set("ShapeGradient", "fixed_dimensions", "[1]")

Expand All @@ -1056,9 +1056,9 @@ def test_fixed_dimensions(rng):
sop = cashocs.ShapeOptimizationProblem(e, bcs, J, u, p, boundaries, config)
grad_x = sop.compute_shape_gradient()
assert assemble(grad_x[0][1] * grad_x[0][1] * dx) == 0
assert sop.gradient_test(rng=rng) > 1.85
assert sop.gradient_test(rng=rng) > 1.85
assert sop.gradient_test(rng=rng) > 1.85
assert sop.gradient_test(rng=rng) > 1.9
assert sop.gradient_test(rng=rng) > 1.9
assert sop.gradient_test(rng=rng) > 1.9


def test_check_config_list():
Expand Down
Loading