-
Notifications
You must be signed in to change notification settings - Fork 240
/
LinearSolver_template
70 lines (53 loc) · 1.94 KB
/
LinearSolver_template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from openmdao.solvers.solver import LinearSolver
class {class_name}(LinearSolver):
"""
{class_name} solver.
Describe the solver here...
"""
SOLVER = 'LN: ????' # replace ???? with an abbreviated solver name
def __init__(self, **kwargs):
"""
Initialize all attributes.
Parameters
----------
**kwargs : dict
Options dictionary.
"""
super({class_name}, self).__init__(**kwargs)
# initialize needed atributes here...
def _setup_solvers(self, system, depth):
"""
Assign system instance, set depth, and optionally perform setup.
Parameters
----------
system : <System>
pointer to the owning system.
depth : int
depth of the current system (already incremented).
"""
super({class_name}, self)._setup_solvers(system, depth)
# perform any necessary setup here...
def _declare_options(self):
"""
Declare options before kwargs are processed in the init method.
"""
super({class_name}, self)._declare_options()
# for example...
# self.options.declare('cs_reconverge', types=bool, default=True,
# desc='When True, when this driver solves under a complex step, nudge '
# 'the Solution vector by a small amount so that it reconverges.')
def solve(self, vec_names, mode, rel_systems=None):
"""
Solve the linear system for the problem in self._system().
The full solution vector is returned.
Parameters
----------
vec_names : list
list of vector names.
mode : string
Derivative mode, can be 'fwd' or 'rev'.
rel_systems : set of str
Set of names of relevant systems based on the current linear solve.
"""
# solver the linear system here...
pass