openmdao/devtools/problem_viewer/problem_viewer.py
def _get_tree_dict(system, component_execution_orders, component_execution_index):
    """Get a dictionary representation of the system hierarchy."""
    tree_dict = OrderedDict()
    tree_dict['name'] = system.name
    tree_dict['type'] = 'subsystem'

    if not isinstance(system, Group):
        tree_dict['subsystem_type'] = 'component'
        component_execution_orders[system.pathname] = component_execution_index[0]
        component_execution_index[0] += 1

        children = []
        for typ in ['input', 'output']:
            for ind, abs_name in enumerate(system._var_abs_names[typ]):
                meta = system._var_abs2meta[abs_name]
                name = system._var_abs2prom[typ][abs_name]

                var_dict = OrderedDict()
                var_dict['name'] = name
                if typ == 'input':
                    var_dict['type'] = 'param'
                elif typ == 'output':
                    isimplicit = isinstance(system, ImplicitComponent)
                    var_dict['type'] = 'unknown'
                    var_dict['implicit'] = isimplicit

                var_dict['dtype'] = type(meta['value']).__name__
                children.append(var_dict)
    else:
        tree_dict['subsystem_type'] = 'group'
        children = [_get_tree_dict(s, component_execution_orders, component_execution_index)
                    for s in system._subsystems_myproc]
        if system.comm.size > 1:
            if system._subsystems_myproc:
                sub_comm = system._subsystems_myproc[0].comm
                if sub_comm.rank != 0:
                    children = []
            children_lists = system.comm.allgather(children)

            children = []
            for children_list in children_lists:
                children.extend(children_list)

    if isinstance(system, ImplicitComponent):
        if overrides_method('solve_linear', system, ImplicitComponent):
            tree_dict['linear_solver'] = "solve_linear"
        else:
            tree_dict['linear_solver'] = ""
    else:
        if system.linear_solver:
            tree_dict['linear_solver'] = system.linear_solver.SOLVER
        else:
            tree_dict['linear_solver'] = ""

    if isinstance(system, ImplicitComponent):
        if overrides_method('solve_nonlinear', system, ImplicitComponent):
            tree_dict['nonlinear_solver'] = "solve_nonlinear"
        else:
            tree_dict['nonlinear_solver'] = ""
    else:
        if system.nonlinear_solver:
            tree_dict['nonlinear_solver'] = system.nonlinear_solver.SOLVER
        else:
            tree_dict['nonlinear_solver'] = ""

    tree_dict['children'] = children

    if not tree_dict['name']:
        tree_dict['name'] = 'root'
        tree_dict['type'] = 'root'


    return tree_dict
Get a dictionary representation of the system hierarchy.
Get a dictionary representation of the system hierarchy.
Get a dictionary representation of the system hierarchy .
def _get_tree_dict(system, component_execution_orders, component_execution_index):
    tree_dict = OrderedDict()
    tree_dict['name'] = system.name
    tree_dict['type'] = 'subsystem'
    if not isinstance(system, Group):
        tree_dict['subsystem_type'] = 'component'
        component_execution_orders[system.pathname] = component_execution_index[0]
        component_execution_index[0] += 1
        children = []
        for typ in ['input', 'output']:
            for ind, abs_name in enumerate(system._var_abs_names[typ]):
                meta = system._var_abs2meta[abs_name]
                name = system._var_abs2prom[typ][abs_name]
                var_dict = OrderedDict()
                var_dict['name'] = name
                if typ == 'input':
                    var_dict['type'] = 'param'
                elif typ == 'output':
                    isimplicit = isinstance(system, ImplicitComponent)
                    var_dict['type'] = 'unknown'
                    var_dict['implicit'] = isimplicit
                var_dict['dtype'] = type(meta['value']).__name__
                children.append(var_dict)
    else:
        tree_dict['subsystem_type'] = 'group'
        children = [_get_tree_dict(s, component_execution_orders, component_execution_index)
                    for s in system._subsystems_myproc]
        if system.comm.size > 1:
            if system._subsystems_myproc:
                sub_comm = system._subsystems_myproc[0].comm
                if sub_comm.rank != 0:
                    children = []
            children_lists = system.comm.allgather(children)
            children = []
            for children_list in children_lists:
                children.extend(children_list)
    if isinstance(system, ImplicitComponent):
        if overrides_method('solve_linear', system, ImplicitComponent):
            tree_dict['linear_solver'] = "solve_linear"
        else:
            tree_dict['linear_solver'] = ""
    else:
        if system.linear_solver:
            tree_dict['linear_solver'] = system.linear_solver.SOLVER
        else:
            tree_dict['linear_solver'] = ""
    if isinstance(system, ImplicitComponent):
        if overrides_method('solve_nonlinear', system, ImplicitComponent):
            tree_dict['nonlinear_solver'] = "solve_nonlinear"
        else:
            tree_dict['nonlinear_solver'] = ""
    else:
        if system.nonlinear_solver:
            tree_dict['nonlinear_solver'] = system.nonlinear_solver.SOLVER
        else:
            tree_dict['nonlinear_solver'] = ""
    tree_dict['children'] = children
    if not tree_dict['name']:
        tree_dict['name'] = 'root'
        tree_dict['type'] = 'root'
    return tree_dict
