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

Hotfix/2.0.10 #294

Merged
merged 7 commits into from
Aug 24, 2023
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
21 changes: 11 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,30 @@ jobs:
name: Run tests before publishing
runs-on: ubuntu-latest
container:
image: sblauth/cashocs:latest
image: ghcr.io/sblauth/cashocs:main
options: --user=root

steps:
- name: Delete old installation
shell: bash -l {0}
- name: Delete current installation in docker image
shell: bash
run: |
conda activate cashocs
source /usr/local/bin/_entrypoint.sh
pip uninstall -y cashocs
rm -R /root/cashocs
rm -R /home/mambauser/cashocs

- name: Checkout repository
uses: actions/checkout@v3.5.3

- name: Update cashocs installation
shell: bash -l {0}
- name: Install cashocs
shell: bash
run: |
conda activate cashocs
source /usr/local/bin/_entrypoint.sh
pip install .[all]

- name: Run tests
shell: bash -l {0}
shell: bash
run: |
conda activate cashocs
source /usr/local/bin/_entrypoint.sh
python3 -m pytest -vv tests/


Expand Down
6 changes: 3 additions & 3 deletions cashocs/geometry/mesh_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,9 @@ def remesh(self, solver: OptimizationAlgorithm) -> bool:
solver: The optimization algorithm used to solve the problem.

Returns:
A boolean, which indicates whether the geometry was remeshed (`True`) or not
(`False`).
A boolean that indicated whether a remeshing has been performed successfully
(if it is `True`) or not (if it is `False`). A possible reason why remeshing
was not successful is that it is not activated in the configuration.

"""
if self.do_remesh and self.db.parameter_db.temp_dict:
Expand Down Expand Up @@ -646,7 +647,6 @@ def remesh(self, solver: OptimizationAlgorithm) -> bool:

self._reinitialize(solver)
self._check_imported_mesh_quality(solver)

return True

else:
Expand Down
4 changes: 2 additions & 2 deletions docs/source/_static/version_switcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
},
{
"name": "2.0 (stable)",
"version": "2.0.9",
"url": "https://cashocs.readthedocs.io/en/v2.0.9/"
"version": "2.0.10",
"url": "https://cashocs.readthedocs.io/en/v2.0.10/"
},
{
"name": "1.8",
Expand Down
35 changes: 35 additions & 0 deletions tests/test_remeshing.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,38 @@ def mesh_parametrization(mesh_file):
[f"rm -r {dir_path}/mesh/remesh/cashocs_remesh_*"], shell=True, check=True
)
MPI.barrier(MPI.comm_world)


def test_remeshing_disabled():
dir_path = str(pathlib.Path(__file__).parent)
mesh_file = f"{dir_path}/mesh/remesh/mesh.xdmf"

config = cashocs.load_config(f"{dir_path}/config_remesh.ini")
config.set("Mesh", "mesh_file", dir_path + "/mesh/remesh/mesh.xdmf")
config.set("Mesh", "gmsh_file", dir_path + "/mesh/remesh/mesh.msh")
config.set("Mesh", "geo_file", dir_path + "/mesh/remesh/mesh.geo")
config.set("Mesh", "remesh", "False")
config.set("Output", "save_state", "False")
config.set("Output", "save_adjoint", "False")
config.set("Output", "save_gradient", "False")
config.set("Output", "save_mesh", "False")
config.set("Output", "save_results", "False")
config.set("Output", "save_txt", "False")
config.set("OptimizationRoutine", "soft_exit", "False")

mesh, subdomains, boundaries, dx, ds, dS = cashocs.import_mesh(mesh_file)

V = FunctionSpace(mesh, "CG", 1)
u = Function(V)
p = Function(V)

x = SpatialCoordinate(mesh)
f = 2.5 * pow(x[0] + 0.4 - pow(x[1], 2), 2) + pow(x[0], 2) + pow(x[1], 2) - 1

e = inner(grad(u), grad(p)) * dx - f * p * dx
bcs = DirichletBC(V, Constant(0), boundaries, 1)

J = cashocs.IntegralFunctional(u * dx)

sop = cashocs.ShapeOptimizationProblem(e, bcs, J, u, p, boundaries, config)
sop.solve(max_iter=7)
Loading