cashocs.space_mapping.optimal_control.CoarseModel#

class cashocs.space_mapping.optimal_control.CoarseModel(state_forms: list[ufl.Form] | ufl.Form, bcs_list: fenics.DirichletBC | list[fenics.DirichletBC] | list[list[fenics.DirichletBC]], cost_functional_form: list[_typing.CostFunctional] | _typing.CostFunctional, states: list[fenics.Function] | fenics.Function, controls: list[fenics.Function] | fenics.Function, adjoints: list[fenics.Function] | fenics.Function, config: io.Config | None = None, riesz_scalar_products: ufl.Form | list[ufl.Form] | None = None, control_constraints: list[list[float | fenics.Function]] | 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, control_bcs_list: list[list[fenics.DirichletBC]] | list[fenics.DirichletBC] | fenics.DirichletBC | 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 optimal control.

Initializes self.

Parameters:
  • state_forms (list[ufl.Form] | ufl.Form) – The list of weak forms for the coare state problem

  • bcs_list (fenics.DirichletBC | list[fenics.DirichletBC] | list[list[fenics.DirichletBC]]) – 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 (list[fenics.Function] | fenics.Function) – The state variables for the coarse problem

  • controls (list[fenics.Function] | fenics.Function) – The control variables for the coarse problem

  • adjoints (list[fenics.Function] | fenics.Function) – The adjoint variables for the coarse problem

  • config (io.Config | None) – config: The config file for the problem, generated via cashocs.load_config(). Alternatively, this can also be None, in which case the default configurations are used, except for the optimization algorithm. This has then to be specified in the solve method. The default is None.

  • riesz_scalar_products (ufl.Form | list[ufl.Form] | None) – The scalar products for the coarse problem

  • control_constraints (list[list[float | fenics.Function]] | None) – The box constraints for the 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.

  • control_bcs_list (list[list[fenics.DirichletBC]] | list[fenics.DirichletBC] | fenics.DirichletBC | None) – A list of boundary conditions for the control variables. This is passed analogously to bcs_list. Default is None.

  • 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

optimize() None[source]#

Solves the coarse model optimization problem.

Return type:

None