def _get_tree_dict ( system , component_execution_orders , component_execution_index ) : tree_dict = OrderedDict ( ) tree_dict [ 'name' ] = system . name tree_dict [ 'type' ] = 'subsystem' if not isinstance ( system , Group ) : tree_dict [ 'subsystem_type' ] = 'component' component_execution_orders [ system . pathname ] = component_execution_index [ 0 ] component_execution_index [ 0 ] += 1 children = [ ] for typ in [ 'input' , 'output' ] : for ind , abs_name in enumerate ( system . _var_abs_names [ typ ] ) : meta = system . _var_abs2meta [ abs_name ] name = system . _var_abs2prom [ typ ] [ abs_name ] var_dict = OrderedDict ( ) var_dict [ 'name' ] = name if typ == 'input' : var_dict [ 'type' ] = 'param' elif typ == 'output' : isimplicit = isinstance ( system , ImplicitComponent ) var_dict [ 'type' ] = 'unknown' var_dict [ 'implicit' ] = isimplicit var_dict [ 'dtype' ] = type ( meta [ 'value' ] ) . __name__ children . append ( var_dict ) else : tree_dict [ 'subsystem_type' ] = 'group' children = [ _get_tree_dict ( s , component_execution_orders , component_execution_index ) for s in system . _subsystems_myproc ] if system . comm . size > 1 : if system . _subsystems_myproc : sub_comm = system . _subsystems_myproc [ 0 ] . comm if sub_comm . rank != 0 : children = [ ] children_lists = system . comm . allgather ( children ) children = [ ] for children_list in children_lists : children . extend ( children_list ) if isinstance ( system , ImplicitComponent ) : if overrides_method ( 'solve_linear' , system , ImplicitComponent ) : tree_dict [ 'linear_solver' ] = "solve_linear" else : tree_dict [ 'linear_solver' ] = "" else : if system . linear_solver : tree_dict [ 'linear_solver' ] = system . linear_solver . SOLVER else : tree_dict [ 'linear_solver' ] = "" if isinstance ( system , ImplicitComponent ) : if overrides_method ( 'solve_nonlinear' , system , ImplicitComponent ) : tree_dict [ 'nonlinear_solver' ] = "solve_nonlinear" else : tree_dict [ 'nonlinear_solver' ] = "" else : if system . nonlinear_solver : tree_dict [ 'nonlinear_solver' ] = system . nonlinear_solver . SOLVER else : tree_dict [ 'nonlinear_solver' ] = "" tree_dict [ 'children' ] = children if not tree_dict [ 'name' ] : tree_dict [ 'name' ] = 'root' tree_dict [ 'type' ] = 'root' return tree_dict
Get a dictionary representation of the system hierarchy.
Get a dictionary representation of the system hierarchy .
"""Get a dictionary representation of the system hierarchy."""
system
component_execution_orders
component_execution_index