openmdao/core/total_jac.py
def _get_solvec_map(self, names, vois, abs2meta, mode):
        """
        Create a dict mapping vecname and direction to an index array into the solution vector.

        Using the index array to pull values from the solution vector will give the values
        in the order needed by the jacobian.

        Parameters
        ----------
        names : iter of str
            Names of the variables making up the rows or columns of the jacobian.
        vois : dict
            Mapping of variable of interest (desvar or response) name to its metadata.
        abs2meta : dict
            Mapping of absolute var name to metadata for that var.
        mode : str
            Derivative solution direction.

        Returns
        -------
        dict
            Mapping of vecname to index array for all names in order
        """
        idxs = {}
        jac_idxs = {}
        model = self.model
        myproc = model.comm.rank
        owners = model._owning_rank
        fwd = mode == 'fwd'
        missing = False
        full_slice = slice(None)

        for vecname in model._lin_vec_names:
            inds = []
            jac_inds = []
            sizes = model._var_sizes[vecname]['output']
            offsets = model._var_offsets[vecname]['output']
            abs2idx = model._var_allprocs_abs2idx[vecname]
            start = end = 0

            for name in names:
                indices = vois[name]['indices'] if name in vois else None
                meta = abs2meta[name]

                if name in abs2idx:
                    var_idx = abs2idx[name]
                    if meta['distributed']:
                        # if var is distributed, we need all of its parts from all procs
                        dist_idxs = []
                        for rank in range(model.comm.size):
                            if sizes[rank, var_idx] > 0:
                                offset = offsets[rank, var_idx]
                                dist_idxs.append(np.arange(offset, offset + sizes[rank, var_idx],
                                                           dtype=INT_DTYPE))
                        idx_array = np.hstack(dist_idxs)
                    else:
                        iproc = owners[name]

                        offset = offsets[iproc, var_idx]
                        idx_array = np.arange(offset, offset + sizes[iproc, var_idx],
                                              dtype=INT_DTYPE)
                        if indices is not None:
                            idx_array = idx_array[indices]

                    sz = idx_array.size
                else:
                    missing = True
                    sz = meta['global_size']

                if indices is not None:
                    sz = len(indices)

                end += sz
                if name in abs2idx:
                    inds.append(idx_array)
                    jac_inds.append((start, end))

                start = end

            idxs[vecname] = np.hstack(inds)

            if missing:
                jac_idxs[vecname] = np.hstack([np.arange(start, end, dtype=INT_DTYPE)
                                               for start, end in jac_inds])
            else:
                jac_idxs[vecname] = full_slice

        return idxs, jac_idxs

        Create a dict mapping vecname and direction to an index array into the solution vector.

        Using the index array to pull values from the solution vector will give the values
        in the order needed by the jacobian.

        Parameters
        ----------
        names : iter of str
            Names of the variables making up the rows or columns of the jacobian.
        vois : dict
            Mapping of variable of interest (desvar or response) name to its metadata.
        abs2meta : dict
            Mapping of absolute var name to metadata for that var.
        mode : str
            Derivative solution direction.

        Returns
        -------
        dict
            Mapping of vecname to index array for all names in order
        
Create a dict mapping vecname and direction to an index array into the solution vector.
Using the index array to pull values from the solution vector will give the values
in the order needed by the jacobian.

Parameters

names : iter of str
Names of the variables making up the rows or columns of the jacobian.
vois : dict
Mapping of variable of interest (desvar or response) name to its metadata.
abs2meta : dict
Mapping of absolute var name to metadata for that var.
mode : str
Derivative solution direction.

Returns

