openmdao/core/group.py
def _setup_var_index_ranges(self, recurse=True):
        """
        Compute the division of variables by subsystem.

        Parameters
        ----------
        recurse : bool
            Whether to call this method in subsystems.
        """
        super(Group, self)._setup_var_index_ranges()

        nsub_allprocs = len(self._subsystems_allprocs)

        subsystems_var_range = self._subsystems_var_range = {}

        vec_names = self._lin_rel_vec_name_list if self._use_derivatives else self._vec_names

        # First compute these on one processor for each subsystem
        for vec_name in vec_names:

            # Here, we count the number of variables in each subsystem.
            # We do this so that we can compute the offset when we recurse into each subsystem.
            allprocs_counters = {
                type_: np.zeros(nsub_allprocs, INT_DTYPE) for type_ in ['input', 'output']}

            for type_ in ['input', 'output']:
                for subsys, isub in zip(self._subsystems_myproc, self._subsystems_myproc_inds):
                    comm = subsys.comm if subsys._full_comm is None else subsys._full_comm
                    if comm.rank == 0 and vec_name in subsys._rel_vec_names:
                        allprocs_counters[type_][isub] = \
                            len(subsys._var_allprocs_relevant_names[vec_name][type_])

            # If running in parallel, allgather
            if self.comm.size > 1:
                gathered = self.comm.allgather(allprocs_counters)

                allprocs_counters = {
                    type_: np.zeros(nsub_allprocs, INT_DTYPE) for type_ in ['input', 'output']}
                for myproc_counters in gathered:
                    for type_ in ['input', 'output']:
                        allprocs_counters[type_] += myproc_counters[type_]

            # Compute _subsystems_var_range
            subsystems_var_range[vec_name] = {}

            for type_ in ['input', 'output']:
                subsystems_var_range[vec_name][type_] = {}

                for subsys, isub in zip(self._subsystems_myproc, self._subsystems_myproc_inds):
                    if vec_name not in subsys._rel_vec_names:
                        continue
                    subsystems_var_range[vec_name][type_][subsys.name] = (
                        np.sum(allprocs_counters[type_][:isub]),
                        np.sum(allprocs_counters[type_][:isub + 1]))

        if self._use_derivatives:
            subsystems_var_range['nonlinear'] = subsystems_var_range['linear']

        # Recursion
        if recurse:
            for subsys in self._subsystems_myproc:
                subsys._setup_var_index_ranges(recurse)

        Compute the division of variables by subsystem.

        Parameters
        ----------
        recurse : bool
            Whether to call this method in subsystems.
        
Compute the division of variables by subsystem.
Parameters

recurse : bool
Whether to call this method in subsystems.
Compute the division of variables by subsystem . Parameters recurse : bool Whether to call this method in subsystems .
def _setup_var_index_ranges(self, recurse=True):
        super(Group, self)._setup_var_index_ranges()
        nsub_allprocs = len(self._subsystems_allprocs)
        subsystems_var_range = self._subsystems_var_range = {}
        vec_names = self._lin_rel_vec_name_list if self._use_derivatives else self._vec_names
        for vec_name in vec_names:
            allprocs_counters = {
                type_: np.zeros(nsub_allprocs, INT_DTYPE) for type_ in ['input', 'output']}
            for type_ in ['input', 'output']:
                for subsys, isub in zip(self._subsystems_myproc, self._subsystems_myproc_inds):
                    comm = subsys.comm if subsys._full_comm is None else subsys._full_comm
                    if comm.rank == 0 and vec_name in subsys._rel_vec_names:
                        allprocs_counters[type_][isub] = \
                            len(subsys._var_allprocs_relevant_names[vec_name][type_])
            if self.comm.size > 1:
                gathered = self.comm.allgather(allprocs_counters)
                allprocs_counters = {
                    type_: np.zeros(nsub_allprocs, INT_DTYPE) for type_ in ['input', 'output']}
                for myproc_counters in gathered:
                    for type_ in ['input', 'output']:
                        allprocs_counters[type_] += myproc_counters[type_]
            subsystems_var_range[vec_name] = {}
            for type_ in ['input', 'output']:
                subsystems_var_range[vec_name][type_] = {}
                for subsys, isub in zip(self._subsystems_myproc, self._subsystems_myproc_inds):
                    if vec_name not in subsys._rel_vec_names:
                        continue
                    subsystems_var_range[vec_name][type_][subsys.name] = (
                        np.sum(allprocs_counters[type_][:isub]),
                        np.sum(allprocs_counters[type_][:isub + 1]))
        if self._use_derivatives:
            subsystems_var_range['nonlinear'] = subsystems_var_range['linear']
        if recurse:
            for subsys in self._subsystems_myproc:
                subsys._setup_var_index_ranges(recurse)
def _setup_var_index_ranges ( self , recurse = True ) : super ( Group , self ) . _setup_var_index_ranges ( ) nsub_allprocs = len ( self . _subsystems_allprocs ) subsystems_var_range = self . _subsystems_var_range = { } vec_names = self . _lin_rel_vec_name_list if self . _use_derivatives else self . _vec_names for vec_name in vec_names : allprocs_counters = { type_ : np . zeros ( nsub_allprocs , INT_DTYPE ) for type_ in [ 'input' , 'output' ] } for type_ in [ 'input' , 'output' ] : for subsys , isub in zip ( self . _subsystems_myproc , self . _subsystems_myproc_inds ) : comm = subsys . comm if subsys . _full_comm is None else subsys . _full_comm if comm . rank == 0 and vec_name in subsys . _rel_vec_names : allprocs_counters [ type_ ] [ isub ] = len ( subsys . _var_allprocs_relevant_names [ vec_name ] [ type_ ] ) if self . comm . size > 1 : gathered = self . comm . allgather ( allprocs_counters ) allprocs_counters = { type_ : np . zeros ( nsub_allprocs , INT_DTYPE ) for type_ in [ 'input' , 'output' ] } for myproc_counters in gathered : for type_ in [ 'input' , 'output' ] : allprocs_counters [ type_ ] += myproc_counters [ type_ ] subsystems_var_range [ vec_name ] = { } for type_ in [ 'input' , 'output' ] : subsystems_var_range [ vec_name ] [ type_ ] = { } for subsys , isub in zip ( self . _subsystems_myproc , self . _subsystems_myproc_inds ) : if vec_name not in subsys . _rel_vec_names : continue subsystems_var_range [ vec_name ] [ type_ ] [ subsys . name ] = ( np . sum ( allprocs_counters [ type_ ] [ : isub ] ) , np . sum ( allprocs_counters [ type_ ] [ : isub + 1 ] ) ) if self . _use_derivatives : subsystems_var_range [ 'nonlinear' ] = subsystems_var_range [ 'linear' ] if recurse : for subsys in self . _subsystems_myproc : subsys . _setup_var_index_ranges ( recurse )
Compute the division of variables by subsystem.
Compute the division of variables by subsystem .
"""
        Compute the division of variables by subsystem.

        Parameters
        ----------
        recurse : bool
            Whether to call this method in subsystems.
        """ # First compute these on one processor for each subsystem # Here, we count the number of variables in each subsystem. # We do this so that we can compute the offset when we recurse into each subsystem. # If running in parallel, allgather # Compute _subsystems_var_range # Recursion
self
recurse