openmdao/core/group.py
def _setup_var_data(self, recurse=True):
        """
        Compute the list of abs var names, abs/prom name maps, and metadata dictionaries.

        Parameters
        ----------
        recurse : bool
            Whether to call this method in subsystems.
        """
        super(Group, self)._setup_var_data()
        allprocs_abs_names = self._var_allprocs_abs_names
        allprocs_discrete = self._var_allprocs_discrete
        abs_names = self._var_abs_names
        var_discrete = self._var_discrete
        allprocs_prom2abs_list = self._var_allprocs_prom2abs_list
        abs2prom = self._var_abs2prom
        allprocs_abs2meta = self._var_allprocs_abs2meta
        abs2meta = self._var_abs2meta

        # Recursion
        if recurse:
            for subsys in self._subsystems_myproc:
                subsys._setup_var_data(recurse)
                self._has_output_scaling |= subsys._has_output_scaling
                self._has_resid_scaling |= subsys._has_resid_scaling

        for subsys in self._subsystems_myproc:
            var_maps = subsys._get_maps(subsys._var_allprocs_prom2abs_list)

            # Assemble allprocs_abs2meta and abs2meta
            allprocs_abs2meta.update(subsys._var_allprocs_abs2meta)
            abs2meta.update(subsys._var_abs2meta)

            sub_prefix = subsys.name + '.'

            for type_ in ['input', 'output']:

                # Assemble abs_names and allprocs_abs_names
                allprocs_abs_names[type_].extend(subsys._var_allprocs_abs_names[type_])
                allprocs_discrete[type_].update({k: v for k, v in
                                                 iteritems(subsys._var_allprocs_discrete[type_])})
                abs_names[type_].extend(subsys._var_abs_names[type_])
                var_discrete[type_].update({sub_prefix + k: v for k, v in
                                            iteritems(subsys._var_discrete[type_])})

                # Assemble abs2prom
                for abs_name in subsys._var_abs_names[type_]:
                    sub_prom_name = subsys._var_abs2prom[type_][abs_name]
                    abs2prom[type_][abs_name] = var_maps[type_][sub_prom_name]

                # Assemble allprocs_prom2abs_list
                for sub_prom, sub_abs in iteritems(subsys._var_allprocs_prom2abs_list[type_]):
                    prom_name = var_maps[type_][sub_prom]
                    if prom_name not in allprocs_prom2abs_list[type_]:
                        allprocs_prom2abs_list[type_][prom_name] = []
                    allprocs_prom2abs_list[type_][prom_name].extend(sub_abs)

        for prom_name, abs_list in iteritems(allprocs_prom2abs_list['output']):
            if len(abs_list) > 1:
                raise RuntimeError("Output name '%s' refers to "
                                   "multiple outputs: %s." %
                                   (prom_name, sorted(abs_list)))

        # If running in parallel, allgather
        if self.comm.size > 1:
            mysub = self._subsystems_myproc[0] if self._subsystems_myproc else False
            if (mysub and mysub.comm.rank == 0 and (mysub._full_comm is None or
                                                    mysub._full_comm.rank == 0)):
                raw = (allprocs_abs_names, allprocs_discrete, allprocs_prom2abs_list,
                       allprocs_abs2meta, self._has_output_scaling, self._has_resid_scaling)
            else:
                raw = (
                    {'input': [], 'output': []},
                    {'input': {}, 'output': {}},
                    {'input': {}, 'output': {}},
                    {'input': {}, 'output': {}},
                    False,
                    False
                )
            gathered = self.comm.allgather(raw)

            for type_ in ['input', 'output']:
                allprocs_abs_names[type_] = []
                allprocs_prom2abs_list[type_] = OrderedDict()

            for (myproc_abs_names, myproc_discrete, myproc_prom2abs_list, myproc_abs2meta,
                 oscale, rscale) in gathered:
                self._has_output_scaling |= oscale
                self._has_resid_scaling |= rscale

                # Assemble in parallel allprocs_abs2meta
                allprocs_abs2meta.update(myproc_abs2meta)

                for type_ in ['input', 'output']:

                    # Assemble in parallel allprocs_abs_names
                    allprocs_abs_names[type_].extend(myproc_abs_names[type_])
                    allprocs_discrete[type_].update(myproc_discrete[type_])

                    # Assemble in parallel allprocs_prom2abs_list
                    for prom_name, abs_names_list in iteritems(myproc_prom2abs_list[type_]):
                        if prom_name not in allprocs_prom2abs_list[type_]:
                            allprocs_prom2abs_list[type_][prom_name] = []
                        allprocs_prom2abs_list[type_][prom_name].extend(abs_names_list)

        if self._var_discrete['input'] or self._var_discrete['output']:
            self._discrete_inputs = _DictValues(self._var_discrete['input'])
            self._discrete_outputs = _DictValues(self._var_discrete['output'])
        else:
            self._discrete_inputs = self._discrete_outputs = ()

        Compute the list of abs var names, abs/prom name maps, and metadata dictionaries.

        Parameters
        ----------
        recurse : bool
            Whether to call this method in subsystems.
        
