petsc4py.PETSc.DM¶
- class petsc4py.PETSc.DM¶
Bases:
Object
An object describing a computational grid or mesh.
Enumerations
DM
Boundary types.DM
types.Methods Summary
adaptLabel
(label)adaptMetric
(metric[, bdLabel, rgLabel])Return a mesh adapted to the specified metric field.
addCoarsenHook
(coarsenhook, restricthook[, ...])Add a callback to be executed when restricting to a coarser grid.
addField
(field[, label])Add a field to a
DM
object.appendOptionsPrefix
(prefix)Append to the prefix used for searching for options in the database.
clearDS
()Remove all discrete systems from the
DM
.Remove all fields from the
DM
.clearLabelStratum
(name, value)Remove all points from a stratum.
clearLabelValue
(name, point, value)Remove a point from a
DMLabel
with given value.clone
()Return the cloned
DM
.coarsen
([comm])Return a coarsened
DM
object.coarsenHierarchy
(nlevels)convert
(dm_type)copyDS
(dm)copyDisc
(dm)copyFields
(dm)create
([comm])Return an empty
DM
.createDS
()Create discrete systems.
Return a list of
IS
objects.Return a global vector.
createInjection
(dm)Return the injection matrix into a finer
DM
.Return the interpolation matrix to a finer
DM
.createLabel
(name)Create a label of the given name if it does not already exist.
Return a local vector.
createMassMatrix
(dmf)Return an empty matrix.
Return the restriction matrix between this
DM
and the givenDM
.createSectionSF
(localsec, globalsec)createSubDM
(fields)destroy
()Destroy the object.
getAuxiliaryVec
([label, value, part])Return an auxiliary vector for region.
Return the flags for determining variable influence.
Return the inherent block size associated with a
DM
.Return the dimension of embedding space for coordinates values.
Return the coarse
DM
.Return the number of coarsenings.
Return the coordinate
DM
.Return the dimension of embedding space for coordinates values.
Return coordinate values layout over the mesh.
Return a global vector with the coordinates associated.
Return a local vector with the coordinates associated.
getDS
()Return default
DS
.Return the topological dimension of the
DM
.getField
(index)Return the discretization object for a given
DM
field.getFieldAdjacency
(field)Return the flags for determining variable influence.
Return the
Section
encoding the global data layout for theDM
.Return a global vector.
getLGMap
()Return local mapping to global mapping.
getLabel
(name)Return the label of a given name.
getLabelIdIS
(name)getLabelName
(index)Return the name of nth label.
getLabelOutput
(name)Return the output flag for a given label.
getLabelSize
(name)Return the number of values that the
DMLabel
takes.getLabelValue
(name, point)Return the value in
DMLabel
for the given point.Return the bounding box for the piece of the
DM
.Return the
Section
encoding the local data layout for theDM
.Return a local vector.
Return the number of fields in the
DM
.Return the number of labels defined by on the
DM
.Return the prefix used for searching for options in the database.
Return the refinement level.
Return the
Section
encoding the parallel DOF overlap.getStratumIS
(name, value)Return the points in a label stratum.
getStratumSize
(name, value)Return the number of points in a label stratum.
getType
()Return the
DM
type name.globalToLocal
(vg, vl[, addv])Update local vectors from global vector.
hasLabel
(name)Determine whether the
DM
has a label.load
(viewer)Return a
DM
stored in binary.localToGlobal
(vl, vg[, addv])Update global vectors from local vector.
localToLocal
(vl, vlg[, addv])Map the values from a local vector to another local vector.
Create local coordinates for cells having periodic faces.
projectCoordinates
(disc)Project coordinates to a different space.
refine
([comm])Return a refined
DM
object.refineHierarchy
(nlevels)removeLabel
(name)Remove and destroy the label by name.
restoreGlobalVec
(vg)Restore a global vector.
restoreLocalVec
(vl)Restore a local vector.
setAppCtx
(appctx)setAuxiliaryVec
(aux, label[, value, part])Set an auxiliary vector for a specific region.
setBasicAdjacency
(useCone, useClosure)Set the flags for determining variable influence.
setCoarseDM
(dm)Set the coarse
DM
.setCoordinateDim
(dim)Set the dimension of embedding space for coordinates values.
Set a global vector that holds the coordinates.
Set a local vector with the ghost point holding the coordinates.
setDimension
(dim)Set the topological dimension of the
DM
.setField
(index, field[, label])Set the discretization object for a given
DM
field.setFieldAdjacency
(field, useCone, useClosure)Set the flags for determining variable influence.
Configure the object from the options database.
setGlobalSection
(sec)setKSPComputeOperators
(operators[, args, kargs])Matrix associated with the linear system.
setLabelOutput
(name, output)Set if a given label should be saved to a view.
setLabelValue
(name, point, value)Set a point to a
DMLabel
with a given value.setLocalSection
(sec)setMatType
(mat_type)Set matrix type to be used by
DM.createMat
.setNumFields
(numFields)Set the number of fields in the
DM
.setOptionsPrefix
(prefix)Set the prefix used for searching for options in the database.
setPointSF
(sf)setRefineLevel
(level)Set the number of refinements.
setSNESFunction
(function[, args, kargs])Set
SNES
residual evaluation function.setSNESJacobian
(jacobian[, args, kargs])Set the
SNES
Jacobian evaluation function.setSectionSF
(sf)Set the
Section
encoding the parallel DOF overlap for theDM
.setType
(dm_type)Build a
DM
.setUp
()Return the data structure.
setVecType
(vec_type)Set the type of vector.
view
([viewer])View the
DM
.viewFromOptions
(name[, obj])View a
DM
based in the options.Attributes Summary
Methods Documentation
- adaptMetric(metric, bdLabel=None, rgLabel=None)¶
Return a mesh adapted to the specified metric field.
- Parameters:
- Return type:
See also
petsc.DMAdaptMetric
- addCoarsenHook(coarsenhook, restricthook, args=None, kargs=None)¶
Add a callback to be executed when restricting to a coarser grid.
Logically collective.
- Parameters:
coarsenhook (DMCoarsenHookFunction) – The coarsen hook function.
restricthook (DMRestrictHookFunction) – The restrict hook function.
args (tuple[Any, ...] | None) – Positional arguments for the hooks.
kargs (dict[str, Any] | None) – Keyword arguments for the hooks.
- Return type:
See also
petsc.DMCoarsenHookAdd
- addField(field, label=None)¶
Add a field to a
DM
object.Logically collective.
- Parameters:
- Return type:
See also
petsc.DMAddField
- appendOptionsPrefix(prefix)¶
Append to the prefix used for searching for options in the database.
Logically collective.
See also
Working with PETSc options (TODO),
setOptionsPrefix
,petsc.DMAppendOptionsPrefix
- clearDS()¶
Remove all discrete systems from the
DM
.Logically collective.
See also
petsc.DMClearDS
Source code at petsc4py/PETSc/DM.pyx:683
- Return type:
- clearFields()¶
Remove all fields from the
DM
.Logically collective.
See also
petsc.DMClearFields
Source code at petsc4py/PETSc/DM.pyx:642
- Return type:
- clearLabelStratum(name, value)¶
Remove all points from a stratum.
Not collective.
See also
petsc.DMClearLabelStratum
- clearLabelValue(name, point, value)¶
Remove a point from a
DMLabel
with given value.Not collective.
- Parameters:
- Return type:
See also
petsc.DMClearLabelValue
- clone()¶
Return the cloned
DM
.Collective.
See also
petsc.DMClone
Source code at petsc4py/PETSc/DM.pyx:142
- Return type:
- coarsen(comm=None)¶
Return a coarsened
DM
object.Collective.
- Parameters:
comm (Comm | None) – MPI communicator, defaults to
Sys.getDefaultComm
.- Return type:
See also
petsc.DMCoarsen
- coarsenHierarchy(nlevels)¶
Coarsen this
DM
and return the coarsenedDM
hierarchy.Collective.
See also
petsc.DMCoarsenHierarchy
- convert(dm_type)¶
Return a
DM
converted to anotherDM
.Collective.
See also
DM.Type
,petsc.DMConvert
- copyDS(dm)¶
Copy the discrete systems for this
DM
into anotherDM
.Collective.
See also
petsc.DMCopyDS
- copyDisc(dm)¶
Copy fields and discrete systems of a
DM
into anotherDM
.Collective.
See also
petsc.DMCopyDisc
- copyFields(dm)¶
Copy the discretizations of this
DM
into anotherDM
.Collective.
See also
petsc.DMCopyFields
- create(comm=None)¶
Return an empty
DM
.Collective.
- Parameters:
comm (Comm | None) – MPI communicator, defaults to
Sys.getDefaultComm
.- Return type:
See also
petsc.DMCreate
- createDS()¶
Create discrete systems.
Collective.
See also
petsc.DMCreateDS
Source code at petsc4py/PETSc/DM.pyx:671
- Return type:
- createFieldDecomposition()¶
Return a list of
IS
objects.Not collective.
Notes
The user is responsible for freeing all requested arrays.
See also
petsc.DMCreateFieldDecomposition
- createGlobalVec()¶
Return a global vector.
Collective.
See also
petsc.DMCreateGlobalVector
Source code at petsc4py/PETSc/DM.pyx:774
- Return type:
- createInjection(dm)¶
Return the injection matrix into a finer
DM
.Collective.
See also
petsc.DMCreateInjection
- createInterpolation(dm)¶
Return the interpolation matrix to a finer
DM
.Collective.
See also
petsc.DMCreateInterpolation
- createLabel(name)¶
Create a label of the given name if it does not already exist.
Not collective.
See also
petsc.DMCreateLabel
- createLocalVec()¶
Return a local vector.
Not collective.
See also
petsc.DMCreateLocalVector
Source code at petsc4py/PETSc/DM.pyx:788
- Return type:
- createMassMatrix(dmf)¶
Return the mass matrix between this
DM
and the givenDM
.Collective.
See also
petsc.DMCreateMassMatrix
- createMat()¶
Return an empty matrix.
Collective.
See also
petsc.DMCreateMatrix
Source code at petsc4py/PETSc/DM.pyx:1166
- Return type:
- createRestriction(dm)¶
Return the restriction matrix between this
DM
and the givenDM
.Collective.
See also
petsc.DMCreateRestriction
- createSectionSF(localsec, globalsec)¶
Create the
SF
encoding the parallel DOF overlap for theDM
.- Parameters:
- Return type:
Notes
Encoding based on the
Section
describing the data layout.See also
DM.getSectionSF
,petsc.DMCreateSectionSF
- createSubDM(fields)¶
Return
IS
andDM
encapsulating a subproblem.Not collective.
- Returns:
- Parameters:
- Return type:
See also
petsc.DMCreateSubDM
- destroy()¶
Destroy the object.
Collective.
See also
petsc.DMDestroy
Source code at petsc4py/PETSc/DM.pyx:108
- Return type:
- getAppCtx()¶
- getAuxiliaryVec(label=None, value=0, part=0)¶
Return an auxiliary vector for region.
Not collective.
- Parameters:
- Return type:
See also
DM.getLabel
,petsc.DMGetAuxiliaryVec
- getBasicAdjacency()¶
Return the flags for determining variable influence.
Not collective.
- Returns:
- Return type:
See also
petsc.DMGetBasicAdjacency
- getBlockSize()¶
Return the inherent block size associated with a
DM
.Not collective.
See also
petsc.DMGetBlockSize
Source code at petsc4py/PETSc/DM.pyx:746
- Return type:
- getBoundingBox()¶
Return the dimension of embedding space for coordinates values.
Not collective.
See also
petsc.DMGetBoundingBox
- getCoarseDM()¶
Return the coarse
DM
.Collective.
See also
petsc.DMGetCoarseDM
Source code at petsc4py/PETSc/DM.pyx:954
- Return type:
- getCoarsenLevel()¶
Return the number of coarsenings.
Not collective.
See also
petsc.DMGetCoarsenLevel
Source code at petsc4py/PETSc/DM.pyx:1415
- Return type:
- getCoordinateDM()¶
Return the coordinate
DM
.Collective.
See also
petsc.DMGetCoordinateDM
Source code at petsc4py/PETSc/DM.pyx:982
- Return type:
- getCoordinateDim()¶
Return the dimension of embedding space for coordinates values.
Not collective.
See also
petsc.DMGetCoordinateDim
Source code at petsc4py/PETSc/DM.pyx:225
- Return type:
- getCoordinateSection()¶
Return coordinate values layout over the mesh.
Collective.
See also
petsc.DMGetCoordinateSection
Source code at petsc4py/PETSc/DM.pyx:997
- Return type:
- getCoordinates()¶
Return a global vector with the coordinates associated.
Collective.
See also
petsc.DMGetCoordinates
Source code at petsc4py/PETSc/DM.pyx:1029
- Return type:
- getCoordinatesLocal()¶
Return a local vector with the coordinates associated.
Collective the first time it is called.
See also
petsc.DMGetCoordinatesLocal
Source code at petsc4py/PETSc/DM.pyx:1061
- Return type:
- getDS()¶
Return default
DS
.Not collective.
See also
petsc.DMGetDS
Source code at petsc4py/PETSc/DM.pyx:695
- Return type:
- getDimension()¶
Return the topological dimension of the
DM
.Not collective.
See also
petsc.DMGetDimension
Source code at petsc4py/PETSc/DM.pyx:193
- Return type:
- getField(index)¶
Return the discretization object for a given
DM
field.Not collective.
See also
petsc.DMGetField
- getFieldAdjacency(field)¶
Return the flags for determining variable influence.
Not collective.
- Parameters:
field (int) – The field number.
- Returns:
- Return type:
See also
petsc.DMGetAdjacency
- getGlobalSection()¶
Return the
Section
encoding the global data layout for theDM
.See also
petsc.DMGetGlobalSection
Source code at petsc4py/PETSc/DM.pyx:1541
- Return type:
- getGlobalVec()¶
Return a global vector.
Collective.
See also
petsc.DMGetGlobalVector
Source code at petsc4py/PETSc/DM.pyx:802
- Return type:
- getLGMap()¶
Return local mapping to global mapping.
Collective.
See also
petsc.DMGetLocalToGlobalMapping
Source code at petsc4py/PETSc/DM.pyx:937
- Return type:
- getLabel(name)¶
Return the label of a given name.
Not collective.
See also
petsc.DMGetLabel
- getLabelIdIS(name)¶
Return an
IS
of all values that theDMLabel
takes.Not collective.
See also
petsc.DMLabelGetValueIS
,petsc.DMGetLabelIdIS
- getLabelName(index)¶
Return the name of nth label.
Not collective.
See also
petsc.DMGetLabelName
- getLabelOutput(name)¶
Return the output flag for a given label.
Not collective.
See also
petsc.DMGetLabelOutput
- getLabelSize(name)¶
Return the number of values that the
DMLabel
takes.Not collective.
See also
petsc.DMLabelGetNumValues
,petsc.DMGetLabelSize
- getLabelValue(name, point)¶
Return the value in
DMLabel
for the given point.Not collective.
See also
petsc.DMGetLabelValue
- getLocalBoundingBox()¶
Return the bounding box for the piece of the
DM
.Not collective.
See also
petsc.DMGetLocalBoundingBox
- getLocalSection()¶
Return the
Section
encoding the local data layout for theDM
.See also
petsc.DMGetGlobalSection
Source code at petsc4py/PETSc/DM.pyx:1518
- Return type:
- getLocalVec()¶
Return a local vector.
Not collective.
See also
petsc.DMGetLocalVector
Source code at petsc4py/PETSc/DM.pyx:835
- Return type:
- getNumFields()¶
Return the number of fields in the
DM
.Not collective.
See also
petsc.DMGetNumFields
Source code at petsc4py/PETSc/DM.pyx:554
- Return type:
- getNumLabels()¶
Return the number of labels defined by on the
DM
.Not collective.
See also
petsc.DMGetNumLabels
Source code at petsc4py/PETSc/DM.pyx:1634
- Return type:
- getOptionsPrefix()¶
Return the prefix used for searching for options in the database.
Not collective.
See also
Working with PETSc options (TODO),
setOptionsPrefix
,petsc.DMGetOptionsPrefix
Source code at petsc4py/PETSc/DM.pyx:271
- Return type:
- getPointSF()¶
Return the
SF
encoding the parallel DOF overlap for theDM
.See also
petsc.DMGetPointSF
Source code at petsc4py/PETSc/DM.pyx:1611
- Return type:
- getRefineLevel()¶
Return the refinement level.
Not collective.
See also
petsc.DMGetRefineLevel
Source code at petsc4py/PETSc/DM.pyx:1383
- Return type:
- getSectionSF()¶
Return the
Section
encoding the parallel DOF overlap.See also
petsc.DMGetSectionSF
Source code at petsc4py/PETSc/DM.pyx:1584
- Return type:
- getStratumIS(name, value)¶
Return the points in a label stratum.
Not collective.
See also
petsc.DMGetStratumIS
- getStratumSize(name, value)¶
Return the number of points in a label stratum.
Not collective.
See also
petsc.DMGetStratumSize
- getType()¶
Return the
DM
type name.Not collective.
See also
petsc.DMGetType
Source code at petsc4py/PETSc/DM.pyx:179
- Return type:
- globalToLocal(vg, vl, addv=None)¶
Update local vectors from global vector.
Neighborwise collective.
- Parameters:
vg (Vec) – The global vector.
vl (Vec) – The local vector.
addv (InsertModeSpec | None) – Insertion mode.
- Return type:
See also
petsc.DMGlobalToLocalBegin
,petsc.DMGlobalToLocalEnd
- load(viewer)¶
Return a
DM
stored in binary.Collective.
- Parameters:
viewer (Viewer) – Viewer used to store the
DM
, likeViewer.Type.BINARY
orViewer.Type.HDF5
.- Return type:
Notes
When using
Viewer.Type.HDF5
format, one can save multipleDMPlex
meshes in a single HDF5 files. This in turn requires one to name theDMPlex
object withObject.setName
before saving it withDM.view
and before loading it withDM.load
for identification of the mesh object.See also
DM.view
,DM.load
,Object.setName
,petsc.DMLoad
- localToGlobal(vl, vg, addv=None)¶
Update global vectors from local vector.
Neighborwise collective.
- Parameters:
vl (Vec) – The local vector.
vg (Vec) – The global vector.
addv (InsertModeSpec | None) – Insertion mode.
- Return type:
See also
petsc.DMLocalToGlobalBegin
,petsc.DMLocalToGlobalEnd
- localToLocal(vl, vlg, addv=None)¶
Map the values from a local vector to another local vector.
Neighborwise collective.
- Parameters:
vl (Vec) – The local vector.
vlg (Vec) – The global vector.
addv (InsertModeSpec | None) – Insertion mode.
- Return type:
See also
petsc.DMLocalToLocalBegin
,petsc.DMLocalToLocalEnd
- localizeCoordinates()¶
Create local coordinates for cells having periodic faces.
Collective.
Notes
Used if the mesh is periodic.
See also
petsc.DMLocalizeCoordinates
Source code at petsc4py/PETSc/DM.pyx:1126
- Return type:
- projectCoordinates(disc)¶
Project coordinates to a different space.
See also
petsc.DMProjectCoordinates
- refine(comm=None)¶
Return a refined
DM
object.Collective.
- Parameters:
comm (Comm | None) – MPI communicator, defaults to
Sys.getDefaultComm
.- Return type:
See also
petsc.DMRefine
- refineHierarchy(nlevels)¶
Refine this
DM
and return the refinedDM
hierarchy.Collective.
See also
petsc.DMRefineHierarchy
- removeLabel(name)¶
Remove and destroy the label by name.
Not collective.
See also
petsc.DMRemoveLabel
- restoreGlobalVec(vg)¶
Restore a global vector.
Not collective.
See also
petsc.DMRestoreGlobalVector
- restoreLocalVec(vl)¶
Restore a local vector.
Not collective.
See also
petsc.DMRestoreLocalVector
- setAppCtx(appctx)¶
- setAuxiliaryVec(aux, label, value=0, part=0)¶
Set an auxiliary vector for a specific region.
Not collective.
- Parameters:
- Return type:
See also
petsc.DMGetLabel
,petsc.DMSetAuxiliaryVec
- setBasicAdjacency(useCone, useClosure)¶
Set the flags for determining variable influence.
Not collective.
- Parameters:
- Return type:
See also
petsc.DMSetBasicAdjacency
- setCoordinateDim(dim)¶
Set the dimension of embedding space for coordinates values.
Not collective.
See also
petsc.DMSetCoordinateDim
- setCoordinates(c)¶
Set a global vector that holds the coordinates.
Collective.
See also
petsc.DMSetCoordinates
- setCoordinatesLocal(c)¶
Set a local vector with the ghost point holding the coordinates.
Not collective.
See also
petsc.DMSetCoordinatesLocal
- setDimension(dim)¶
Set the topological dimension of the
DM
.Collective.
See also
petsc.DMSetDimension
- setField(index, field, label=None)¶
Set the discretization object for a given
DM
field.Logically collective.
- Parameters:
- Return type:
See also
petsc.DMSetField
- setFieldAdjacency(field, useCone, useClosure)¶
Set the flags for determining variable influence.
Not collective.
- Parameters:
- Return type:
See also
petsc.DMSetAdjacency
- setFromOptions()¶
Configure the object from the options database.
Collective.
See also
Working with PETSc options (TODO),
petsc.DMSetFromOptions
Source code at petsc4py/PETSc/DM.pyx:299
- Return type:
- setGlobalSection(sec)¶
Set the
Section
encoding the global data layout for theDM
.See also
petsc.DMSetGlobalSection
- setKSPComputeOperators(operators, args=None, kargs=None)¶
Matrix associated with the linear system.
Collective.
- Parameters:
- Return type:
See also
petsc.DMKSPSetComputeOperators
- setLabelOutput(name, output)¶
Set if a given label should be saved to a view.
Not collective.
- Parameters:
- Return type:
See also
petsc.DMSetLabelOutput
- setLabelValue(name, point, value)¶
Set a point to a
DMLabel
with a given value.Not collective.
- Parameters:
- Return type:
See also
petsc.DMSetLabelValue
- setLocalSection(sec)¶
Set the
Section
encoding the local data layout for theDM
.See also
petsc.DMSetLocalSection
- setMatType(mat_type)¶
Set matrix type to be used by
DM.createMat
.Logically collective.
Notes
The option
-dm_mat_type
is used to set the matrix type.See also
Working with PETSc options (TODO),
petsc.DMSetMatType
- setNumFields(numFields)¶
Set the number of fields in the
DM
.Logically collective.
See also
petsc.DMSetNumFields
- setOptionsPrefix(prefix)¶
Set the prefix used for searching for options in the database.
Logically collective.
See also
Working with PETSc options (TODO),
getOptionsPrefix
,petsc.DMSetOptionsPrefix
- setPointSF(sf)¶
Set the
SF
encoding the parallel DOF overlap for theDM
.See also
petsc.DMSetPointSF
- setRefineLevel(level)¶
Set the number of refinements.
Not collective.
See also
petsc.DMSetRefineLevel
- setSNESFunction(function, args=None, kargs=None)¶
Set
SNES
residual evaluation function.Not collective.
- Parameters:
- Return type:
See also
SNES.setFunction
,petsc.DMSNESSetFunction
- setSNESJacobian(jacobian, args=None, kargs=None)¶
Set the
SNES
Jacobian evaluation function.Not collective.
- Parameters:
- Return type:
See also
SNES.setJacobian
,petsc.DMSNESSetJacobian
- setSectionSF(sf)¶
Set the
Section
encoding the parallel DOF overlap for theDM
.See also
petsc.DMSetSectionSF
- setType(dm_type)¶
Build a
DM
.Collective.
Notes
DM
types are available inDM.Type
class.See also
DM.Type
,petsc.DMSetType
- setUp()¶
Return the data structure.
Collective.
See also
petsc.DMSetUp
Source code at petsc4py/PETSc/DM.pyx:334
- Return type:
- setVecType(vec_type)¶
Set the type of vector.
Logically collective.
See also
Vec.Type
,petsc.DMSetVecType
- viewFromOptions(name, obj=None)¶
View a
DM
based in the options.Collective.
- Parameters:
- Return type:
See also
petsc.DMViewFromOptions
Attributes Documentation
- appctx¶
- ds¶