openmdao/core/group.py
def _discrete_transfer(self, isub):
        """
        Transfer discrete variables between components.  This only occurs in fwd mode.

        Parameters
        ----------
        isub : None or int
            If None, perform a full transfer.
            If int, perform a partial transfer for linear Gauss--Seidel.
        """
        comm = self.comm
        key = None if isub is None else self._subsystems_allprocs[isub].name

        if comm.size == 1:
            for src_sys_name, src, tgt_sys_name, tgt in self._discrete_transfers[key]:
                tgt_sys = self._loc_subsys_map[tgt_sys_name]
                src_sys = self._loc_subsys_map[src_sys_name]
                # note that we are not copying the discrete value here, so if the
                # discrete value is some mutable object, for example not an int or str,
                # the downstream system will have a reference to the same object
                # as the source, allowing the downstream system to modify the value as
                # seen by the source system.
                tgt_sys._discrete_inputs[tgt] = src_sys._discrete_outputs[src]

        else:  # MPI
            allprocs_recv = self._allprocs_discrete_recv[key]
            discrete_out = self._var_discrete['output']
            if key in self._discrete_transfers:
                xfers, remote_send = self._discrete_transfers[key]
                if allprocs_recv:
                    sendvars = [(n, discrete_out[n]['value']) for n in remote_send]
                    allprocs_send = comm.gather(sendvars, root=0)
                    if comm.rank == 0:
                        allprocs_dict = {}
                        for i in range(comm.size):
                            allprocs_dict.update(allprocs_send[i])
                        recvs = [{} for i in range(comm.size)]
                        for rname, ranks in iteritems(allprocs_recv):
                            val = allprocs_dict[rname]
                            for i in ranks:
                                recvs[i][rname] = val
                        data = comm.scatter(recvs, root=0)
                    else:
                        data = comm.scatter(None, root=0)
                else:
                    data = None

                for src_sys_name, src, tgt_sys_name, tgt in xfers:
                    if tgt_sys_name in self._loc_subsys_map:
                        tgt_sys = self._loc_subsys_map[tgt_sys_name]
                        if tgt in tgt_sys._discrete_inputs:
                            abs_src = '.'.join((src_sys_name, src))
                            if data is not None and abs_src in data:
                                src_val = data[abs_src]
                            else:
                                src_val = self._loc_subsys_map[src_sys_name]._discrete_outputs[src]
                            tgt_sys._discrete_inputs[tgt] = src_val

        Transfer discrete variables between components.  This only occurs in fwd mode.

        Parameters
        ----------
        isub : None or int
            If None, perform a full transfer.
            If int, perform a partial transfer for linear Gauss--Seidel.
        
Transfer discrete variables between components.  This only occurs in fwd mode.
Parameters

isub : None or int
If None, perform a full transfer.
If int, perform a partial transfer for linear Gauss--Seidel.
Transfer discrete variables between components . This only occurs in fwd mode . Parameters isub : None or int If None perform a full transfer . If int perform a partial transfer for linear Gauss -- Seidel .
def _discrete_transfer(self, isub):
        comm = self.comm
        key = None if isub is None else self._subsystems_allprocs[isub].name
        if comm.size == 1:
            for src_sys_name, src, tgt_sys_name, tgt in self._discrete_transfers[key]:
                tgt_sys = self._loc_subsys_map[tgt_sys_name]
                src_sys = self._loc_subsys_map[src_sys_name]
                tgt_sys._discrete_inputs[tgt] = src_sys._discrete_outputs[src]
        else:  
            allprocs_recv = self._allprocs_discrete_recv[key]
            discrete_out = self._var_discrete['output']
            if key in self._discrete_transfers:
                xfers, remote_send = self._discrete_transfers[key]
                if allprocs_recv:
                    sendvars = [(n, discrete_out[n]['value']) for n in remote_send]
                    allprocs_send = comm.gather(sendvars, root=0)
                    if comm.rank == 0:
                        allprocs_dict = {}
                        for i in range(comm.size):
                            allprocs_dict.update(allprocs_send[i])
                        recvs = [{} for i in range(comm.size)]
                        for rname, ranks in iteritems(allprocs_recv):
                            val = allprocs_dict[rname]
                            for i in ranks:
                                recvs[i][rname] = val
                        data = comm.scatter(recvs, root=0)
                    else:
                        data = comm.scatter(None, root=0)
                else:
                    data = None
                for src_sys_name, src, tgt_sys_name, tgt in xfers:
                    if tgt_sys_name in self._loc_subsys_map:
                        tgt_sys = self._loc_subsys_map[tgt_sys_name]
                        if tgt in tgt_sys._discrete_inputs:
                            abs_src = '.'.join((src_sys_name, src))
                            if data is not None and abs_src in data:
                                src_val = data[abs_src]
                            else:
                                src_val = self._loc_subsys_map[src_sys_name]._discrete_outputs[src]
                            tgt_sys._discrete_inputs[tgt] = src_val
def _discrete_transfer ( self , isub ) : comm = self . comm key = None if isub is None else self . _subsystems_allprocs [ isub ] . name if comm . size == 1 : for src_sys_name , src , tgt_sys_name , tgt in self . _discrete_transfers [ key ] : tgt_sys = self . _loc_subsys_map [ tgt_sys_name ] src_sys = self . _loc_subsys_map [ src_sys_name ] tgt_sys . _discrete_inputs [ tgt ] = src_sys . _discrete_outputs [ src ] else : allprocs_recv = self . _allprocs_discrete_recv [ key ] discrete_out = self . _var_discrete [ 'output' ] if key in self . _discrete_transfers : xfers , remote_send = self . _discrete_transfers [ key ] if allprocs_recv : sendvars = [ ( n , discrete_out [ n ] [ 'value' ] ) for n in remote_send ] allprocs_send = comm . gather ( sendvars , root = 0 ) if comm . rank == 0 : allprocs_dict = { } for i in range ( comm . size ) : allprocs_dict . update ( allprocs_send [ i ] ) recvs = [ { } for i in range ( comm . size ) ] for rname , ranks in iteritems ( allprocs_recv ) : val = allprocs_dict [ rname ] for i in ranks : recvs [ i ] [ rname ] = val data = comm . scatter ( recvs , root = 0 ) else : data = comm . scatter ( None , root = 0 ) else : data = None for src_sys_name , src , tgt_sys_name , tgt in xfers : if tgt_sys_name in self . _loc_subsys_map : tgt_sys = self . _loc_subsys_map [ tgt_sys_name ] if tgt in tgt_sys . _discrete_inputs : abs_src = '.' . join ( ( src_sys_name , src ) ) if data is not None and abs_src in data : src_val = data [ abs_src ] else : src_val = self . _loc_subsys_map [ src_sys_name ] . _discrete_outputs [ src ] tgt_sys . _discrete_inputs [ tgt ] = src_val
Transfer discrete variables between components.
Transfer discrete variables between components .
"""
        Transfer discrete variables between components.  This only occurs in fwd mode.

        Parameters
        ----------
        isub : None or int
            If None, perform a full transfer.
            If int, perform a partial transfer for linear Gauss--Seidel.
        """ # note that we are not copying the discrete value here, so if the # discrete value is some mutable object, for example not an int or str, # the downstream system will have a reference to the same object # as the source, allowing the downstream system to modify the value as # seen by the source system. # MPI
self
isub