Compute the list of abs var names, abs/prom name maps, and metadata dictionaries.
Parameters

recurse : bool
Whether to call this method in subsystems.
Compute the list of abs var names abs / prom name maps and metadata dictionaries . Parameters recurse : bool Whether to call this method in subsystems .
def _setup_var_data(self, recurse=True):
        super(Group, self)._setup_var_data()
        allprocs_abs_names = self._var_allprocs_abs_names
        allprocs_discrete = self._var_allprocs_discrete
        abs_names = self._var_abs_names
        var_discrete = self._var_discrete
        allprocs_prom2abs_list = self._var_allprocs_prom2abs_list
        abs2prom = self._var_abs2prom
        allprocs_abs2meta = self._var_allprocs_abs2meta
        abs2meta = self._var_abs2meta
        if recurse:
            for subsys in self._subsystems_myproc:
                subsys._setup_var_data(recurse)
                self._has_output_scaling |= subsys._has_output_scaling
                self._has_resid_scaling |= subsys._has_resid_scaling
        for subsys in self._subsystems_myproc:
            var_maps = subsys._get_maps(subsys._var_allprocs_prom2abs_list)
            allprocs_abs2meta.update(subsys._var_allprocs_abs2meta)
            abs2meta.update(subsys._var_abs2meta)
            sub_prefix = subsys.name + '.'
            for type_ in ['input', 'output']:
                allprocs_abs_names[type_].extend(subsys._var_allprocs_abs_names[type_])
                allprocs_discrete[type_].update({k: v for k, v in
                                                 iteritems(subsys._var_allprocs_discrete[type_])})
                abs_names[type_].extend(subsys._var_abs_names[type_])
                var_discrete[type_].update({sub_prefix + k: v for k, v in
                                            iteritems(subsys._var_discrete[type_])})
                for abs_name in subsys._var_abs_names[type_]:
                    sub_prom_name = subsys._var_abs2prom[type_][abs_name]
                    abs2prom[type_][abs_name] = var_maps[type_][sub_prom_name]
                for sub_prom, sub_abs in iteritems(subsys._var_allprocs_prom2abs_list[type_]):
                    prom_name = var_maps[type_][sub_prom]
                    if prom_name not in allprocs_prom2abs_list[type_]:
                        allprocs_prom2abs_list[type_][prom_name] = []
                    allprocs_prom2abs_list[type_][prom_name].extend(sub_abs)
        for prom_name, abs_list in iteritems(allprocs_prom2abs_list['output']):
            if len(abs_list) > 1:
                raise RuntimeError("Output name '%s' refers to "
                                   "multiple outputs: %s." %
                                   (prom_name, sorted(abs_list)))
        if self.comm.size > 1:
            mysub = self._subsystems_myproc[0] if self._subsystems_myproc else False
            if (mysub and mysub.comm.rank == 0 and (mysub._full_comm is None or
                                                    mysub._full_comm.rank == 0)):
                raw = (allprocs_abs_names, allprocs_discrete, allprocs_prom2abs_list,
                       allprocs_abs2meta, self._has_output_scaling, self._has_resid_scaling)
            else:
                raw = (
                    {'input': [], 'output': []},
                    {'input': {}, 'output': {}},
                    {'input': {}, 'output': {}},
                    {'input': {}, 'output': {}},
                    False,
                    False
                )
            gathered = self.comm.allgather(raw)
            for type_ in ['input', 'output']:
                allprocs_abs_names[type_] = []
                allprocs_prom2abs_list[type_] = OrderedDict()
            for (myproc_abs_names, myproc_discrete, myproc_prom2abs_list, myproc_abs2meta,
                 oscale, rscale) in gathered:
                self._has_output_scaling |= oscale
                self._has_resid_scaling |= rscale
                allprocs_abs2meta.update(myproc_abs2meta)
                for type_ in ['input', 'output']:
                    allprocs_abs_names[type_].extend(myproc_abs_names[type_])
                    allprocs_discrete[type_].update(myproc_discrete[type_])
                    for prom_name, abs_names_list in iteritems(myproc_prom2abs_list[type_]):
                        if prom_name not in allprocs_prom2abs_list[type_]:
                            allprocs_prom2abs_list[type_][prom_name] = []
                        allprocs_prom2abs_list[type_][prom_name].extend(abs_names_list)
        if self._var_discrete['input'] or self._var_discrete['output']:
            self._discrete_inputs = _DictValues(self._var_discrete['input'])
            self._discrete_outputs = _DictValues(self._var_discrete['output'])
        else:
            self._discrete_inputs = self._discrete_outputs = ()
