Release Notes#
These are cashocs’ release notes. Note, that only major and minor releases are covered here as they add new functionality or might change the API. For a documentation of the maintenance releases, please take a look at sblauth/cashocs.
2.5.0 (March 26, 2025)#
Add the possibility to re-compute the gradient deformation in shape optimization. To do so, the gradient deformation is first computed as before but then only the surface deformation (or the one in normal direction) is used as boundary condition for the elasticty equation to compute a new deformation. This can help to avoid numerical artifacts in the interior of the domain not related to the actual shape changes.
Update the way
cashocs.ts_pseudo_solve()handles convergence / divergence. A new divergence tolerance is introduced. If the residual increases by a factor of 1e4, the solver automatically diverges and raises a corresponding exception. Moreover, if the solver reaches the maximum number of iterations, no exception is raised anymore. Instead, a warning is issued that the solver did not reach the specified tolerances, but converges anyway. This is in line with the convergence of the PETSc TS.Add support for Python 3.13.
Functions with Crouzeix-Raviart elements are now interpolated into discontinuous Galerkin FEM spaces before being saved as .xdmf file so that they can be worked with.
New configuration file parameters:
Section ShapeGradient
reextend_from_boundaryis a boolean flag which indicates whether the gradient deformation should be re-computed as described abovereextension_modecan have the valuesreextension_mode = surfaceorreextension_mode = normal. In the first case, the boundary values of the gradient deformation are used as they are for the re-extension, in the second case only the normal deformation is used.
2.4.0 (January 24, 2025)#
Add support for named Gmsh meshes, so that the names can not only be used with
cashocs.create_dirichlet_bcs(), but also with thecashocs.NamedMeasureobjects created withcashocs.import_mesh().Add a pseudo time stepping solver for nonlinear equations. This uses PETSc’s TS and is implemented in
cashocs.ts_pseudo_solve(). The pseudo time stepping is also available for optimization problems and documented at https://cashocs.readthedocs.io/en/stable/user/demos/shape_optimization/demo_pseudo_time_stepping/.Add a Poisson approach for computing the distance to the wall. This should be more robust than the previous approach of solving the Eikonal equation but less robust. The method can be changed in the configuration (see “New configuration file parameters” below).
New configuration file parameters:
Section ShapeGradient
distance_methodspecifies which method should be used to compute the distance to the boundary. The default isdistance_method = eikonal, but the new Poisson approach can be used withdistance_method = poisson.
2.3.0 (November 12, 2024)#
The handling of the terminal output (and some other outputs) has changed significantly and now uses the python logging library. This allows for a greater flexibility and automatically times operations. The downside of this is, that the configuration has to change. Particularly, the
verboseandsave_txtparameters are now deprecated and will be removed in the future. These are kept for backwards compatibility reasons, but their default value is set to False to use the new logging-based approach. Moreover, almost any place where a flag such as a keyword argumentverboseorquietis used, is deprecated and will be removed in the future. Here, too, the logging-based approach is used by default now. If your applications are too verbose for you now, you can callcashocs.log.set_log_level(cashocs.log.WARNING)to increase the log level. A brief documentation of the logging capabilities can be found at https://cashocs.readthedocs.io/en/stable/user/demos/misc/demo_logging/.Properly handle the output for nested problems in the context of space mapping and additional constraints. The output config is applied to all problems and the sub- and main problems all write their history to files and console.
Topology optimization problems now work as expected in parallel, with the exception that there is no support for angle-weighted interpolation of the topological derivative. Now, a corresponding exception is raised by cashocs.
Add additional documentation for the configuration parameters for topology optimization which can be found at https://cashocs.readthedocs.io/en/stable/user/demos/topology_optimization/doc_config/.
2.2.0 (August 28, 2024)#
Add a wrapper for PETSc’s SNES solver for nonlinear equations. This is used internally in cashocs whenever possible. For the solution of the state system, our own Newton solver is the default for backwards compatibility. Users can use the new SNES backend by specifying
backend = petscin the Section StateSystem of the configuration.Allows nesting of PETSc Fieldsplit PCs with the command line option “pc_fieldsplit_%d_fields <a,b,…>, as explained at https://petsc.org/main/manualpages/PC/PCFieldSplitSetFields/
Increase the precision of the Gmsh output from cashocs
New configuration file parameters:
Section StateSystem
backendspecifies which backend is used for solving nonlinear equations. The default isbackend = cashocs, which is the “old” behavior, andbackend = petscuses the new PETSc SNES interface.
Section ShapeGradient
test_for_intersectionsis used to disable the (post mesh movement) check for intersections of the mesh, which ensures physically reasonable designs. This should not be set to False.
2.1.0 (February 6, 2024)#
The class
cashocs.DeformationHandlercannot be used anymore. Instead, use the class by callingcashocs.geometry.DeformationHandler.Add the keyword arguments
pre_callbackandpost_callbackto define callbacks when an optimization problem is instanciated.Callbacks can now have one parameter - the parameter supplied when being called during runtime is the optimization problem itself
Add a new function
cashocs.io.extract_mesh_from_xdmf()which extracts (any, not only Gmsh) meshes from some XDMF state file (e.g. written by cashocs) and saves the underlying mesh in Gmsh file format.Add a new command line interface
cashocs-extract_meshwhich can be used to invokecashocs.io.extract_mesh_from_xdmf().The output routines save the xdmf files not in a folder called xdmf anymore, but the folder is called checkpoints
The output parameter
save_meshdoes now not only save the optimized mesh, but also writes a Gmsh .msh file of the current iterated mesh for each iteration. This is very useful for restarting simulations.Added the function
cashocs.io.import_function()which can be used to load a XDMF Function with a function space. This is very useful for checkpointing (first, read the saved mesh, define the function space, then callcashocs.io.import_function().cashocs.import_mesh()can now also directly import a Gmsh mesh file. Internally, the mesh is directly converted to xdmf and then read. At the moment, this only supports the conversion mode physical.Add the kwargs linear_solver and (where applicable) adjoint_linear_solver. These can be used to define custom python KSP objects via petsc4py, most importantly, custom python-based preconditioners can be used with these. The feature is covered in the undocumented demo “demos/shape_optimization/python_pc”.
Add the kwarg newton_linearization to the optimization problem classes. This can be used to specify which (alternative) linearization techniques can be used for solving the nonlinear state systems.
The function
cashocs.newton_solve()does not change the user-specified tolerance (in the ksp_options) anymore, unless the kwarg inexact=True is set. This means, that the user can use custom “inexact Newton” schemes (e.g., gain one digit in accuracy) too. The old default was to use the relative tolerance of the nonlinear iteration multiplied with a safety factor (0.1).New configuration file parameters:
Section LineSearch
fail_if_not_convergeddetermines, whether the line search is cancelled once the state system cannot be solved or if a new iterate is tried instead.
Section ShapeGradient
inhomogeneous_exponentis a float, which specifies an exponent for the inhomogeneous mesh stiffness
Section MeshQuality
remesh_iteris used to perform a remeshing after a certain amount of iterations.
2.0.0 (May 16, 2023)#
cashocs has a new docstyle. It now uses the pydata-sphinx-theme.
Added space mapping methods to cashocs. The space mapping methods can utilize parallelism via MPI.
Added polynomial based models for computing trial stepsizes in an extended Armijo rule.
implemented a wrapper for
cashocs-convert, so that this can be used from inside python too. Simply callcashocs.convert().cashocs-convertnow has a default output argument (which is the same name as the input file). This can be invoked with the-oor--outfile flag.cashocs-convertnow has an additional quiet flag, which can be invoked with-qor--quiet. Analogously,cashocs.convert()also has a keyword argumentquiet. These arguments / flags suppress its output.cashocs now saves files in XDMF file format for visualization and does not use .pvd files anymore. This greatly reduces the number of files needed and also enables better visualization for remeshing.
cashocs’ print calls now flush the output buffer, which helps when sys.stdout is a file.
The “hook” methods of cashocs (
pre_hookandpost_hook) are renamed to “callback”, see, e.g.,inject_pre_callback.cashocs now uses pathlib over os.path
cashocs’ loggers are now not colored anymore, which makes reading the log easier if one logs to a file
Added i/o possibilites to read meshes and functions from the data saved in the xdmf files for visualization. This is documented here.
Deprecated functions have been removed. In particular, the functions
create_bcs_list(),create_config(),damped_newton_solve()are removed. They are replaced bycreate_dirichlet_bcs,load_config, andnewton_solve.The usage of the keyword arguments
scalar_tracking_formsandmin_max_termsinShapeOptimizationProblemandOptimalControlProblemhas been removed. Instead, every cost functional is now passed via thecost_functional_listparameter. Scalar tracking forms are now realized viaScalarTrackingFunctionaland min-max terms viaMinMaxFunctional, see https://cashocs.readthedocs.io/en/stable/user/demos/optimal_control/demo_scalar_control_tracking.BFGS methods can now be used in a restarted fashion, if desired.
The BFGS method can now be used in a damped fashion. This ensures that the inverse Hessian approximation stays positive definite.
The options for defining parameters which are to be supplied to PETSc KSP objects have changed their datatype: They are now given by (lists of) dictionaries instead of nested lists. For options without a value in the command line (e.g. the option
-ksp_view) have a value ofNonein the dictionary (so'ksp_view': Nonecan be used inside the dictionary to supply the aforementioned option).cashocs now includes a
cashocs.linear_solve()that can be used to solve linear problems.Optimization problems, constrained problems, space mapping problems, and linear and nonlinear solvers now include the keyword argument
preconditioner_forms, which is a list of UFL forms used to define the preconditioner matrices for solving the respective PDEs.Added different mesh conversion modes for
cashocs.convert(), which are"physical","geometrical", and"none". These are used to either use the physical or geometrical entities of Gmsh for the definition of the boundaries and subdomains (or neither of these).Changed configuration file parameters
Section OptimizationRoutine
maximum_iterationsis now calledmax_iter
Section Output
save_pvdis now calledsave_state, functionality is the samesave_pvd_adjointis now calledsave_adjoint, functionality is the samesave_pvd_gradientis now calledsave_gradient, functionality is the same
Section LineSearch
The parameters
initial_stepsize,epsilon_armijo,beta_armijo, andsafeguard_stepsizeare moved from the OptimizationRoutine section to the LineSearch section. Their behavior is unaltered.
New configuration file parameters
Section AlgoLBFGS
bfgs_periodic_restartis an integer parameter. If this is 0 (the default), no restarting is done. If this is >0, then the BFGS method is restarted after as many iterations, as given in the parameterdampedis a boolean flag which indicates, whether damping should be used for the BFGS method. The default isdamped = False.
Section LineSearch is a completely new section where the line searches can be configured.
methodis a string parameter, which can take the valuesmethod = armijo(which is the default previous line search) andmethod = polynomial(which are the new models)polynomial_modelis a string parameter which can be eitherpolynomial_model = quadraticorpolynomial_model = cubic. In case this ispolynomial_model = quadratic, three values (current function value, directional derivative, and trial function value) are used to generate a quadratic model of the one-dimensional cost functional. If this ispolynmomial_model = cubic, a cubic model is generated based on the last two guesses for the stepsize. These models are exactly minimized to get a new trial stepsize and a safeguarding is applied so that the steps remain feasible.factor_highis one parameter for the safeguarding, the upper bound for the search interval for the stepsize (this is multiplied with the previous stepsize)factor_lowis the other parameter for the safeguarding, the lower bound for the search interval for the stepsize (this is multiplied with the previous stepsize)
Section Output
precisionis an integer which specifies the precision (number of significant digits) when printing to console or file. Default is, as before, 3 significant digits.
1.8.0 (July 6, 2022)#
cashocs now has a better memory efficiency
The printing and file output of cashocs has been modified to better readable and fit the default console window
The ksp keyword argument for solver routines in the
_utilsmodule has been removed. Now, KSP objects can be interfaced only directly viaksp_optionsRename the default branch from “master” to “main”
Implement the “guard against poor scaling” for the stepsize computation from Kelley, but only for the initial stepsize
New configuration file parameters
Section OptimizationRoutine
safeguard_stepsizeis a boolean parameter which dis-/enables the guard against poor scaling for the initial iteration
1.7.0 (April 20, 2022)#
MPI Support - cashocs now has full MPI support. All of its features, including remeshing, now work out of the box in parallel. Nearly any script using cashocs can be run in parallel by invoking it via
mpirun -n p python script.py, wherepis the number of MPI processes. Note, that running in parallel may sometimes cause unexpected behavior as it is not tested as well as the serial usage. If you should encounter any bugs, please report them.
1.6.0 (April 4, 2022)#
Added the possibility to define additional constraints for the optimization problems as well as solvers which can be used to solve these new problems. This includes Augmented Lagrangian and Quadratic Penalty methods. This feature is documented at https://cashocs.readthedocs.io/en/stable/user/demos/optimal_control/demo_constraints.
Added the possibility for users to execute their own code before each solution of the state system or after each computation of the gradient with the help of
inject_pre_callbackandinject_post_callback. This is documented at https://cashocs.readthedocs.io/en/stable/user/demos/optimal_control/demo_pre_post_callbacks.Added the possibility to define boundary conditions for control variables. This is documented at https://cashocs.readthedocs.io/en/stable/user/demos/optimal_control/demo_control_boundary_conditions.
Added new style cost functionals, namely
cashocs.IntegralFunctional,cashocs.ScalarTrackingFunctionalandcashocs.MinMaxFunctional. These allow for a clearer definition of cost functionals and will replace the keyword argumentsscalar_tracking_formsandmin_max_termsin the future. The new style cost functionals allow for greater flexibility and extensibility in the future.Added the possibility to choose between a direct and iterative solver for computing (shape) gradients.
Reworked the private interface of cashocs for better extensibility. The
utilssubmodule is now private. Added a newcashocs.iosubmodule for handling in- and output.Reworked the way configuration files are treated in cashocs. Now, they are validated and an exception is raised if a config is found to be invalid.
New configuration file parameters:
Section OptimizationRoutine
gradient_methodis eithergradient_method = directorgradient_method = iterativeand specifies that the corresponding type of solver is used to compute the gradient.gradient_tolspecifies the tolerance which is used in case an iterative solver is used to compute the (shape) gradient.
1.5.0 (December 22, 2021)#
Major performance increase (particularly for large problems)
Added support for using the p-Laplacian to compute the shape gradient.
cashocs now also imports Gmsh Physical Group information when it is given by strings, which can be used in integration measures (e.g.,
dx('part1')ords('inlet'), or for creating Dirichlet boundary conditions (e.g.cashocs.create_dirichlet_bcs(V, Constant(0.0), boundaries, 'dirichlet_boundary')).The nonlinear solver (Newton’s method) got an additional
inexactparameter, which allows users to use an inexact Newton’s method with iterative solvers. Additionally, users can specify their own Jacobians to be used in Newton’s method with the keyword argumentdF.Users can now specify the weight of the scalar tracking terms individually (this is now documented).
New configuration file parameters:
Section ShapeGradient
use_p_laplacianis a boolean flag which enables the use of the p-Laplacian for the computation of the shape gradientp_laplacian_poweris an integer parameter specifying the power p used for the p-Laplacianp_laplacian_stabilizationis a float parameter, which acts as stabilization term for the p-Laplacian. This should be positive and small (e.g. 1e-3).update_inhomogeneousis a boolean parameter, which allows to update the cell volume when usinginhomogeneous = Truein the ShapeGradient section. This makes small elements have a higher stiffness and updates this over the course of the optimization. Default isupdate_inhomogeneous = False
1.4.0 (September 3, 2021)#
Added the possibility to compute the stiffness for the shape gradient based on the distance to the boundary using the eikonal equation
Cashocs now supports the tracking of scalar quantities, which are given as integrals of the states / controls / geometric properties. Input parameter is
scalar_tracking_forms, which is a dictionary consisting of'integrand', which is the integrand of the scalar quantity, and'tracking_goal', which is the (scalar) value that shall be achieved. This feature is documented at https://cashocs.readthedocs.io/en/stable/user/demos/optimal_control/demo_scalar_control_tracking.Fixed a bug concerning cashocs’ memory management, which would occur if several OptimizationProblems were created one after the other
Changed the coding style to “black”
Switched printing to f-string syntax for better readability
Config files are now copied when they are passed to OptimizationProblems, so that manipulation of them is only possible before the instance is created
New configuration file parameters:
Section ShapeGradient
use_distance_muis a boolean flag which enables stiffness computation based on distancesdist_minanddist_maxdescribe the minimal and maximum distance to the boundary for which a certain stiffness is used (see below)mu_minandmu_maxdescribe the stiffness values: If the boundary distance is smaller thandist_min, thenmu = mu_minand if the distance is larger thandist_max, we havemu = mu_maxsmooth_muis a boolean flag, which determines howmuis interpolated betweendist_minanddist_max: If this is set to False, linear interpolation is used, otherwise, a cubic spline is usedboundaries_distis a list of boundary indices to which the distance shall be computed
Small bugfixes and other improvements:
Switched to pseudo random numbers for the tests for the sake of reproduceability
fixed some tolerances for the tests
replaced
os.system()calls bysubprocess.run()
1.3.0 (June 11, 2021)#
Improved the remeshing workflow and fixed several smaller bugs concerning it
New configuration file parameters:
Section Output
save_pvd_adjointis a boolean flag which allows users to also save adjoint states in paraview formatsave_pvd_gradientis a boolean flag which allows users to save the (shape) gradient(s) in paraview formatsave_txtis a boolean flag, which allows users to capture the command line output as .txt file
1.2.0 (December 01, 2020)#
Users can now supply their own bilinear form (or scalar product) for the computation of the shape gradient, which is then used instead of the linear elasticity formulation. This is documented at https://cashocs.readthedocs.io/en/stable/user/demos/shape_optimization/demo_custom_scalar_product.
Added a curvature regularization term for shape optimization, which can be enabled via the config files, similarly to already implemented regularizations. This is documented at https://cashocs.readthedocs.io/en/stable/user/demos/shape_optimization/demo_regularization.
cashocs can now scale individual terms of the cost functional if this is desired. This allows for a more granular handling of problems with cost functionals consisting of multiple terms. This also extends to the regularizations for shape optimization, see https://cashocs.readthedocs.io/en/stable/user/demos/shape_optimization/demo_regularization. This feature is documented at https://cashocs.readthedocs.io/en/stable/user/demos/shape_optimization/demo_scaling.
cashocs now uses the logging module to issue messages for the user. The level of verbosity can be controlled via
cashocs.set_log_level().New configuration file parameters:
Section Regularization:
factor_curvaturecan be used to specify the weight for the curvature regularization term.use_relative_weightsis a boolean which specifies, whether the weights should be used as scaling factor in front of the regularization terms (if this is False), or whether they should be used to scale the regularization terms so that they have the prescribed value on the initial iteration (if this is True).
1.1.0 (November 13, 2020)#
Added the functionality for cashocs to be used as a solver only, where users can specify their custom adjoint equations and (shape) derivatives for the optimization problems. This is documented at https://cashocs.readthedocs.io/en/stable/user/demos/cashocs_as_solver/index.
Using
cashocs.create_config()is deprecated and replaced bycashocs.load_config(), but the former will still be supported.Configuration files are now not strictly necessary, but still very strongly recommended.
New configuration file parameters:
Section Output:
result_dircan be used to specify where cashocs’ output files should be placed.
1.0.0 (September 18, 2020)#
Initial release of cashocs.