solver.py

Define the base Solver, NonlinearSolver, and LinearSolver classes.

class openmdao.solvers.solver.BlockLinearSolver(**kwargs)[source]

Bases: openmdao.solvers.solver.LinearSolver

A base class for LinearBlockGS and LinearBlockJac.

SOLVER = 'base_solver'
__init__(self, **kwargs)

Initialize all attributes.

Parameters
**kwargsdict

options dictionary.

add_recorder(self, recorder)

Add a recorder to the solver’s RecordingManager.

Parameters
recorder<CaseRecorder>

A recorder instance to be added to RecManager.

cleanup(self)

Clean up resources prior to exit.

property msginfo

Return info to prepend to messages.

Returns
str

Info to prepend to messages.

record_iteration(self, **kwargs)

Record an iteration of the current Solver.

Parameters
**kwargsdict

Keyword arguments (used for abs and rel error).

solve(self, vec_names, mode, rel_systems=None)[source]

Run the solver.

Parameters
vec_names[str, …]

list of names of the right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

rel_systemsset of str

Set of names of relevant systems based on the current linear solve.

class openmdao.solvers.solver.LinearSolver(**kwargs)[source]

Bases: openmdao.solvers.solver.Solver

Base class for linear solvers.

SOLVER = 'base_solver'
__init__(self, **kwargs)[source]

Initialize all attributes.

Parameters
**kwargsdict

options dictionary.

add_recorder(self, recorder)[source]

Add a recorder to the solver’s RecordingManager.

Parameters
recorder<CaseRecorder>

A recorder instance to be added to RecManager.

cleanup(self)

Clean up resources prior to exit.

property msginfo

Return info to prepend to messages.

Returns
str

Info to prepend to messages.

record_iteration(self, **kwargs)

Record an iteration of the current Solver.

Parameters
**kwargsdict

Keyword arguments (used for abs and rel error).

solve(self, vec_names, mode, rel_systems=None)[source]

Run the solver.

Parameters
vec_names[str, …]

list of names of the right-hand-side vectors.

modestr

‘fwd’ or ‘rev’.

rel_systemsset of str

Set of names of relevant systems based on the current linear solve.

class openmdao.solvers.solver.NonlinearSolver(**kwargs)[source]

Bases: openmdao.solvers.solver.Solver

Base class for nonlinear solvers.

SOLVER = 'base_solver'
__init__(self, **kwargs)[source]

Initialize all attributes.

Parameters
**kwargsdict

options dictionary.

add_recorder(self, recorder)

Add a recorder to the solver’s RecordingManager.

Parameters
recorder<CaseRecorder>

A recorder instance to be added to RecManager.

cleanup(self)

Clean up resources prior to exit.

property msginfo

Return info to prepend to messages.

Returns
str

Info to prepend to messages.

record_iteration(self, **kwargs)

Record an iteration of the current Solver.

Parameters
**kwargsdict

Keyword arguments (used for abs and rel error).

solve(self)[source]

Run the solver.

class openmdao.solvers.solver.Solver(**kwargs)[source]

Bases: object

Base solver class.

This class is subclassed by NonlinearSolver and LinearSolver, which are in turn subclassed by actual solver implementations.

Attributes

cite

(str) Listing of relevant citations that should be referenced when publishing work that uses this class.

options

(<OptionsDictionary>) Options dictionary.

recording_options

(<OptionsDictionary>) Recording options dictionary.

supports

(<OptionsDictionary>) Options dictionary describing what features are supported by this solver.

SOLVER = 'base_solver'
__init__(self, **kwargs)[source]

Initialize all attributes.

Parameters
**kwargsdict of keyword arguments

Keyword arguments that will be mapped into the Solver options.

add_recorder(self, recorder)[source]

Add a recorder to the solver’s RecordingManager.

Parameters
recorder<CaseRecorder>

A recorder instance to be added to RecManager.

cleanup(self)[source]

Clean up resources prior to exit.

property msginfo

Return info to prepend to messages.

Returns
str

Info to prepend to messages.

record_iteration(self, **kwargs)[source]

Record an iteration of the current Solver.

Parameters
**kwargsdict

Keyword arguments (used for abs and rel error).

class openmdao.solvers.solver.SolverInfo[source]

Bases: object

Communal object for storing some formatting for solver iprint.

Attributes

prefix

(str) Prefix to prepend during this iprint.

stack

(List) List of strings; strings are popped and appended as needed.

__init__(self)[source]

Initialize.

append_precon(self)[source]

Add a new level for any preconditioner to a linear solver.

append_solver(self)[source]

Add a new level for the main solver in a group.

append_subsolver(self)[source]

Add a new level for any sub-solver for your solver.

clear(self)[source]

Clear out the iprint stack, in case something is left over from a handled exception.

pop(self)[source]

Remove one level of solver depth in the printing.

restore_cache(self, cache)[source]

Restore previously saved iprint stack names.

Parameters
cachetuple(str, list)

cache of current stack

save_cache(self)[source]

Save prefix and stack so that they can be restored later in event of an exception recovery.

Returns
tuple(str, list)

cache of current stack