petsc_impl.py¶
PETSc vector and data transfer implementation factory.
-
class
openmdao.core.petsc_impl.
PetscDataTransfer
(src_vec, tgt_vec, src_idxs, tgt_idxs, vec_conns, byobj_conns, mode, sysdata)[source]¶ Bases:
object
Args: src_vec : VecWrapper
Variables that are the source of the transfer in fwd mode and the destination of the transfer in rev mode.
tgt_vec : VecWrapper
Variables that are the destination of the transfer in fwd mode and the source of the transfer in rev mode.
src_idxs : array
indices of the source variables in the source vector.
tgt_idxs : array
indices of the target variables in the target vector.
vec_conns : dict
mapping of ‘pass by vector’ variables to the source variables that they are connected to.
byobj_conns : dict
mapping of ‘pass by object’ variables to the source variables that they are connected to.
mode : str
Either ‘fwd’ or ‘rev’, indicating a forward or reverse scatter.
sysdata : SysData object
The SysData object for the Group that will contain this DataTransfer object.
-
transfer
(srcvec, tgtvec, mode='fwd', deriv=False)[source]¶ Performs data transfer between a distributed source vector and a distributed target vector.
Args: srcvec : VecWrapper
Variables that are the source of the transfer in fwd mode and the destination of the transfer in rev mode.
tgtvec : VecWrapper
Variables that are the destination of the transfer in fwd mode and the source of the transfer in rev mode.
mode : ‘fwd’ or ‘rev’, optional
Direction of the data transfer, source to target (‘fwd’, the default) or target to source (‘rev’).
deriv : bool, optional
If True, this is a derivative data transfer, so no pass_by_obj variables will be transferred.
-
-
class
openmdao.core.petsc_impl.
PetscImpl
[source]¶ Bases:
object
PETSc vector and data transfer implementation factory.
-
static
create_data_xfer
(src_vec, tgt_vec, src_idxs, tgt_idxs, vec_conns, byobj_conns, mode, sysdata)[source]¶ Create an object for performing data transfer between source and target vectors.
Args: src_vec : VecWrapper
Variables that are the source of the transfer in fwd mode and the destination of the transfer in rev mode.
tgt_vec : VecWrapper
Variables that are the destination of the transfer in fwd mode and the source of the transfer in rev mode.
src_idxs : array
Indices of the source variables in the source vector.
tgt_idxs : array
Indices of the target variables in the target vector.
vec_conns : dict
Mapping of ‘pass by vector’ variables to the source variables that they are connected to.
byobj_conns : dict
Mapping of ‘pass by object’ variables to the source variables that they are connected to.
mode : str
Either ‘fwd’ or ‘rev’, indicating a forward or reverse scatter.
sysdata : SysData object
The SysData object for the Group that will contain the new DataTransfer object.
Returns: PetscDataTransfer
A PetscDataTransfer object.
-
static
create_src_vecwrapper
(sysdata, comm)[source]¶ Create a`PetscSrcVecWrapper`.
Returns: PetscSrcVecWrapper
-
static
create_tgt_vecwrapper
(sysdata, comm)[source]¶ Create a PetscTgtVecWrapper.
Returns: PetscTgtVecWrapper
-
idx_arr_type
= <Mock name='mock.PETSc.IntType' id='140180397386640'>¶
-
static
-
class
openmdao.core.petsc_impl.
PetscSrcVecWrapper
(sysdata, comm=None)[source]¶ Bases:
openmdao.core.vec_wrapper.SrcVecWrapper
-
distance_along_vector_to_limit
(alpha, duvec)[source]¶ Returns a new alpha so that new_u = current_u + alpha*duvec does not violate any lower or upper limits if specified.
Args: alpha: float
Initial value for step in gradient direction.
duvec: `Vecwrapper`
Direction to apply step. generally the gradient.
Returns: float
New step size, backtracked to prevent violation.
-
idx_arr_type
= <Mock name='mock.PETSc.IntType' id='140180397386640'>¶
-
setup
(unknowns_dict, relevance, var_of_interest=None, store_byobjs=False, shared_vec=None)[source]¶ Create internal data storage for variables in unknowns_dict.
Args: unknowns_dict : OrderedDict
A dictionary of absolute variable names keyed to an associated metadata dictionary.
relevance : Relevance object
Object that knows what vars are relevant for each var_of_interest.
var_of_interest : str or None
Name of the current variable of interest.
store_byobjs : bool, optional
Indicates that ‘pass by object’ vars should be stored. This is only true for the unknowns vecwrapper.
shared_vec : ndarray, optional
If not None, create vec as a subslice of this array.
-
-
class
openmdao.core.petsc_impl.
PetscTgtVecWrapper
(sysdata, comm=None)[source]¶ Bases:
openmdao.core.vec_wrapper.TgtVecWrapper
-
idx_arr_type
= <Mock name='mock.PETSc.IntType' id='140180397386640'>¶
-
setup
(parent_params_vec, params_dict, srcvec, my_params, connections, relevance, var_of_interest=None, store_byobjs=False, shared_vec=None)[source]¶ Configure this vector to store a flattened array of the variables in params_dict. Variable shape and value are retrieved from srcvec.
Args: parent_params_vec : VecWrapper or None
VecWrapper of parameters from the parent System.
params_dict : OrderedDict
Dictionary of parameter absolute name mapped to metadata dict.
srcvec : VecWrapper
Source VecWrapper corresponding to the target VecWrapper we’re building.
my_params : list of str
A list of absolute names of parameters that the VecWrapper we’re building will ‘own’.
connections : dict of str
A dict of absolute target names mapped to the absolute name of their source variable.
relevance : Relevance object
Object that knows what vars are relevant for each var_of_interest.
var_of_interest : str or None
Name of the current variable of interest.
store_byobjs : bool, optional
If True, store ‘pass by object’ variables in the VecWrapper we’re building.
shared_vec : ndarray, optional
If not None, create vec as a subslice of this array.
-