Skip to content

Commit

Permalink
Merge pull request #267 from sblauth/development/remesh_iters
Browse files Browse the repository at this point in the history
Add configuration parameter "remesh_iter" to Section "MeshQuality"
  • Loading branch information
sblauth authored Jul 11, 2023
2 parents d1fafb4 + 0a65838 commit 09de2ff
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ of the maintenance releases, please take a look at

* :ini:`fail_if_not_converged` determines, whether the line search is cancelled once the state system cannot be solved or if a new iterate is tried instead.

* Section MeshQuality

* :ini:`remesh_iter` is used to perform a remeshing after a certain amount of iterations.



2.0.0 (May 16, 2023)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,23 @@ def requires_remeshing(self) -> bool:
A boolean, which indicates whether remeshing is required.
"""
return bool(
mesh_quality_criterion = bool(
self.mesh_handler.current_mesh_quality
< self.mesh_handler.mesh_quality_tol_upper
)

iteration = self.db.parameter_db.optimization_state["iteration"]
if self.db.config.getint("MeshQuality", "remesh_iter") > 0:
iteration_criterion = bool(
iteration > 0
and iteration % self.db.config.getint("MeshQuality", "remesh_iter") == 0
)
else:
iteration_criterion = False

requires_remeshing = mesh_quality_criterion or iteration_criterion
return requires_remeshing

def project_ncg_search_direction(
self, search_direction: List[fenics.Function]
) -> None:
Expand Down
5 changes: 5 additions & 0 deletions cashocs/io/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@ def __init__(self, config_file: Optional[str] = None) -> None:
"type": "str",
"possible_options": ["min", "avg", "minimum", "average"],
},
"remesh_iter": {
"type": "int",
"attributes": ["non_negative"],
},
},
"TopologyOptimization": {
"angle_tol": {
Expand Down Expand Up @@ -637,6 +641,7 @@ def __init__(self, config_file: Optional[str] = None) -> None:
type = min
volume_change = inf
angle_change = inf
remesh_iter = 0
[TopologyOptimization]
angle_tol = 1.0
Expand Down
10 changes: 9 additions & 1 deletion docs/source/user/demos/shape_optimization/doc_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ Available options are
(see :py:class:`MeshQuality <cashocs.MeshQuality>` for a detailed description).
The default value is given by :ini:`measure = skewness`.

Finally, the parameter :ini:`type` determines, whether the minimum quality over all
The parameter :ini:`type` determines, whether the minimum quality over all
elements (:ini:`type = min`) or the average quality over all elements (:ini:`type = avg`)
shall be used. This is set via

Expand All @@ -973,6 +973,14 @@ shall be used. This is set via
and defaults to :ini:`type = min`.

Finally, we have the parameter :ini:`remesh_iter` in which the user can specify after how many iterations a remeshing should be performed. It is given by

.. code-block:: ini
remesh_iter = 0
where :ini:`remesh_iter = 0` means that no automatic remeshing is performed (this is the default), and :ini:`remesh_iter = n` means that remeshing is performed after each `n` iterations. Note that to use this parameter and avoid unexpected results, it might be beneficial to the the lower and upper mesh quality tolerances to a low value, so that the "quality based remeshing" does not interfere with the "iteration based remeshing", but both can be used in combination.

.. _config_shape_output:

Section Output
Expand Down

0 comments on commit 09de2ff

Please sign in to comment.