dict
Mapping of vecname to index array for all names in order
Create a dict mapping vecname and direction to an index array into the solution vector . Using the index array to pull values from the solution vector will give the values in the order needed by the jacobian . Parameters names : iter of str Names of the variables making up the rows or columns of the jacobian . vois : dict Mapping of variable of interest ( desvar or response ) name to its metadata . abs2meta : dict Mapping of absolute var name to metadata for that var . mode : str Derivative solution direction . Returns dict Mapping of vecname to index array for all names in order
def _get_solvec_map(self, names, vois, abs2meta, mode):
        idxs = {}
        jac_idxs = {}
        model = self.model
        myproc = model.comm.rank
        owners = model._owning_rank
        fwd = mode == 'fwd'
        missing = False
        full_slice = slice(None)
        for vecname in model._lin_vec_names:
            inds = []
            jac_inds = []
            sizes = model._var_sizes[vecname]['output']
            offsets = model._var_offsets[vecname]['output']
            abs2idx = model._var_allprocs_abs2idx[vecname]
            start = end = 0
            for name in names:
                indices = vois[name]['indices'] if name in vois else None
                meta = abs2meta[name]
                if name in abs2idx:
                    var_idx = abs2idx[name]
                    if meta['distributed']:
                        dist_idxs = []
                        for rank in range(model.comm.size):
                            if sizes[rank, var_idx] > 0:
                                offset = offsets[rank, var_idx]
                                dist_idxs.append(np.arange(offset, offset + sizes[rank, var_idx],
                                                           dtype=INT_DTYPE))
                        idx_array = np.hstack(dist_idxs)
                    else:
                        iproc = owners[name]
                        offset = offsets[iproc, var_idx]
                        idx_array = np.arange(offset, offset + sizes[iproc, var_idx],
                                              dtype=INT_DTYPE)
                        if indices is not None:
                            idx_array = idx_array[indices]
                    sz = idx_array.size
                else:
                    missing = True
                    sz = meta['global_size']
                if indices is not None:
                    sz = len(indices)
                end += sz
                if name in abs2idx:
                    inds.append(idx_array)
                    jac_inds.append((start, end))
                start = end
            idxs[vecname] = np.hstack(inds)
            if missing:
                jac_idxs[vecname] = np.hstack([np.arange(start, end, dtype=INT_DTYPE)
                                               for start, end in jac_inds])
            else:
                jac_idxs[vecname] = full_slice
        return idxs, jac_idxs
def _get_solvec_map ( self , names , vois , abs2meta , mode ) : idxs = { } jac_idxs = { } model = self . model myproc = model . comm . rank owners = model . _owning_rank fwd = mode == 'fwd' missing = False full_slice = slice ( None ) for vecname in model . _lin_vec_names : inds = [ ] jac_inds = [ ] sizes = model . _var_sizes [ vecname ] [ 'output' ] offsets = model . _var_offsets [ vecname ] [ 'output' ] abs2idx = model . _var_allprocs_abs2idx [ vecname ] start = end = 0 for name in names : indices = vois [ name ] [ 'indices' ] if name in vois else None meta = abs2meta [ name ] if name in abs2idx : var_idx = abs2idx [ name ] if meta [ 'distributed' ] : dist_idxs = [ ] for rank in range ( model . comm . size ) : if sizes [ rank , var_idx ] > 0 : offset = offsets [ rank , var_idx ] dist_idxs . append ( np . arange ( offset , offset + sizes [ rank , var_idx ] , dtype = INT_DTYPE ) ) idx_array = np . hstack ( dist_idxs ) else : iproc = owners [ name ] offset = offsets [ iproc , var_idx ] idx_array = np . arange ( offset , offset + sizes [ iproc , var_idx ] , dtype = INT_DTYPE ) if indices is not None : idx_array = idx_array [ indices ] sz = idx_array . size else : missing = True sz = meta [ 'global_size' ] if indices is not None : sz = len ( indices ) end += sz if name in abs2idx : inds . append ( idx_array ) jac_inds . append ( ( start , end ) ) start = end idxs [ vecname ] = np . hstack ( inds ) if missing : jac_idxs [ vecname ] = np . hstack ( [ np . arange ( start , end , dtype = INT_DTYPE ) for start , end in jac_inds ] ) else : jac_idxs [ vecname ] = full_slice return idxs , jac_idxs
Create a dict mapping vecname and direction to an index array into the solution vector.
Create a dict mapping vecname and direction to an index array into the solution vector .
"""
        Create a dict mapping vecname and direction to an index array into the solution vector.

        Using the index array to pull values from the solution vector will give the values
        in the order needed by the jacobian.

        Parameters
        ----------
        names : iter of str
            Names of the variables making up the rows or columns of the jacobian.
        vois : dict
            Mapping of variable of interest (desvar or response) name to its metadata.
        abs2meta : dict
            Mapping of absolute var name to metadata for that var.
        mode : str
            Derivative solution direction.

        Returns
        -------
        dict
            Mapping of vecname to index array for all names in order
        """ # if var is distributed, we need all of its parts from all procs
self
names
vois
abs2meta
mode