openmdao/core/group.py
def _setup_var_sizes(self, recurse=True):
        """
        Compute the arrays of local variable sizes for all variables/procs on this system.

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

        self._var_offsets = None

        iproc = self.comm.rank
        nproc = self.comm.size

        subsystems_proc_range = self._subsystems_proc_range

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

        sizes = self._var_sizes
        relnames = self._var_allprocs_relevant_names

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

        # Compute _var_sizes
        for vec_name in vec_names:
            sizes[vec_name] = {}
            subsystems_var_range = self._subsystems_var_range[vec_name]

            for type_ in ['input', 'output']:
                sizes[vec_name][type_] = np.zeros((nproc, len(relnames[vec_name][type_])),
                                                  INT_DTYPE)

                for ind, subsys in enumerate(self._subsystems_myproc):
                    if vec_name not in subsys._rel_vec_names:
                        continue
                    proc_slice = slice(*subsystems_proc_range[ind])
                    var_slice = slice(*subsystems_var_range[type_][subsys.name])
                    if proc_slice.stop - proc_slice.start > subsys.comm.size:
                        # in this case, we've split the proc for parallel FD, so subsys doesn't
                        # have var_sizes for all the ranks we need. Since each parallel FD comm
                        # has the same size distribution (since all are identical), just 'tile'
                        # the var_sizes from the subsystem to fill in the full rank range we need
                        # at this level.
                        assert (proc_slice.stop - proc_slice.start) % subsys.comm.size == 0, \
                            "%s comm size (%d) is not an exact multiple of %s comm size (%d)" % (
                                self.pathname, self.comm.size, subsys.pathname, subsys.comm.size)
                        proc_i = proc_slice.start
                        while proc_i < proc_slice.stop:
                            sizes[vec_name][type_][proc_i:proc_i + subsys.comm.size, var_slice] = \
                                subsys._var_sizes[vec_name][type_]
                            proc_i += subsys.comm.size
                    else:
                        sizes[vec_name][type_][proc_slice, var_slice] = \
                            subsys._var_sizes[vec_name][type_]

        # If parallel, all gather
        if self.comm.size > 1:
            for vec_name in self._lin_rel_vec_name_list:
                sizes = self._var_sizes[vec_name]
                for type_ in ['input', 'output']:
                    self.comm.Allgather(sizes[type_][iproc, :], sizes[type_])

            # compute owning ranks
            owns = self._owning_rank
            for type_ in ('input', 'output'):
                sizes = self._var_sizes[vec_names[0]][type_]
                for i, name in enumerate(self._var_allprocs_abs_names[type_]):
                    for rank in range(self.comm.size):
                        if sizes[rank, i] > 0:
                            owns[name] = rank
                            break

                if self._var_allprocs_discrete[type_]:
                    local = list(self._var_discrete[type_])
                    for i, names in enumerate(self.comm.allgather(local)):
                        for n in names:
                            if n not in owns:
                                owns[n] = i

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

        self._setup_global_shapes()

        Compute the arrays of local variable sizes for all variables/procs on this system.

        Parameters
        ----------
        recurse : bool
            Whether to call this method in subsystems.
        
Compute the arrays of local variable sizes for all variables/procs on this system.
Parameters

recurse : bool
Whether to call this method in subsystems.
Compute the arrays of local variable sizes for all variables / procs on this system . Parameters recurse : bool Whether to call this method in subsystems .
def _setup_var_sizes(self, recurse=True):
        super(Group, self)._setup_var_sizes()
        self._var_offsets = None
        iproc = self.comm.rank
        nproc = self.comm.size
        subsystems_proc_range = self._subsystems_proc_range
        if recurse:
            for subsys in self._subsystems_myproc:
                subsys._setup_var_sizes(recurse)
        sizes = self._var_sizes
        relnames = self._var_allprocs_relevant_names
        vec_names = self._lin_rel_vec_name_list if self._use_derivatives else self._vec_names
        for vec_name in vec_names:
            sizes[vec_name] = {}
            subsystems_var_range = self._subsystems_var_range[vec_name]
            for type_ in ['input', 'output']:
                sizes[vec_name][type_] = np.zeros((nproc, len(relnames[vec_name][type_])),
                                                  INT_DTYPE)
                for ind, subsys in enumerate(self._subsystems_myproc):
                    if vec_name not in subsys._rel_vec_names:
                        continue
                    proc_slice = slice(*subsystems_proc_range[ind])
                    var_slice = slice(*subsystems_var_range[type_][subsys.name])
                    if proc_slice.stop - proc_slice.start > subsys.comm.size:
                        assert (proc_slice.stop - proc_slice.start) % subsys.comm.size == 0, \
                            "%s comm size (%d) is not an exact multiple of %s comm size (%d)" % (
                                self.pathname, self.comm.size, subsys.pathname, subsys.comm.size)
                        proc_i = proc_slice.start
                        while proc_i < proc_slice.stop:
                            sizes[vec_name][type_][proc_i:proc_i + subsys.comm.size, var_slice] = \
                                subsys._var_sizes[vec_name][type_]
                            proc_i += subsys.comm.size
                    else:
                        sizes[vec_name][type_][proc_slice, var_slice] = \
                            subsys._var_sizes[vec_name][type_]
        if self.comm.size > 1:
            for vec_name in self._lin_rel_vec_name_list:
                sizes = self._var_sizes[vec_name]
                for type_ in ['input', 'output']:
                    self.comm.Allgather(sizes[type_][iproc, :], sizes[type_])
            owns = self._owning_rank
            for type_ in ('input', 'output'):
                sizes = self._var_sizes[vec_names[0]][type_]
                for i, name in enumerate(self._var_allprocs_abs_names[type_]):
                    for rank in range(self.comm.size):
                        if sizes[rank, i] > 0:
                            owns[name] = rank
                            break
                if self._var_allprocs_discrete[type_]:
                    local = list(self._var_discrete[type_])
                    for i, names in enumerate(self.comm.allgather(local)):
                        for n in names:
                            if n not in owns:
                                owns[n] = i
        if self._use_derivatives:
            self._var_sizes['nonlinear'] = self._var_sizes['linear']
        self._setup_global_shapes()
def _setup_var_sizes ( self , recurse = True ) : super ( Group , self ) . _setup_var_sizes ( ) self . _var_offsets = None iproc = self . comm . rank nproc = self . comm . size subsystems_proc_range = self . _subsystems_proc_range if recurse : for subsys in self . _subsystems_myproc : subsys . _setup_var_sizes ( recurse ) sizes = self . _var_sizes relnames = self . _var_allprocs_relevant_names vec_names = self . _lin_rel_vec_name_list if self . _use_derivatives else self . _vec_names for vec_name in vec_names : sizes [ vec_name ] = { } subsystems_var_range = self . _subsystems_var_range [ vec_name ] for type_ in [ 'input' , 'output' ] : sizes [ vec_name ] [ type_ ] = np . zeros ( ( nproc , len ( relnames [ vec_name ] [ type_ ] ) ) , INT_DTYPE ) for ind , subsys in enumerate ( self . _subsystems_myproc ) : if vec_name not in subsys . _rel_vec_names : continue proc_slice = slice ( * subsystems_proc_range [ ind ] ) var_slice = slice ( * subsystems_var_range [ type_ ] [ subsys . name ] ) if proc_slice . stop - proc_slice . start > subsys . comm . size : assert ( proc_slice . stop - proc_slice . start ) % subsys . comm . size == 0 , "%s comm size (%d) is not an exact multiple of %s comm size (%d)" % ( self . pathname , self . comm . size , subsys . pathname , subsys . comm . size ) proc_i = proc_slice . start while proc_i < proc_slice . stop : sizes [ vec_name ] [ type_ ] [ proc_i : proc_i + subsys . comm . size , var_slice ] = subsys . _var_sizes [ vec_name ] [ type_ ] proc_i += subsys . comm . size else : sizes [ vec_name ] [ type_ ] [ proc_slice , var_slice ] = subsys . _var_sizes [ vec_name ] [ type_ ] if self . comm . size > 1 : for vec_name in self . _lin_rel_vec_name_list : sizes = self . _var_sizes [ vec_name ] for type_ in [ 'input' , 'output' ] : self . comm . Allgather ( sizes [ type_ ] [ iproc , : ] , sizes [ type_ ] ) owns = self . _owning_rank for type_ in ( 'input' , 'output' ) : sizes = self . _var_sizes [ vec_names [ 0 ] ] [ type_ ] for i , name in enumerate ( self . _var_allprocs_abs_names [ type_ ] ) : for rank in range ( self . comm . size ) : if sizes [ rank , i ] > 0 : owns [ name ] = rank break if self . _var_allprocs_discrete [ type_ ] : local = list ( self . _var_discrete [ type_ ] ) for i , names in enumerate ( self . comm . allgather ( local ) ) : for n in names : if n not in owns : owns [ n ] = i if self . _use_derivatives : self . _var_sizes [ 'nonlinear' ] = self . _var_sizes [ 'linear' ] self . _setup_global_shapes ( )
Compute the arrays of local variable sizes for all variables/procs on this system.
Compute the arrays of local variable sizes for all variables / procs on this system .
"""
        Compute the arrays of local variable sizes for all variables/procs on this system.

        Parameters
        ----------
        recurse : bool
            Whether to call this method in subsystems.
        """ # Recursion # Compute _var_sizes # in this case, we've split the proc for parallel FD, so subsys doesn't # have var_sizes for all the ranks we need. Since each parallel FD comm # has the same size distribution (since all are identical), just 'tile' # the var_sizes from the subsystem to fill in the full rank range we need # at this level. # If parallel, all gather # compute owning ranks
self
recurse