def _setup_var_data ( self , recurse = True ) : super ( Group , self ) . _setup_var_data ( ) allprocs_abs_names = self . _var_allprocs_abs_names allprocs_discrete = self . _var_allprocs_discrete abs_names = self . _var_abs_names var_discrete = self . _var_discrete allprocs_prom2abs_list = self . _var_allprocs_prom2abs_list abs2prom = self . _var_abs2prom allprocs_abs2meta = self . _var_allprocs_abs2meta abs2meta = self . _var_abs2meta if recurse : for subsys in self . _subsystems_myproc : subsys . _setup_var_data ( recurse ) self . _has_output_scaling |= subsys . _has_output_scaling self . _has_resid_scaling |= subsys . _has_resid_scaling for subsys in self . _subsystems_myproc : var_maps = subsys . _get_maps ( subsys . _var_allprocs_prom2abs_list ) allprocs_abs2meta . update ( subsys . _var_allprocs_abs2meta ) abs2meta . update ( subsys . _var_abs2meta ) sub_prefix = subsys . name + '.' for type_ in [ 'input' , 'output' ] : allprocs_abs_names [ type_ ] . extend ( subsys . _var_allprocs_abs_names [ type_ ] ) allprocs_discrete [ type_ ] . update ( { k : v for k , v in iteritems ( subsys . _var_allprocs_discrete [ type_ ] ) } ) abs_names [ type_ ] . extend ( subsys . _var_abs_names [ type_ ] ) var_discrete [ type_ ] . update ( { sub_prefix + k : v for k , v in iteritems ( subsys . _var_discrete [ type_ ] ) } ) for abs_name in subsys . _var_abs_names [ type_ ] : sub_prom_name = subsys . _var_abs2prom [ type_ ] [ abs_name ] abs2prom [ type_ ] [ abs_name ] = var_maps [ type_ ] [ sub_prom_name ] for sub_prom , sub_abs in iteritems ( subsys . _var_allprocs_prom2abs_list [ type_ ] ) : prom_name = var_maps [ type_ ] [ sub_prom ] if prom_name not in allprocs_prom2abs_list [ type_ ] : allprocs_prom2abs_list [ type_ ] [ prom_name ] = [ ] allprocs_prom2abs_list [ type_ ] [ prom_name ] . extend ( sub_abs ) for prom_name , abs_list in iteritems ( allprocs_prom2abs_list [ 'output' ] ) : if len ( abs_list ) > 1 : raise RuntimeError ( "Output name '%s' refers to " "multiple outputs: %s." % ( prom_name , sorted ( abs_list ) ) ) if self . comm . size > 1 : mysub = self . _subsystems_myproc [ 0 ] if self . _subsystems_myproc else False if ( mysub and mysub . comm . rank == 0 and ( mysub . _full_comm is None or mysub . _full_comm . rank == 0 ) ) : raw = ( allprocs_abs_names , allprocs_discrete , allprocs_prom2abs_list , allprocs_abs2meta , self . _has_output_scaling , self . _has_resid_scaling ) else : raw = ( { 'input' : [ ] , 'output' : [ ] } , { 'input' : { } , 'output' : { } } , { 'input' : { } , 'output' : { } } , { 'input' : { } , 'output' : { } } , False , False ) gathered = self . comm . allgather ( raw ) for type_ in [ 'input' , 'output' ] : allprocs_abs_names [ type_ ] = [ ] allprocs_prom2abs_list [ type_ ] = OrderedDict ( ) for ( myproc_abs_names , myproc_discrete , myproc_prom2abs_list , myproc_abs2meta , oscale , rscale ) in gathered : self . _has_output_scaling |= oscale self . _has_resid_scaling |= rscale allprocs_abs2meta . update ( myproc_abs2meta ) for type_ in [ 'input' , 'output' ] : allprocs_abs_names [ type_ ] . extend ( myproc_abs_names [ type_ ] ) allprocs_discrete [ type_ ] . update ( myproc_discrete [ type_ ] ) for prom_name , abs_names_list in iteritems ( myproc_prom2abs_list [ type_ ] ) : if prom_name not in allprocs_prom2abs_list [ type_ ] : allprocs_prom2abs_list [ type_ ] [ prom_name ] = [ ] allprocs_prom2abs_list [ type_ ] [ prom_name ] . extend ( abs_names_list ) if self . _var_discrete [ 'input' ] or self . _var_discrete [ 'output' ] : self . _discrete_inputs = _DictValues ( self . _var_discrete [ 'input' ] ) self . _discrete_outputs = _DictValues ( self . _var_discrete [ 'output' ] ) else : self . _discrete_inputs = self . _discrete_outputs = ( )
Compute the list of abs var names, abs/prom name maps, and metadata dictionaries.
Compute the list of abs var names abs / prom name maps and metadata dictionaries .
"""
        Compute the list of abs var names, abs/prom name maps, and metadata dictionaries.

        Parameters
        ----------
        recurse : bool
            Whether to call this method in subsystems.
        """ # Recursion # Assemble allprocs_abs2meta and abs2meta # Assemble abs_names and allprocs_abs_names # Assemble abs2prom # Assemble allprocs_prom2abs_list # If running in parallel, allgather # Assemble in parallel allprocs_abs2meta # Assemble in parallel allprocs_abs_names # Assemble in parallel allprocs_prom2abs_list
self
recurse