cashocs.space_mapping.shape_optimization.SpaceMappingProblem#
- class cashocs.space_mapping.shape_optimization.SpaceMappingProblem(
- fine_model: FineModel,
- coarse_model: CoarseModel,
- parameter_extraction: ParameterExtraction,
- method: Literal['broyden', 'bfgs', 'lbfgs', 'sd', 'steepest_descent', 'ncg'] = 'broyden',
- max_iter: int = 25,
- tol: float = 0.01,
- use_backtracking_line_search: bool = False,
- broyden_type: Literal['good', 'bad'] = 'good',
- cg_type: Literal['FR', 'PR', 'HS', 'DY', 'HZ'] = 'FR',
- memory_size: int = 10,
- verbose: bool = True,
- save_history: bool = False,
Bases:
objectSpace mapping method for shape optimization.
Initializes self.
- Parameters:
fine_model (FineModel) – The fine model optimization problem
coarse_model (CoarseModel) – The coarse model optimization problem
parameter_extraction (ParameterExtraction) – The parameter extraction problem
method (Literal['broyden', 'bfgs', 'lbfgs', 'sd', 'steepest_descent', 'ncg']) – A string, which indicates which method is used to solve the space mapping. Can be one of “broyden”, “bfgs”, “lbfgs”, “sd”, “steepest descent”, or “ncg”. Default is “broyden”.
max_iter (int) – Maximum number of space mapping iterations
tol (float) – The tolerance used for solving the space mapping iteration
use_backtracking_line_search (bool) – A boolean flag, which indicates whether a backtracking line search should be used for the space mapping.
broyden_type (Literal['good', 'bad']) – A string, either “good” or “bad”, determining the type of Broyden’s method used. Default is “good”
cg_type (Literal['FR', 'PR', 'HS', 'DY', 'HZ']) – A string, either “FR”, “PR”, “HS”, “DY”, “HZ”, which indicates which NCG variant is used for solving the space mapping. Default is “FR”
memory_size (int) – The size of the memory for Broyden’s method and the BFGS method
verbose (bool) – A boolean flag which indicates, whether the output of the space mapping method should be verbose. Default is
True.save_history (bool) – A boolean flag which indicates, whether the history of the space mapping method should be saved to a .json file. Default is
False.
Methods Summary
inject_post_callback(function)Changes the a-posteriori callback of the OptimizationProblem.
inject_pre_callback(function)Changes the a-priori callback of the OptimizationProblem.
inject_pre_post_callback(pre_function, ...)Changes the a-priori (pre) and a-posteriori (post) callbacks of the problem.
output()Uses the output manager to save / show the current results.
Smooths a deformation vector field with a Poincaré-Steklov operator.
solve()Solves the problem with the space mapping method.
Tests, whether maximum number of iterations are exceeded.
Methods Documentation
- inject_post_callback(
- function: Callable | None,
Changes the a-posteriori callback of the OptimizationProblem.
- Parameters:
function (Callable | None) – A custom function without arguments, which will be called after the computation of the gradient(s)
- Return type:
None
- inject_pre_callback(
- function: Callable | None,
Changes the a-priori callback of the OptimizationProblem.
- Parameters:
function (Callable | None) – A custom function without arguments, which will be called before each solve of the state system
- Return type:
None
- inject_pre_post_callback(
- pre_function: Callable | None,
- post_function: Callable | None,
Changes the a-priori (pre) and a-posteriori (post) callbacks of the problem.
- Parameters:
pre_function (Callable | None) – A function without arguments, which is to be called before each solve of the state system
post_function (Callable | None) – A function without arguments, which is to be called after each computation of the (shape) gradient
- Return type:
None
- output() None[source]#
Uses the output manager to save / show the current results.
- Return type:
None
- smooth_deformation(
- a: list[fenics.Function],
Smooths a deformation vector field with a Poincaré-Steklov operator.
- Parameters:
a (list[fenics.Function]) – The deformation vector field
- Returns:
A smoothed deformation vector field, for the use in the scalar product.
- Return type:
list[fenics.Function]