cashocs.space_mapping.shape_optimization.CoarseModel#
- class cashocs.space_mapping.shape_optimization.CoarseModel(state_forms: ufl.Form | list[ufl.Form], bcs_list: fenics.DirichletBC | list[fenics.DirichletBC] | list[list[fenics.DirichletBC]] | None, cost_functional_form: list[_typing.CostFunctional] | _typing.CostFunctional, states: fenics.Function | list[fenics.Function], adjoints: fenics.Function | list[fenics.Function], boundaries: fenics.MeshFunction, config: io.Config | None = None, shape_scalar_product: ufl.Form | None = None, initial_guess: list[fenics.Function] | None = None, ksp_options: _typing.KspOption | list[_typing.KspOption] | None = None, adjoint_ksp_options: _typing.KspOption | list[_typing.KspOption] | None = None, gradient_ksp_options: _typing.KspOption | list[_typing.KspOption] | None = None, desired_weights: list[float] | None = None, preconditioner_forms: list[ufl.Form] | None = None, pre_callback: Callable | None = None, post_callback: Callable | None = None, linear_solver: _utils.linalg.LinearSolver | None = None, adjoint_linear_solver: _utils.linalg.LinearSolver | None = None, newton_linearizations: ufl.Form | list[ufl.Form] | None = None, excluded_from_time_derivative: list[int] | list[list[int]] | None = None)[source]#
Bases:
object
Coarse Model for space mapping shape optimization.
Initializes self.
- Parameters:
state_forms (ufl.Form | list[ufl.Form]) – The list of weak forms for the coarse state problem
bcs_list (fenics.DirichletBC | list[fenics.DirichletBC] | list[list[fenics.DirichletBC]] | None) – The list of boundary conditions for the coarse problem
cost_functional_form (list[_typing.CostFunctional] | _typing.CostFunctional) – The cost functional for the coarse problem
states (fenics.Function | list[fenics.Function]) – The state variables for the coarse problem
adjoints (fenics.Function | list[fenics.Function]) – The adjoint variables for the coarse problem
boundaries (fenics.MeshFunction) – A fenics MeshFunction which marks the boundaries.
config (io.Config | None) – config: The config file for the problem, generated via
cashocs.load_config()
. Alternatively, this can also beNone
, in which case the default configurations are used, except for the optimization algorithm. This has then to be specified in thesolve
method. The default isNone
.shape_scalar_product (ufl.Form | None) – The scalar product for the shape optimization problem
initial_guess (list[fenics.Function] | None) – The initial guess for solving a nonlinear state equation
ksp_options (_typing.KspOption | list[_typing.KspOption] | None) – The list of PETSc options for the state equations.
adjoint_ksp_options (_typing.KspOption | list[_typing.KspOption] | None) – The list of PETSc options for the adjoint equations.
gradient_ksp_options (_typing.KspOption | list[_typing.KspOption] | None) – A list of dicts corresponding to command line options for PETSc, used to compute the (shape) gradient. If this is
None
, either a direct or an iterative method is used (depending on the configuration, section OptimizationRoutine, key gradient_method).desired_weights (list[float] | None) – The desired weights for the cost functional
preconditioner_forms (list[ufl.Form] | None) – The list of forms for the preconditioner. The default is None, so that the preconditioner matrix is the same as the system matrix.
pre_callback (Callable | None) – A function (without arguments) that will be called before each solve of the state system
post_callback (Callable | None) – A function (without arguments) that will be called after the computation of the gradient.
linear_solver (_utils.linalg.LinearSolver | None) – The linear solver (KSP) which is used to solve the linear systems arising from the discretized PDE.
adjoint_linear_solver (_utils.linalg.LinearSolver | None) – The linear solver (KSP) which is used to solve the (linear) adjoint system.
newton_linearizations (ufl.Form | list[ufl.Form] | None) – A (list of) UFL forms describing which (alternative) linearizations should be used for the (nonlinear) state equations when solving them (with Newton’s method). The default is None, so that the Jacobian of the supplied state forms is used.
excluded_from_time_derivative (list[int] | list[list[int]] | None) – For each state equation, a list of indices which are not part of the first order time derivative for pseudo time stepping. Example: Pressure for incompressible flow. Default is None.
Methods Summary
optimize
()Solves the coarse model optimization problem.
Methods Documentation