pyop2.types package¶
Submodules¶
pyop2.types.access module¶
- class pyop2.types.access.Access(value)¶
Bases:
IntEnumAn enumeration.
- READ = 1¶
- WRITE = 2¶
- RW = 3¶
- INC = 4¶
- MIN = 5¶
- MAX = 6¶
- pyop2.types.access.READ = Access.READ¶
The
Global,Dat, orMatis accessed read-only.
- pyop2.types.access.WRITE = Access.WRITE¶
The
Global,Dat, orMatis accessed write-only, and OP2 is not required to handle write conflicts.
- pyop2.types.access.RW = Access.RW¶
The
Global,Dat, orMatis accessed for reading and writing, and OP2 is not required to handle write conflicts.
- pyop2.types.access.INC = Access.INC¶
The kernel computes increments to be summed onto a
Global,Dat, orMat. OP2 is responsible for managing the write conflicts caused.
- pyop2.types.access.MIN = Access.MIN¶
The kernel contributes to a reduction into a
Globalusing aminoperation. OP2 is responsible for reducing over the different kernel invocations.
- pyop2.types.access.MAX = Access.MAX¶
The kernel contributes to a reduction into a
Globalusing amaxoperation. OP2 is responsible for reducing over the different kernel invocations.
pyop2.types.dat module¶
- class pyop2.types.dat.AbstractDat(dataset, data=None, dtype=None, name=None)¶
Bases:
DataCarrier,EmptyDataMixin,ABCOP2 vector data. A
Datholds values on every element of aDataSet.oIf a
Setis passed as thedatasetargument, rather than aDataSet, theDatis created with a defaultDataSetdimension of 1.If a
Datis passed as thedatasetargument, a copy is returned.It is permissible to pass None as the data argument. In this case, allocation of the data buffer is postponed until it is accessed.
Note
If the data buffer is not passed in, it is implicitly initialised to be zero.
When a
Datis passed topyop2.op2.par_loop(), the map via which indirection occurs and the access descriptor are passed by calling theDat. For instance, if aDatnamedDis to be accessed for reading via aMapnamedM, this is accomplished byD(pyop2.READ, M)
The
Mapthrough which indirection occurs can be indexed using the index notation described in the documentation for theMap. Direct access to a Dat is accomplished by omitting the path argument.Datobjects support the pointwise linear algebra operations+=,*=,-=,/=, where*=and/=also support multiplication / division by a scalar.- property dataset¶
DataSeton which the Dat is defined.
- property dim¶
The shape of the values for each element of the object.
- property cdim¶
The scalar number of values for each member of the object. This is the product of the dim tuple.
- property data¶
Numpy array containing the data values.
With this accessor you are claiming that you will modify the values you get back. If you only need to look at the values, use
data_ro()instead.This only shows local values, to see the halo values too use
data_with_halos().This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property data_with_halos¶
A view of this
Dats data.This accessor marks the
Datas dirty, seedata()for more details on the semantics.With this accessor, you get to see up to date halo values, but you should not try and modify them, because they will be overwritten by the next halo exchange.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property data_ro¶
Numpy array containing the data values. Read-only.
With this accessor you are not allowed to modify the values you get back. If you need to do so, use
data()instead.This only shows local values, to see the halo values too use
data_ro_with_halos().This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property data_ro_with_halos¶
A view of this
Dats data.This accessor does not mark the
Datas dirty, and is a read only view, seedata_ro()for more details on the semantics.With this accessor, you get to see up to date halo values, but you should not try and modify them, because they will be overwritten by the next halo exchange.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property data_wo¶
Numpy array containing the data values that is only valid for writing to.
This only shows local values, to see the halo values too use
data_wo_with_halos().This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property data_wo_with_halos¶
Return a write-only view of all the data values.
This method, unlike
data_with_halos(), avoids a halo exchange if the halo is dirty.This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- save(filename)¶
Write the data array to file
filenamein NumPy format.
- load(filename)¶
Read the data stored in file
filenameinto a NumPy array and store the values in_data().
- property shape¶
- property dtype¶
The Python type of the data.
- property nbytes¶
Return an estimate of the size of the data associated with this
Datin bytes. This will be the correct size of the data payload, but does not take into account the (presumably small) overhead of the object and its metadata.Note that this is the process local memory usage, not the sum over all MPI processes.
- zero(subset=None)¶
Zero the data associated with this
Dat- Parameters:
subset – A
Subsetof entries to zero (optional).
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- copy(other, subset=None)¶
Copy the data in this
Datinto another.- Parameters:
other – The destination
Datsubset – A
Subsetof elements to copy (optional)
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- inner(other)¶
Compute the l2 inner product of the flattened
Dat- Parameters:
other – the other
Datto compute the inner product against. The complex conjugate of this is taken.
- property norm¶
Compute the l2 norm of this
DatNote
This acts on the flattened data (see also
inner()).
- global_to_local_begin(access_mode)¶
Begin a halo exchange from global to ghosted representation.
- Parameters:
access_mode – Mode with which the data will subsequently be accessed.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- global_to_local_end(access_mode)¶
End a halo exchange from global to ghosted representation.
- Parameters:
access_mode – Mode with which the data will subsequently be accessed.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- local_to_global_begin(insert_mode)¶
Begin a halo exchange from ghosted to global representation.
- Parameters:
insert_mode – insertion mode (an access descriptor)
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- local_to_global_end(insert_mode)¶
End a halo exchange from ghosted to global representation.
- Parameters:
insert_mode – insertion mode (an access descriptor)
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- frozen_halo(access_mode)¶
Temporarily disable halo exchanges inside a context manager.
- Parameters:
access_mode – Mode with which the data will subsequently be accessed.
This is useful in cases where one is repeatedly writing to a
Datwith the same access descriptor since the intermediate updates can be skipped.This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- freeze_halo(access_mode)¶
Disable halo exchanges.
- Parameters:
access_mode – Mode with which the data will subsequently be accessed.
Note that some bookkeeping is needed when freezing halos. Prefer to use the
Dat.frozen_halo()context manager.This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- unfreeze_halo()¶
Re-enable halo exchanges.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- class pyop2.types.dat.DatView(dat, index)¶
Bases:
AbstractDatAn indexed view into a
Dat.This object can be used like a
Datbut the kernel will only see the requested index, rather than the full data.- Parameters:
dat – The
Datto create a view into.index – The component to select a view of.
- property cdim¶
The scalar number of values for each member of the object. This is the product of the dim tuple.
- property dim¶
The shape of the values for each element of the object.
- property shape¶
- property halo_valid¶
- property dat_version¶
- property data¶
Numpy array containing the data values.
With this accessor you are claiming that you will modify the values you get back. If you only need to look at the values, use
data_ro()instead.This only shows local values, to see the halo values too use
data_with_halos().This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property data_ro¶
Numpy array containing the data values. Read-only.
With this accessor you are not allowed to modify the values you get back. If you need to do so, use
data()instead.This only shows local values, to see the halo values too use
data_ro_with_halos().This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property data_wo¶
Numpy array containing the data values that is only valid for writing to.
This only shows local values, to see the halo values too use
data_wo_with_halos().This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property data_with_halos¶
A view of this
Dats data.This accessor marks the
Datas dirty, seedata()for more details on the semantics.With this accessor, you get to see up to date halo values, but you should not try and modify them, because they will be overwritten by the next halo exchange.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property data_ro_with_halos¶
A view of this
Dats data.This accessor does not mark the
Datas dirty, and is a read only view, seedata_ro()for more details on the semantics.With this accessor, you get to see up to date halo values, but you should not try and modify them, because they will be overwritten by the next halo exchange.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property data_wo_with_halos¶
Return a write-only view of all the data values.
This method, unlike
data_with_halos(), avoids a halo exchange if the halo is dirty.This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- class pyop2.types.dat.Dat(*args, **kwargs)¶
Bases:
AbstractDat,VecAccessMixin
- class pyop2.types.dat.MixedDat(mdset_or_dats)¶
Bases:
AbstractDat,VecAccessMixinA container for a bag of
Dats.Initialized either from a
MixedDataSet, aMixedSet, or an iterable ofDataSets and/orSets, where all theSets are implcitly upcast toDataSetsmdat = op2.MixedDat(mdset) mdat = op2.MixedDat([dset1, ..., dsetN])
or from an iterable of
Datsmdat = op2.MixedDat([dat1, ..., datN])
- property dat_version¶
- increment_dat_version()¶
- property dtype¶
The NumPy dtype of the data.
- property data¶
Numpy arrays containing the data excluding halos.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property data_with_halos¶
Numpy arrays containing the data including halos.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property data_ro¶
Numpy arrays with read-only data excluding halos.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property data_ro_with_halos¶
Numpy arrays with read-only data including halos.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property data_wo¶
Numpy arrays with read-only data excluding halos.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property data_wo_with_halos¶
Numpy arrays with read-only data including halos.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property halo_valid¶
Does this Dat have up to date halos?
- global_to_local_begin(access_mode)¶
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- global_to_local_end(access_mode)¶
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- local_to_global_begin(insert_mode)¶
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- local_to_global_end(insert_mode)¶
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- freeze_halo(access_mode)¶
Disable halo exchanges.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- unfreeze_halo()¶
Re-enable halo exchanges.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- zero(subset=None)¶
Zero the data associated with this
MixedDat.- Parameters:
subset – optional subset of entries to zero (not implemented).
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property nbytes¶
Return an estimate of the size of the data associated with this
MixedDatin bytes. This will be the correct size of the data payload, but does not take into account the (presumably small) overhead of the object and its metadata.Note that this is the process local memory usage, not the sum over all MPI processes.
- copy(other, subset=None)¶
Copy the data in this
MixedDatinto another.- Parameters:
other – The destination
MixedDatsubset – Subsets are not supported, this must be
None
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- inner(other)¶
Compute the l2 inner product.
- Parameters:
other – the other
MixedDatto compute the inner product against
- vec_context(access)¶
A context manager scattering the arrays of all components of this
MixedDatinto a contiguousPETSc.Vecand reverse scattering to the original arrays when exiting the context.- Parameters:
access – Access descriptor: READ, WRITE, or RW.
Note
The
Vecobtained from this context is in the correct order to be left multiplied by a compatibleMixedMat. In parallel it is not just a concatenation of the underlyingDats.
pyop2.types.data_carrier module¶
- class pyop2.types.data_carrier.DataCarrier¶
Bases:
ABCAbstract base class for OP2 data.
Actual objects will be
DataCarrierobjects of rank 0 (Global), rank 1 (Dat), or rank 2 (Mat)- property dtype¶
The Python type of the data.
- property ctype¶
The c type of the data.
- property name¶
User-defined label.
- property dim¶
The shape tuple of the values for each element of the object.
- property cdim¶
The scalar number of values for each member of the object. This is the product of the dim tuple.
- increment_dat_version()¶
- class pyop2.types.data_carrier.EmptyDataMixin(data, dtype, shape)¶
Bases:
ABCA mixin for
DatandGlobalobjects that takes care of allocating data on demand if the user has passed nothing in.Accessing the
_dataproperty allocates a zeroed data array if it does not already exist.
- class pyop2.types.data_carrier.VecAccessMixin(petsc_counter=None)¶
Bases:
ABC- property dat_version¶
- abstract vec_context(access)¶
- property vec¶
Context manager for a PETSc Vec appropriate for this Dat.
You’re allowed to modify the data you get back from this view.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property vec_wo¶
Context manager for a PETSc Vec appropriate for this Dat.
You’re allowed to modify the data you get back from this view, but you cannot read from it.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property vec_ro¶
Context manager for a PETSc Vec appropriate for this Dat.
You’re not allowed to modify the data you get back from this view.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
pyop2.types.dataset module¶
- class pyop2.types.dataset.DataSet(*args, **kwargs)¶
Bases:
ObjectCachedPyOP2 Data Set
Set used in the op2.Dat structures to specify the dimension of the data.
- property dim¶
The shape tuple of the values for each element of the set.
- property cdim¶
The scalar number of values for each member of the set. This is the product of the dim tuple.
- property name¶
Returns the name of the data set.
- property set¶
Returns the parent set of the data set.
- property scalar_lgmap¶
- property unblocked_lgmap¶
A PETSc LGMap mapping process-local indices to global indices for this
DataSetwith a block size of 1.
- property field_ises¶
A list of PETSc ISes defining the global indices for each set in the DataSet.
Used when extracting blocks from matrices for solvers.
- property local_ises¶
A list of PETSc ISes defining the local indices for each set in the DataSet.
Used when extracting blocks from matrices for assembly.
- property layout_vec¶
A PETSc Vec compatible with the dof layout of this DataSet.
- property dm¶
- class pyop2.types.dataset.GlobalDataSet(*args, **kwargs)¶
Bases:
DataSetA proxy
DataSetfor use in aSparsitywhere the matrix hasGlobalrows or columns.- Parameters:
global – The
Globalon which this object is based.
- property dim¶
The shape tuple of the values for each element of the set.
- property cdim¶
The scalar number of values for each member of the set. This is the product of the dim tuple.
- property name¶
Returns the name of the data set.
- property set¶
Returns the parent set of the data set.
- property size¶
The number of local entries in the Dataset (1 on rank 0)
- property unblocked_lgmap¶
A PETSc LGMap mapping process-local indices to global indices for this
DataSetwith a block size of 1.
- property local_ises¶
A list of PETSc ISes defining the local indices for each set in the DataSet.
Used when extracting blocks from matrices for assembly.
- property layout_vec¶
A PETSc Vec compatible with the dof layout of this DataSet.
- property dm¶
- class pyop2.types.dataset.MixedDataSet(*args, **kwargs)¶
Bases:
DataSetA container for a bag of
DataSets.Initialized either from a
MixedSetand an iterable or iterator ofdimsof corresponding lengthmdset = op2.MixedDataSet(mset, [dim1, ..., dimN])
or from a tuple of
Sets and an iterable ofdimsof corresponding lengthmdset = op2.MixedDataSet([set1, ..., setN], [dim1, ..., dimN])
If all
dimsare to be the same, they can also be given as anintfor either of above invocationsmdset = op2.MixedDataSet(mset, dim) mdset = op2.MixedDataSet([set1, ..., setN], dim)
Initialized from a
MixedSetwithout explicitly specifyingdimsthey default to 1mdset = op2.MixedDataSet(mset)
Initialized from an iterable or iterator of
DataSets and/orSets, whereSets are implicitly upcast toDataSets of dim 1mdset = op2.MixedDataSet([dset1, ..., dsetN])
- Parameters:
arg – a
MixedSetor an iterable or a generator expression ofSets orDataSets or a mixture of bothdims – None (the default) or an
intor an iterable or generator expression ofints, which must be of same length as arg
Warning
When using generator expressions for
argordims, these must terminate or else will cause an infinite loop.- property dim¶
The shape tuple of the values for each element of the sets.
- property cdim¶
The sum of the scalar number of values for each member of the sets. This is the sum of products of the dim tuples.
- property name¶
Returns the name of the data sets.
- property set¶
Returns the
MixedSetthisMixedDataSetis defined on.
- property layout_vec¶
A PETSc Vec compatible with the dof layout of this MixedDataSet.
- property lgmap¶
A PETSc LGMap mapping process-local indices to global indices for this
MixedDataSet.
pyop2.types.glob module¶
- class pyop2.types.glob.SetFreeDataCarrier(dim, data=None, dtype=None, name=None)¶
Bases:
DataCarrier,EmptyDataMixin- property shape¶
- property dtype¶
The Python type of the data.
- property data_ro¶
Data array.
- property data_wo¶
- property data¶
Data array.
- property data_with_halos¶
- property data_ro_with_halos¶
- property data_wo_with_halos¶
- property halo_valid¶
- copy(other, subset=None)¶
Copy the data in this
SetFreeDataCarrierinto another.- Parameters:
other – The destination
Globalsubset – A
Subsetof elements to copy (optional)
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- property split¶
- property nbytes¶
Return an estimate of the size of the data associated with this
Globalin bytes. This will be the correct size of the data payload, but does not take into account the overhead of the object and its metadata. This renders this method of little statistical significance, however it is included to make the interface consistent.
- inner(other)¶
- class pyop2.types.glob.Global(dim, data=None, dtype=None, name=None, comm=None)¶
Bases:
SetFreeDataCarrier,VecAccessMixinOP2 global value.
When a
Globalis passed to apyop2.op2.par_loop(), the access descriptor is passed by calling theGlobal. For example, if aGlobalnamedGis to be accessed for reading, this is accomplished by:G(pyop2.READ)
It is permissible to pass None as the data argument. In this case, allocation of the data buffer is postponed until it is accessed.
Note
If the data buffer is not passed in, it is implicitly initialised to be zero.
- property dataset¶
- duplicate()¶
Return a deep copy of self.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- zero(subset=None)¶
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- global_to_local_begin(access_mode)¶
Dummy halo operation for the case in which a
Globalforms part of aMixedDat.This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- global_to_local_end(access_mode)¶
Dummy halo operation for the case in which a
Globalforms part of aMixedDat.This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- local_to_global_begin(insert_mode)¶
Dummy halo operation for the case in which a
Globalforms part of aMixedDat.This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- local_to_global_end(insert_mode)¶
Dummy halo operation for the case in which a
Globalforms part of aMixedDat.This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- frozen_halo(access_mode)¶
Dummy halo operation for the case in which a
Globalforms part of aMixedDat.This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- freeze_halo(access_mode)¶
Dummy halo operation for the case in which a
Globalforms part of aMixedDat.This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- unfreeze_halo()¶
Dummy halo operation for the case in which a
Globalforms part of aMixedDat.This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. You can set PYOP2_SPMD_STRICT=1 in your environment to try and catch non-collective calls.
- class pyop2.types.glob.Constant(dim, data=None, dtype=None, name=None, comm=None)¶
Bases:
SetFreeDataCarrierOP2 constant value.
When a
Constantis passed to apyop2.op2.par_loop(), the access descriptor is alwaysAccess.READ. Used in cases where collective functionality is not required, or is not desirable. For example: objects with no associated mesh and do not have a communicator.- duplicate()¶
Return a deep copy of self.
pyop2.types.halo module¶
- class pyop2.types.halo.Halo¶
Bases:
ABCA description of a halo associated with a
pyop2.types.set.Set.The halo object describes which
pyop2.types.set.Setelements are sent where, and whichpyop2.types.set.Setelements are received from where.- abstract property comm¶
The MPI communicator for this halo.
- abstract property local_to_global_numbering¶
The mapping from process-local to process-global numbers for this halo.
- abstract global_to_local_begin(dat, insert_mode)¶
Begin an exchange from global (assembled) to local (ghosted) representation.
- Parameters:
dat – The
pyop2.types.dat.Datto exchange.insert_mode – The insertion mode.
- abstract global_to_local_end(dat, insert_mode)¶
Finish an exchange from global (assembled) to local (ghosted) representation.
- Parameters:
dat – The
pyop2.types.dat.Datto exchange.insert_mode – The insertion mode.
- abstract local_to_global_begin(dat, insert_mode)¶
Begin an exchange from local (ghosted) to global (assembled) representation.
- Parameters:
dat – The
pyop2.types.dat.Datto exchange.insert_mode – The insertion mode.
- abstract local_to_global_end(dat, insert_mode)¶
Finish an exchange from local (ghosted) to global (assembled) representation.
- Parameters:
dat – The
pyop2.types.dat.Datto exchange.insert_mode – The insertion mode.
pyop2.types.map module¶
- class pyop2.types.map.Map(iterset, toset, arity, values=None, name=None, offset=None, offset_quotient=None)¶
Bases:
objectOP2 map, a relation between two
Setobjects.Each entry in the
itersetmaps toarityentries in thetoset. When a map is used in apyop2.op2.par_loop(), it is possible to use Python index notation to select an individual entry on the right hand side of this map. There are three possibilities:No index. All
arityDatentries will be passed to the kernel.An integer:
some_map[n]. Thenth entry of the map result will be passed to the kernel.
- dtype = dtype('int32')¶
- property split¶
- property iterset¶
Setmapped from.
- property toset¶
Setmapped to.
- property arity¶
Arity of the mapping: number of toset elements mapped to per iterset element.
- property arities¶
Arity of the mapping: number of toset elements mapped to per iterset element.
- Return type:
tuple
- property values¶
Mapping array.
This only returns the map values for local points, to see the halo points too, use
values_with_halo().
- property values_with_halo¶
Mapping array.
This returns all map values (including halo points), see
values()if you only need to look at the local points.
- property name¶
User-defined label
- property offset¶
The vertical offset.
- property offset_quotient¶
The offset quotient.
- class pyop2.types.map.PermutedMap(map_, permutation)¶
Bases:
MapComposition of a standard
Mapwith a constant permutation.- Parameters:
map – The map to permute.
permutation – The permutation of the map indices.
Where normally staging to element data is performed as
local[i] = global[map[i]]
With a
PermutedMapwe instead getlocal[i] = global[map[permutation[i]]]
This might be useful if your local kernel wants data in a different order to the one that the map provides, and you don’t want two global-sized data structures.
- class pyop2.types.map.ComposedMap(*maps_, name=None)¶
Bases:
MapComposition of :class:`Map`s, :class:`PermutedMap`s, and/or :class:`ComposedMap`s.
- Parameters:
maps – The maps to compose.
Where normally staging to element data is performed as
local[i] = global[map[i]]
With a
ComposedMapwe instead getlocal[i] = global[maps_[0][maps_[1][maps_[2][...[i]]]]]
This might be useful if the map you want can be represented by a composition of existing maps.
- property values¶
Mapping array.
This only returns the map values for local points, to see the halo points too, use
values_with_halo().
- class pyop2.types.map.MixedMap(*args, **kwargs)¶
Bases:
Map,ObjectCachedA container for a bag of
Maps.- Parameters:
maps (iterable) – Iterable of
Maps
- property iterset¶
MixedSetmapped from.
- property toset¶
MixedSetmapped to.
- property arity¶
Arity of the mapping: total number of toset elements mapped to per iterset element.
- property arities¶
Arity of the mapping: number of toset elements mapped to per iterset element.
- Return type:
tuple
- property values¶
Mapping arrays excluding data for halos.
This only returns the map values for local points, to see the halo points too, use
values_with_halo().
- property values_with_halo¶
Mapping arrays including data for halos.
This returns all map values (including halo points), see
values()if you only need to look at the local points.
- property name¶
User-defined labels
- property offset¶
Vertical offsets.
- property offset_quotient¶
Offsets quotient.
pyop2.types.mat module¶
pyop2.types.set module¶
- class pyop2.types.set.Set(size, name=None, halo=None, comm=None, constrained_size=0)¶
Bases:
objectOP2 set.
- Parameters:
size (integer or list of four integers.) – The size of the set.
name (string) – The name of the set (optional).
halo – An exisiting halo to use (optional).
When the set is employed as an iteration space in a
pyop2.op2.par_loop(), the extent of any local iteration space within each set entry is indicated in brackets. See the example inpyop2.op2.par_loop()for more details.The size of the set can either be an integer, or a list of four integers. The latter case is used for running in parallel where we distinguish between:
CORE (owned and not touching halo)
OWNED (owned, touching halo)
EXECUTE HALO (not owned, but executed over redundantly)
NON EXECUTE HALO (not owned, read when executing in the execute halo)
If a single integer is passed, we assume that we’re running in serial and there is no distinction.
The division of set elements is:
[0, CORE) [CORE, OWNED) [OWNED, GHOST)
Halo send/receive data is stored on sets in a
Halo.- property indices¶
Returns iterator.
- property core_size¶
Core set size. Owned elements not touching halo elements.
- property constrained_size¶
- property size¶
Set size, owned elements.
- property total_size¶
Set size including ghost elements.
- property sizes¶
Set sizes: core, owned, execute halo, total.
- property core_part¶
- property owned_part¶
- property name¶
User-defined label
- property halo¶
Haloassociated with this Set
- property partition_size¶
Default partition size
- property layers¶
Return None (not an
ExtrudedSet).
- intersection(other)¶
- union(other)¶
- difference(other)¶
- symmetric_difference(other)¶
- class pyop2.types.set.GlobalSet(comm=None)¶
Bases:
Set- property core_size¶
Core set size. Owned elements not touching halo elements.
- property size¶
Set size, owned elements.
- property total_size¶
Total set size, including halo elements.
- property sizes¶
Set sizes: core, owned, execute halo, total.
- property name¶
User-defined label
- property halo¶
Haloassociated with this Set
- property partition_size¶
Default partition size
- class pyop2.types.set.ExtrudedSet(parent, layers, extruded_periodic=False)¶
Bases:
SetOP2 ExtrudedSet.
- Parameters:
parent (a
Set.) – The parentSetto build thisExtrudedSeton top oflayers (an integer, indicating the number of layers for every entity, or an array of shape (parent.total_size, 2) giving the start and one past the stop layer for every entity. An entry
a, b = layers[e, ...]means that the layers for entityerun over [a, b).) – The number of layers in thisExtrudedSet.
The number of layers indicates the number of time the base set is extruded in the direction of the
ExtrudedSet. As a result, there arelayers-1extruded “cells” in an extruded set.- property parent¶
- property layers¶
The layers of this extruded set.
- property layers_array¶
- class pyop2.types.set.Subset(superset, indices)¶
Bases:
ExtrudedSetOP2 subset.
- Parameters:
- property superset¶
Returns the superset Set
- property indices¶
Returns the indices pointing in the superset.
- property owned_indices¶
Return the indices that correspond to the owned entities of the superset.
- property layers_array¶
- intersection(other)¶
- union(other)¶
- difference(other)¶
- symmetric_difference(other)¶
- class pyop2.types.set.SetPartition(set, offset, size)¶
Bases:
object
- class pyop2.types.set.MixedSet(*args, **kwargs)¶
Bases:
Set,ObjectCachedA container for a bag of
Sets.- Parameters:
sets (iterable) – Iterable of
Sets orExtrudedSets
- property core_size¶
Core set size. Owned elements not touching halo elements.
- property constrained_size¶
Set size, owned constrained elements.
- property size¶
Set size, owned elements.
- property total_size¶
Total set size, including halo elements.
- property sizes¶
Set sizes: core, owned, execute halo, total.
- property name¶
User-defined labels.
- property layers¶
Numbers of layers in the extruded mesh (or None if this MixedSet is not extruded).