petscimpl.py

PETSc vector and data transfer implementation factory.

class openmdao.core.petscimpl.PetscDataXfer(src_vec, tgt_vec, src_idxs, tgt_idxs, vec_conns, byobj_conns)[source]

Bases: openmdao.core.dataxfer.DataXfer

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.

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.petscimpl.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)[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.

Returns:

PetscDataXfer

A PetscDataXfer object.

static create_src_vecwrapper(pathname, comm)[source]

Create a`PetscSrcVecWrapper`.

Returns:PetscSrcVecWrapper
static create_tgt_vecwrapper(pathname, comm)[source]

Create a PetscTgtVecWrapper.

Returns:PetscTgtVecWrapper
class openmdao.core.petscimpl.PetscSrcVecWrapper(pathname='', comm=None)[source]

Bases: openmdao.core.vecwrapper.SrcVecWrapper

get_view(sys_pathname, comm, varmap, relevance, var_of_interest)[source]
idx_arr_type = <Mock name='mock.PETSc.IntType' id='140466563876496'>
norm()[source]
Returns:

float

The norm of the distributed vector.

setup(unknowns_dict, relevant_vars=None, store_byobjs=False)[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.

relevant_vars : iter of str

Names of variables that are relevant a particular variable of interest.

store_byobjs : bool, optional

Indicates that ‘pass by object’ vars should be stored. This is only true for the unknowns vecwrapper.

class openmdao.core.petscimpl.PetscTgtVecWrapper(pathname='', comm=None)[source]

Bases: openmdao.core.vecwrapper.TgtVecWrapper

idx_arr_type = <Mock name='mock.PETSc.IntType' id='140466563876496'>
setup(parent_params_vec, params_dict, srcvec, my_params, connections, relevant_vars=None, store_byobjs=False)[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.

store_byobjs : bool, optional

If True, store ‘pass by object’ variables in the VecWrapper we’re building.