Skip to main content
`Ctrl`+`K`

# petsc4py.PETSc.DM

class petsc4py.PETSc.DM

  Bases: `Object`

  An object describing a computational grid or mesh.

  Enumerations

  `BoundaryType` | `DM` Boundary types.
  `PolytopeType` | The `DM` cell types.
  `ReorderDefaultFlag` | The `DM` reordering default flags.
  `Type` | `DM` types.

  Methods Summary

  `adaptLabel`(label) | Adapt a `DM` based on a `DMLabel`.
  `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`.
  `clearFields`() | 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) | Coarsen this `DM` and return the coarsened `DM` hierarchy.
  `convert`(dm_type) | Return a `DM` converted to another `DM`.
  `copyDS`(dm[, minDegree, maxDegree]) | Copy the discrete systems for this `DM` into another `DM`.
  `copyDisc`(dm) | Copy fields and discrete systems of a `DM` into another `DM`.
  `copyFields`(dm[, minDegree, maxDegree]) | Copy the discretizations of this `DM` into another `DM`.
  `create`([comm]) | Return an empty `DM`.
  `createDS`() | Create discrete systems.
  `createFieldDecomposition`() | Return field splitting information.
  `createGlobalVec`() | Return a global vector.
  `createInjection`(dm) | Return the injection matrix into a finer `DM`.
  `createInterpolation`(dm) | Return the interpolation matrix to a finer `DM`.
  `createLabel`(name) | Create a label of the given name if it does not already exist.
  `createLocalVec`() | Return a local vector.
  `createMassMatrix`(dmf) | Return the mass matrix between this `DM` and the given `DM`.
  `createMat`() | Return an empty matrix.
  `createRestriction`(dm) | Return the restriction matrix between this `DM` and the given `DM`.
  `createSectionSF`(localsec, globalsec) | Create the `SF` encoding the parallel DOF overlap for the `DM`.
  `createSubDM`(fields) | Return `IS` and `DM` encapsulating a subproblem.
  `destroy`() | Destroy the object.
  `getAppCtx`() | Return the application context.
  `getAuxiliaryVec`([label, value, part]) | Return an auxiliary vector for region.
  `getBasicAdjacency`() | Return the flags for determining variable influence.
  `getBlockSize`() | Return the inherent block size associated with a `DM`.
  `getBoundingBox`() | Return the dimension of embedding space for coordinates values.
  `getCellCoordinateDM`() | Return the cell coordinate `DM`.
  `getCellCoordinateSection`() | Return the cell coordinate layout over the `DM`.
  `getCellCoordinates`() | Return a global vector with the cellwise coordinates.
  `getCellCoordinatesLocal`() | Return a local vector with the cellwise coordinates.
  `getCoarseDM`() | Return the coarse `DM`.
  `getCoarsenLevel`() | Return the number of coarsenings.
  `getCoordinateDM`() | Return the coordinate `DM`.
  `getCoordinateDim`() | Return the dimension of embedding space for coordinates values.
  `getCoordinateSection`() | Return coordinate values layout over the mesh.
  `getCoordinates`() | Return a global vector with the coordinates associated.
  `getCoordinatesLocal`() | Return a local vector with the coordinates associated.
  `getCoordinatesLocalized`() | Check if the coordinates have been localized for cells.
  `getDS`() | Return default `DS`.
  `getDimension`() | 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.
  `getGlobalSection`() | Return the `Section` encoding the global data layout for the `DM`.
  `getGlobalVec`([name]) | Return a global vector.
  `getLGMap`() | Return local mapping to global mapping.
  `getLabel`(name) | Return the label of a given name.
  `getLabelIdIS`(name) | Return an `IS` of all values that the `DMLabel` takes.
  `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.
  `getLocalBoundingBox`() | Return the bounding box for the piece of the `DM`.
  `getLocalSection`() | Return the `Section` encoding the local data layout for the `DM`.
  `getLocalVec`([name]) | Return a local vector.
  `getNumFields`() | Return the number of fields in the `DM`.
  `getNumLabels`() | Return the number of labels defined by on the `DM`.
  `getOptionsPrefix`() | Return the prefix used for searching for options in the database.
  `getPeriodicity`() | Set the description of mesh periodicity.
  `getPointSF`() | Return the `SF` encoding the parallel DOF overlap for the `DM`.
  `getRefineLevel`() | Return the refinement level.
  `getSectionSF`() | 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.
  `getUseNatural`() | Get the flag for constructing a global-to-natural map.
  `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.
  `localizeCoordinates`() | Create local coordinates for cells having periodic faces.
  `refine`([comm]) | Return a refined `DM` object.
  `refineHierarchy`(nlevels) | Refine this `DM` and return the refined `DM` hierarchy.
  `removeLabel`(name) | Remove and destroy the label by name.
  `restoreGlobalVec`(vg[, name]) | Restore a global vector obtained with `getGlobalVec`.
  `restoreLocalVec`(vl[, name]) | Restore a local vector obtained with `getLocalVec`.
  `setAppCtx`(appctx) | Set the application context.
  `setAuxiliaryVec`(aux, label[, value, part]) | Set an auxiliary vector for a specific region.
  `setBasicAdjacency`(useCone, useClosure) | Set the flags for determining variable influence.
  `setCellCoordinateDM`(dm) | Set the cell coordinate `DM`.
  `setCellCoordinateSection`(dim, sec) | Set the cell coordinate layout over the `DM`.
  `setCellCoordinates`(c) | Set a global vector with the cellwise coordinates.
  `setCellCoordinatesLocal`(c) | Set a local vector with the cellwise coordinates.
  `setCoarseDM`(dm) | Set the coarse `DM`.
  `setCoordinateDim`(dim) | Set the dimension of embedding space for coordinates values.
  `setCoordinateDisc`(disc, localized, project) | Project coordinates to a different space.
  `setCoordinates`(c) | Set a global vector that holds the coordinates.
  `setCoordinatesLocal`(c) | 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.
  `setFromOptions`() | Configure the object from the options database.
  `setGlobalSection`(sec) | Set the `Section` encoding the global data layout for the `DM`.
  `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) | Set the `Section` encoding the local data layout for the `DM`.
  `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.
  `setPeriodicity`(maxCell, Lstart, L) | Set the description of mesh periodicity.
  `setPointSF`(sf) | Set the `SF` encoding the parallel DOF overlap for the `DM`.
  `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 the `DM`.
  `setType`(dm_type) | Build a `DM`.
  `setUp`() | Return the data structure.
  `setUseNatural`(useNatural) | Set the flag for constructing a global-to-natural map.
  `setVecType`(vec_type) | Set the type of vector.
  `view`([viewer]) | View the `DM`.

  Attributes Summary

  `appctx` | Application context.
  `ds` | Discrete space.

  Methods Documentation

  adaptLabel(label)

    Adapt a `DM` based on a `DMLabel`.

    Collective.

    Parameters:

      label (str) – The name of the `DMLabel`.

    Return type:

      DM

    See also

    `DMAdaptLabel`

    Source code at petsc4py/PETSc/DM.pyx:1750

  adaptMetric(metric, bdLabel=None, rgLabel=None)

    Return a mesh adapted to the specified metric field.

    Collective.

    Parameters:

      - metric (Vec) – The metric to which the mesh is adapted, defined vertex-wise.

      - bdLabel (str | None) – Label for boundary tags.

      - rgLabel (str | None) – Label for cell tag.

    Return type:

      DM

    See also

    `DMAdaptMetric`

    Source code at petsc4py/PETSc/DM.pyx:1773

  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:

      None

    See also

    `DMCoarsenHookAdd`

    Source code at petsc4py/PETSc/DM.pyx:2437

  addField(field, label=None)

    Add a field to a `DM` object.

    Logically collective.

    Parameters:

      - field (Object) – The discretization object.

      - label (str | None) – The name of the label indicating the support of the field, or `None` for the entire mesh.

    Return type:

      None

    See also

    `DMAddField`

    Source code at petsc4py/PETSc/DM.pyx:648

  appendOptionsPrefix(prefix)

    Append to the prefix used for searching for options in the database.

    Logically collective.

    See also

    Working with PETSc options, `setOptionsPrefix`, `DMAppendOptionsPrefix`

    Source code at petsc4py/PETSc/DM.pyx:298

    Parameters:

      prefix (str | None)

    Return type:

      None

  clearDS()

    Remove all discrete systems from the `DM`.

    Logically collective.

    See also

    `DMClearDS`

    Source code at petsc4py/PETSc/DM.pyx:728

    Return type:

      None

  clearFields()

    Remove all fields from the `DM`.

    Logically collective.

    See also

    `DMClearFields`

    Source code at petsc4py/PETSc/DM.pyx:671

    Return type:

      None

  clearLabelStratum(name, value)

    Remove all points from a stratum.

    Not collective.

    Parameters:

      - name (str) – The label name.

      - value (int) – The stratum value.

    Return type:

      None

    See also

    `DMClearLabelStratum`

    Source code at petsc4py/PETSc/DM.pyx:2229

  clearLabelValue(name, point, value)

    Remove a point from a `DMLabel` with given value.

    Not collective.

    Parameters:

      - name (str) – The label name.

      - point (int) – The mesh point.

      - value (int) – The label value for the point.

    Return type:

      None

    See also

    `DMClearLabelValue`

    Source code at petsc4py/PETSc/DM.pyx:2115

  clone()

    Return the cloned `DM` .

    Collective.

    See also

    `DMClone`

    Source code at petsc4py/PETSc/DM.pyx:155

    Return type:

      DM

  coarsen(comm=None)

    Return a coarsened `DM` object.

    Collective.

    Parameters:

      comm (Comm | None) – MPI communicator, defaults to `Sys.getDefaultComm`.

    Return type:

      DM

    See also

    `DMCoarsen`

    Source code at petsc4py/PETSc/DM.pyx:1624

  coarsenHierarchy(nlevels)

    Coarsen this `DM` and return the coarsened `DM` hierarchy.

    Collective.

    Parameters:

      nlevels (int) – The number of levels of coarsening.

    Return type:

      list

    See also

    `DMCoarsenHierarchy`

    Source code at petsc4py/PETSc/DM.pyx:1675

  convert(dm_type)

    Return a `DM` converted to another `DM`.

    Collective.

    Parameters:

      dm_type (Type | str) – The new `DM.Type`, use `“same”` for the same type.

    Return type:

      DM

    See also

    `DM.Type`, `DMConvert`

    Source code at petsc4py/PETSc/DM.pyx:1577

  copyDS(dm, minDegree=None, maxDegree=None)

    Copy the discrete systems for this `DM` into another `DM`.

    Collective.

    Parameters:

      - dm (DM) – The `DM` that the discrete fields are copied into.

      - minDegree – The minimum polynommial degree for the discretization, or `None` for no limit

      - maxDegree – The maximum polynommial degree for the discretization, or `None` for no limit

    Return type:

      None

    See also

    `DMCopyDS`

    Source code at petsc4py/PETSc/DM.pyx:755

  copyDisc(dm)

    Copy fields and discrete systems of a `DM` into another `DM`.

    Collective.

    Parameters:

      dm (DM) – The `DM` that the fields and discrete systems are copied into.

    Return type:

      None

    See also

    `DMCopyDisc`

    Source code at petsc4py/PETSc/DM.pyx:788

  copyFields(dm, minDegree=None, maxDegree=None)

    Copy the discretizations of this `DM` into another `DM`.

    Collective.

    Parameters:

      - dm (DM) – The `DM` that the fields are copied into.

      - minDegree – The minimum polynommial degree for the discretization, or `None` for no limit

      - maxDegree – The maximum polynommial degree for the discretization, or `None` for no limit

    Return type:

      None

    See also

    `DMCopyFields`

    Source code at petsc4py/PETSc/DM.pyx:683

  create(comm=None)

    Return an empty `DM`.

    Collective.

    Parameters:

      comm (Comm | None) – MPI communicator, defaults to `Sys.getDefaultComm`.

    Return type:

      Self

    See also

    `DMCreate`

    Source code at petsc4py/PETSc/DM.pyx:134

  createDS()

    Create discrete systems.

    Collective.

    See also

    `DMCreateDS`

    Source code at petsc4py/PETSc/DM.pyx:716

    Return type:

      None

  createFieldDecomposition()

    Return field splitting information.

    Collective.

    See also

    `DMCreateFieldDecomposition`

    Source code at petsc4py/PETSc/DM.pyx:2327

    Return type:

      tuple[list, list, list]

  createGlobalVec()

    Return a global vector.

    Collective.

    See also

    `DMCreateGlobalVector`

    Source code at petsc4py/PETSc/DM.pyx:835

    Return type:

      Vec

  createInjection(dm)

    Return the injection matrix into a finer `DM`.

    Collective.

    Parameters:

      dm (DM) – The second, finer `DM` object.

    Return type:

      Mat

    See also

    `DMCreateInjection`

    Source code at petsc4py/PETSc/DM.pyx:1539

  createInterpolation(dm)

    Return the interpolation matrix to a finer `DM`.

    Collective.

    Parameters:

      dm (DM) – The second, finer `DM`.

    Return type:

      tuple[Mat, Vec]

    See also

    `DMCreateInterpolation`

    Source code at petsc4py/PETSc/DM.pyx:1518

  createLabel(name)

    Create a label of the given name if it does not already exist.

    Not collective.

    Parameters:

      name (str) – The label name.

    Return type:

      None

    See also

    `DMCreateLabel`

    Source code at petsc4py/PETSc/DM.pyx:2027

  createLocalVec()

    Return a local vector.

    Not collective.

    See also

    `DMCreateLocalVector`

    Source code at petsc4py/PETSc/DM.pyx:849

    Return type:

      Vec

  createMassMatrix(dmf)

    Return the mass matrix between this `DM` and the given `DM`.

    Collective.

    Parameters:

      dmf (DM) – The second `DM`.

    Return type:

      Mat

    See also

    `DMCreateMassMatrix`

    Source code at petsc4py/PETSc/DM.pyx:1499

  createMat()

    Return an empty matrix.

    Collective.

    See also

    `DMCreateMatrix`

    Source code at petsc4py/PETSc/DM.pyx:1485

    Return type:

      Mat

  createRestriction(dm)

    Return the restriction matrix between this `DM` and the given `DM`.

    Collective.

    Parameters:

      dm (DM) – The second, finer `DM` object.

    Return type:

      Mat

    See also

    `DMCreateRestriction`

    Source code at petsc4py/PETSc/DM.pyx:1558

  createSectionSF(localsec, globalsec)

    Create the `SF` encoding the parallel DOF overlap for the `DM`.

    Collective.

    Parameters:

      - localsec (Section) – Describe the local data layout.

      - globalsec (Section) – Describe the global data layout.

    Return type:

      None

    Notes

    Encoding based on the `Section` describing the data layout.

    See also

    `DM.getSectionSF`, `DMCreateSectionSF`

    Source code at petsc4py/PETSc/DM.pyx:1891

  createSubDM(fields)

    Return `IS` and `DM` encapsulating a subproblem.

    Not collective.

    Returns:

      - iset (`IS`) – The global indices for all the degrees of freedom.

      - subdm (`DM`) – The `DM` for the subproblem.

    Parameters:

      fields (Sequence[int])

    Return type:

      tuple[IS, DM]

    See also

    `DMCreateSubDM`

    Source code at petsc4py/PETSc/DM.pyx:483

  destroy()

    Destroy the object.

    Collective.

    See also

    `DMDestroy`

    Source code at petsc4py/PETSc/DM.pyx:121

    Return type:

      Self

  getAppCtx()

    Return the application context.

    Source code at petsc4py/PETSc/DM.pyx:343

    Return type:

      Any

  getAuxiliaryVec(label=None, value=0, part=0)

    Return an auxiliary vector for region.

    Not collective.

    Parameters:

      - label (str | None) – The name of the `DMLabel`.

      - value (int | None) – Indicate the region.

      - part (int | None) – The equation part, or 0 is unused.

    Return type:

      Vec

    See also

    `DM.getLabel`, `DMGetAuxiliaryVec`

    Source code at petsc4py/PETSc/DM.pyx:540

  getBasicAdjacency()

    Return the flags for determining variable influence.

    Not collective.

    Returns:

      - useCone (`bool`) – Whether adjacency uses cone information.

      - useClosure (`bool`) – Whether adjacency is computed using full closure information.

    Return type:

      tuple[bool, bool]

    See also

    `DMGetBasicAdjacency`

    Source code at petsc4py/PETSc/DM.pyx:407

  getBlockSize()

    Return the inherent block size associated with a `DM`.

    Not collective.

    See also

    `DMGetBlockSize`

    Source code at petsc4py/PETSc/DM.pyx:807

    Return type:

      int

  getBoundingBox()

    Return the dimension of embedding space for coordinates values.

    Not collective.

    See also

    `DMGetBoundingBox`

    Source code at petsc4py/PETSc/DM.pyx:1348

    Return type:

      tuple[tuple[float, float], …]

  getCellCoordinateDM()

    Return the cell coordinate `DM`.

    Collective.

    See also

    `DMGetCellCoordinateDM`

    Source code at petsc4py/PETSc/DM.pyx:1196

    Return type:

      DM

  getCellCoordinateSection()

    Return the cell coordinate layout over the `DM`.

    Collective.

    See also

    `DMGetCellCoordinateSection`

    Source code at petsc4py/PETSc/DM.pyx:1231

    Return type:

      Section

  getCellCoordinates()

    Return a global vector with the cellwise coordinates.

    Collective.

    See also

    `DMGetCellCoordinates`

    Source code at petsc4py/PETSc/DM.pyx:1263

    Return type:

      Vec

  getCellCoordinatesLocal()

    Return a local vector with the cellwise coordinates.

    Collective.

    See also

    `DMGetCellCoordinatesLocal`

    Source code at petsc4py/PETSc/DM.pyx:1295

    Return type:

      Vec

  getCoarseDM()

    Return the coarse `DM`.

    Collective.

    See also

    `DMGetCoarseDM`

    Source code at petsc4py/PETSc/DM.pyx:1057

    Return type:

      DM

  getCoarsenLevel()

    Return the number of coarsenings.

    Not collective.

    See also

    `DMGetCoarsenLevel`

    Source code at petsc4py/PETSc/DM.pyx:1734

    Return type:

      int

  getCoordinateDM()

    Return the coordinate `DM`.

    Collective.

    See also

    `DMGetCoordinateDM`

    Source code at petsc4py/PETSc/DM.pyx:1085

    Return type:

      DM

  getCoordinateDim()

    Return the dimension of embedding space for coordinates values.

    Not collective.

    See also

    `DMGetCoordinateDim`

    Source code at petsc4py/PETSc/DM.pyx:238

    Return type:

      int

  getCoordinateSection()

    Return coordinate values layout over the mesh.

    Collective.

    See also

    `DMGetCoordinateSection`

    Source code at petsc4py/PETSc/DM.pyx:1100

    Return type:

      Section

  getCoordinates()

    Return a global vector with the coordinates associated.

    Collective.

    See also

    `DMGetCoordinates`

    Source code at petsc4py/PETSc/DM.pyx:1132

    Return type:

      Vec

  getCoordinatesLocal()

    Return a local vector with the coordinates associated.

    Collective the first time it is called.

    See also

    `DMGetCoordinatesLocal`

    Source code at petsc4py/PETSc/DM.pyx:1164

    Return type:

      Vec

  getCoordinatesLocalized()

    Check if the coordinates have been localized for cells.

    Not collective.

    See also

    `DMGetCoordinatesLocalized`

    Source code at petsc4py/PETSc/DM.pyx:1334

    Return type:

      bool

  getDS()

    Return default `DS`.

    Not collective.

    See also

    `DMGetDS`

    Source code at petsc4py/PETSc/DM.pyx:740

    Return type:

      DS

  getDimension()

    Return the topological dimension of the `DM`.

    Not collective.

    See also

    `DMGetDimension`

    Source code at petsc4py/PETSc/DM.pyx:206

    Return type:

      int

  getField(index)

    Return the discretization object for a given `DM` field.

    Not collective.

    Parameters:

      index (int) – The field number.

    Return type:

      tuple[Object, None]

    See also

    `DMGetField`

    Source code at petsc4py/PETSc/DM.pyx:623

  getFieldAdjacency(field)

    Return the flags for determining variable influence.

    Not collective.

    Parameters:

      field (int) – The field number.

    Returns:

      - useCone (`bool`) – Whether adjacency uses cone information.

      - useClosure (`bool`) – Whether adjacency is computed using full closure information.

    Return type:

      tuple[bool, bool]

    See also

    `DMGetAdjacency`

    Source code at petsc4py/PETSc/DM.pyx:453

  getGlobalSection()

    Return the `Section` encoding the global data layout for the `DM`.

    Collective the first time it is called.

    See also

    `DMGetGlobalSection`

    Source code at petsc4py/PETSc/DM.pyx:1867

    Return type:

      Section

  getGlobalVec(name=None)

    Return a global vector.

    Collective.

    Parameters:

      name (str | None) – The optional name to retrieve a persistent vector.

    Return type:

      Vec

    Notes

    When done with the vector, it must be restored using `restoreGlobalVec`.

    See also

    `restoreGlobalVec`, `DMGetGlobalVector`, `DMGetNamedGlobalVector`

    Source code at petsc4py/PETSc/DM.pyx:863

  getLGMap()

    Return local mapping to global mapping.

    Collective.

    See also

    `DMGetLocalToGlobalMapping`

    Source code at petsc4py/PETSc/DM.pyx:1040

    Return type:

      LGMap

  getLabel(name)

    Return the label of a given name.

    Not collective.

    See also

    `DMGetLabel`

    Source code at petsc4py/PETSc/DM.pyx:1809

    Parameters:

      name (str)

    Return type:

      DMLabel

  getLabelIdIS(name)

    Return an `IS` of all values that the `DMLabel` takes.

    Not collective.

    Parameters:

      name (str) – The label name.

    Return type:

      IS

    See also

    `DMLabelGetValueIS`, `DMGetLabelIdIS`

    Source code at petsc4py/PETSc/DM.pyx:2160

  getLabelName(index)

    Return the name of nth label.

    Not collective.

    Parameters:

      index (int) – The label number.

    Return type:

      str

    See also

    `DMGetLabelName`

    Source code at petsc4py/PETSc/DM.pyx:1986

  getLabelOutput(name)

    Return the output flag for a given label.

    Not collective.

    Parameters:

      name (str) – The label name.

    Return type:

      bool

    See also

    `DMGetLabelOutput`

    Source code at petsc4py/PETSc/DM.pyx:2273

  getLabelSize(name)

    Return the number of values that the `DMLabel` takes.

    Not collective.

    Parameters:

      name (str) – The label name.

    Return type:

      int

    See also

    `DMLabelGetNumValues`, `DMGetLabelSize`

    Source code at petsc4py/PETSc/DM.pyx:2139

  getLabelValue(name, point)

    Return the value in `DMLabel` for the given point.

    Not collective.

    Parameters:

      - name (str) – The label name.

      - point (int) – The mesh point

    Return type:

      int

    See also

    `DMGetLabelValue`

    Source code at petsc4py/PETSc/DM.pyx:2068

  getLocalBoundingBox()

    Return the bounding box for the piece of the `DM`.

    Not collective.

    See also

    `DMGetLocalBoundingBox`

    Source code at petsc4py/PETSc/DM.pyx:1365

    Return type:

      tuple[tuple[float, float], …]

  getLocalSection()

    Return the `Section` encoding the local data layout for the `DM`.

    Not collective.

    See also

    `DMGetGlobalSection`

    Source code at petsc4py/PETSc/DM.pyx:1840

    Return type:

      Section

  getLocalVec(name=None)

    Return a local vector.

    Not collective.

    Parameters:

      name (str | None) – The optional name to retrieve a persistent vector.

    Return type:

      Vec

    Notes

    When done with the vector, it must be restored using `restoreLocalVec`.

    See also

    `restoreLocalVec`, `DMGetLocalVector`, `DMGetNamedLocalVector`

    Source code at petsc4py/PETSc/DM.pyx:917

  getNumFields()

    Return the number of fields in the `DM`.

    Not collective.

    See also

    `DMGetNumFields`

    Source code at petsc4py/PETSc/DM.pyx:583

    Return type:

      int

  getNumLabels()

    Return the number of labels defined by on the `DM`.

    Not collective.

    See also

    `DMGetNumLabels`

    Source code at petsc4py/PETSc/DM.pyx:1972

    Return type:

      int

  getOptionsPrefix()

    Return the prefix used for searching for options in the database.

    Not collective.

    See also

    Working with PETSc options, `setOptionsPrefix`, `DMGetOptionsPrefix`

    Source code at petsc4py/PETSc/DM.pyx:284

    Return type:

      str

  getPeriodicity()

    Set the description of mesh periodicity.

    Not collective.

    Parameters:

      - maxCell – The longest allowable cell dimension in each direction.

      - Lstart – The start of each coordinate direction, usually [0, 0, 0]

      - L – The periodic length of each coordinate direction, or -1 for non-periodic

    Return type:

      tuple[ArrayReal, ArrayReal, ArrayReal]

    See also

    `DMSetPeriodicity`

    Source code at petsc4py/PETSc/DM.pyx:1399

  getPointSF()

    Return the `SF` encoding the parallel DOF overlap for the `DM`.

    Not collective.

    See also

    `DMGetPointSF`

    Source code at petsc4py/PETSc/DM.pyx:1945

    Return type:

      SF

  getRefineLevel()

    Return the refinement level.

    Not collective.

    See also

    `DMGetRefineLevel`

    Source code at petsc4py/PETSc/DM.pyx:1702

    Return type:

      int

  getSectionSF()

    Return the `Section` encoding the parallel DOF overlap.

    Collective the first time it is called.

    See also

    `DMGetSectionSF`

    Source code at petsc4py/PETSc/DM.pyx:1914

    Return type:

      SF

  getStratumIS(name, value)

    Return the points in a label stratum.

    Not collective.

    Parameters:

      - name (str) – The label name.

      - value (int) – The stratum value.

    Return type:

      IS

    See also

    `DMGetStratumIS`

    Source code at petsc4py/PETSc/DM.pyx:2205

  getStratumSize(name, value)

    Return the number of points in a label stratum.

    Not collective.

    Parameters:

      - name (str) – The label name.

      - value (int) – The stratum value.

    Return type:

      int

    See also

    `DMGetStratumSize`

    Source code at petsc4py/PETSc/DM.pyx:2181

  getType()

    Return the `DM` type name.

    Not collective.

    See also

    `DMGetType`

    Source code at petsc4py/PETSc/DM.pyx:192

    Return type:

      str

  getUseNatural()

    Get the flag for constructing a global-to-natural map.

    Not collective.

    Returns:

      useNatural – Whether a global-to-natural map is created.

    Return type:

      `bool`

    See also

    `DMGetUseNatural`

    Source code at petsc4py/PETSc/DM.pyx:349

  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:

      None

    See also

    `DMGlobalToLocalBegin`, `DMGlobalToLocalEnd`

    Source code at petsc4py/PETSc/DM.pyx:971

  hasLabel(name)

    Determine whether the `DM` has a label.

    Not collective.

    Parameters:

      name (str) – The label name.

    Return type:

      bool

    See also

    `DMHasLabel`

    Source code at petsc4py/PETSc/DM.pyx:2006

  load(viewer)

    Return a `DM` stored in binary.

    Collective.

    Parameters:

      viewer (Viewer) – Viewer used to store the `DM`, like `Viewer.Type.BINARY` or `Viewer.Type.HDF5`.

    Return type:

      Self

    Notes

    When using `Viewer.Type.HDF5` format, one can save multiple `DMPlex` meshes in a single HDF5 files. This in turn requires one to name the `DMPlex` object with `Object.setName` before saving it with `DM.view` and before loading it with `DM.load` for identification of the mesh object.

    See also

    `DM.view`, `DM.load`, `Object.setName`, `DMLoad`

    Source code at petsc4py/PETSc/DM.pyx:95

  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:

      None

    See also

    `DMLocalToGlobalBegin`, `DMLocalToGlobalEnd`

    Source code at petsc4py/PETSc/DM.pyx:994

  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:

      None

    See also

    `DMLocalToLocalBegin`, `DMLocalToLocalEnd`

    Source code at petsc4py/PETSc/DM.pyx:1017

  localizeCoordinates()

    Create local coordinates for cells having periodic faces.

    Collective.

    Notes

    Used if the mesh is periodic.

    See also

    `DMLocalizeCoordinates`

    Source code at petsc4py/PETSc/DM.pyx:1382

    Return type:

      None

  refine(comm=None)

    Return a refined `DM` object.

    Collective.

    Parameters:

      comm (Comm | None) – MPI communicator, defaults to `Sys.getDefaultComm`.

    Return type:

      DM

    See also

    `DMRefine`

    Source code at petsc4py/PETSc/DM.pyx:1600

  refineHierarchy(nlevels)

    Refine this `DM` and return the refined `DM` hierarchy.

    Collective.

    Parameters:

      nlevels (int) – The number of levels of refinement.

    Return type:

      list

    See also

    `DMRefineHierarchy`

    Source code at petsc4py/PETSc/DM.pyx:1648

  removeLabel(name)

    Remove and destroy the label by name.

    Not collective.

    Parameters:

      name (str) – The label name.

    Return type:

      None

    See also

    `DMRemoveLabel`

    Source code at petsc4py/PETSc/DM.pyx:2046

  restoreGlobalVec(vg, name=None)

    Restore a global vector obtained with `getGlobalVec`.

    Logically collective.

    Parameters:

      - vg (Vec) – The global vector.

      - name (str | None) – The name used to retrieve the persistent vector, if any.

    Return type:

      None

    See also

    `getGlobalVec`, `DMRestoreGlobalVector`, `DMRestoreNamedGlobalVector`

    Source code at petsc4py/PETSc/DM.pyx:892

  restoreLocalVec(vl, name=None)

    Restore a local vector obtained with `getLocalVec`.

    Not collective.

    Parameters:

      - vl (Vec) – The local vector.

      - name (str | None) – The name used to retrieve the persistent vector, if any.

    Return type:

      None

    See also

    `getLocalVec`, `DMRestoreLocalVector`, `DMRestoreNamedLocalVector`

    Source code at petsc4py/PETSc/DM.pyx:946

  setAppCtx(appctx)

    Set the application context.

    Source code at petsc4py/PETSc/DM.pyx:339

    Parameters:

      appctx (Any)

    Return type:

      None

  setAuxiliaryVec(aux, label, value=0, part=0)

    Set an auxiliary vector for a specific region.

    Not collective.

    Parameters:

      - aux (Vec) – The auxiliary vector.

      - label (DMLabel | None) – The name of the `DMLabel`.

      - value – Indicate the region.

      - part – The equation part, or 0 is unused.

    Return type:

      None

    See also

    `DMGetLabel`, `DMSetAuxiliaryVec`

    Source code at petsc4py/PETSc/DM.pyx:510

  setBasicAdjacency(useCone, useClosure)

    Set the flags for determining variable influence.

    Not collective.

    Parameters:

      - useCone (`bool`) – Whether adjacency uses cone information.

      - useClosure (`bool`) – Whether adjacency is computed using full closure information.

    Return type:

      None

    See also

    `DMSetBasicAdjacency`

    Source code at petsc4py/PETSc/DM.pyx:386

  setCellCoordinateDM(dm)

    Set the cell coordinate `DM`.

    Collective.

    Parameters:

      dm (DM) – The cell coordinate `DM`.

    Return type:

      None

    See also

    `DMSetCellCoordinateDM`

    Source code at petsc4py/PETSc/DM.pyx:1179

  setCellCoordinateSection(dim, sec)

    Set the cell coordinate layout over the `DM`.

    Collective.

    Parameters:

      - dim (int) – The embedding dimension, or `DETERMINE`.

      - sec (Section) – The cell coordinate `Section`.

    Return type:

      None

    See also

    `DMSetCellCoordinateSection`

    Source code at petsc4py/PETSc/DM.pyx:1211

  setCellCoordinates(c)

    Set a global vector with the cellwise coordinates.

    Collective.

    Parameters:

      c (Vec) – The global cell coordinate vector.

    Return type:

      None

    See also

    `DMSetCellCoordinates`

    Source code at petsc4py/PETSc/DM.pyx:1246

  setCellCoordinatesLocal(c)

    Set a local vector with the cellwise coordinates.

    Not collective.

    Parameters:

      c (Vec) – The local cell coordinate vector.

    Return type:

      None

    See also

    `DMSetCellCoordinatesLocal`

    Source code at petsc4py/PETSc/DM.pyx:1278

  setCoarseDM(dm)

    Set the coarse `DM`.

    Collective.

    See also

    `DMSetCoarseDM`

    Source code at petsc4py/PETSc/DM.pyx:1072

    Parameters:

      dm (DM)

    Return type:

      None

  setCoordinateDim(dim)

    Set the dimension of embedding space for coordinates values.

    Not collective.

    Parameters:

      dim (int) – The embedding dimension.

    Return type:

      None

    See also

    `DMSetCoordinateDim`

    Source code at petsc4py/PETSc/DM.pyx:252

  setCoordinateDisc(disc, localized, project)

    Project coordinates to a different space.

    Collective.

    Parameters:

      - disc (FE) – The new coordinates discretization.

      - localized (bool) – Set a localized (DG) coordinate space

      - project (bool) – Project coordinates to new discretization

    Return type:

      Self

    See also

    `DMSetCoordinateDisc`

    Source code at petsc4py/PETSc/DM.pyx:1310

  setCoordinates(c)

    Set a global vector that holds the coordinates.

    Collective.

    Parameters:

      c (Vec) – Coordinate Vector.

    Return type:

      None

    See also

    `DMSetCoordinates`

    Source code at petsc4py/PETSc/DM.pyx:1115

  setCoordinatesLocal(c)

    Set a local vector with the ghost point holding the coordinates.

    Not collective.

    Parameters:

      c (Vec) – Coordinate Vector.

    Return type:

      None

    See also

    `DMSetCoordinatesLocal`

    Source code at petsc4py/PETSc/DM.pyx:1147

  setDimension(dim)

    Set the topological dimension of the `DM`.

    Collective.

    Parameters:

      dim (int) – Topological dimension.

    Return type:

      None

    See also

    `DMSetDimension`

    Source code at petsc4py/PETSc/DM.pyx:220

  setField(index, field, label=None)

    Set the discretization object for a given `DM` field.

    Logically collective.

    Parameters:

      - index (int) – The field number.

      - field (Object) – The discretization object.

      - label (str | None) – The name of the label indicating the support of the field, or `None` for the entire mesh.

    Return type:

      None

    See also

    `DMSetField`

    Source code at petsc4py/PETSc/DM.pyx:597

  setFieldAdjacency(field, useCone, useClosure)

    Set the flags for determining variable influence.

    Not collective.

    Parameters:

      - field (`int`) – The field number.

      - useCone (`bool`) – Whether adjacency uses cone information.

      - useClosure (`bool`) – Whether adjacency is computed using full closure information.

    Return type:

      None

    See also

    `DMSetAdjacency`

    Source code at petsc4py/PETSc/DM.pyx:429

  setFromOptions()

    Configure the object from the options database.

    Collective.

    See also

    Working with PETSc options, `DMSetFromOptions`

    Source code at petsc4py/PETSc/DM.pyx:312

    Return type:

      None

  setGlobalSection(sec)

    Set the `Section` encoding the global data layout for the `DM`.

    Collective.

    See also

    `DMSetGlobalSection`

    Source code at petsc4py/PETSc/DM.pyx:1855

    Parameters:

      sec (Section)

    Return type:

      None

  setKSPComputeOperators(operators, args=None, kargs=None)

    Matrix associated with the linear system.

    Collective.

    Parameters:

      - operator – Callback function to compute the operators.

      - args (tuple[Any, ...] | None) – Positional arguments for the callback.

      - kargs (dict[str, Any] | None) – Keyword arguments for the callback.

    Return type:

      None

    See also

    `DMKSPSetComputeOperators`

    Source code at petsc4py/PETSc/DM.pyx:2299

  setLabelOutput(name, output)

    Set if a given label should be saved to a view.

    Not collective.

    Parameters:

      - name (str) – The label name.

      - output (bool) – If `True`, the label is saved to the viewer.

    Return type:

      None

    See also

    `DMSetLabelOutput`

    Source code at petsc4py/PETSc/DM.pyx:2251

  setLabelValue(name, point, value)

    Set a point to a `DMLabel` with a given value.

    Not collective.

    Parameters:

      - name (str) – The label name.

      - point (int) – The mesh point.

      - value (int) – The label value for the point.

    Return type:

      None

    See also

    `DMSetLabelValue`

    Source code at petsc4py/PETSc/DM.pyx:2091

  setLocalSection(sec)

    Set the `Section` encoding the local data layout for the `DM`.

    Collective.

    See also

    `DMSetLocalSection`

    Source code at petsc4py/PETSc/DM.pyx:1828

    Parameters:

      sec (Section)

    Return type:

      None

  setMatType(mat_type)

    Set matrix type to be used by `DM.createMat`.

    Logically collective.

    Parameters:

      mat_type (Type | str) – The matrix type.

    Return type:

      None

    Notes

    The option `-dm_mat_type` is used to set the matrix type.

    See also

    Working with PETSc options, `DMSetMatType`

    Source code at petsc4py/PETSc/DM.pyx:1462

  setNumFields(numFields)

    Set the number of fields in the `DM`.

    Logically collective.

    See also

    `DMSetNumFields`

    Source code at petsc4py/PETSc/DM.pyx:570

    Parameters:

      numFields (int)

    Return type:

      None

  setOptionsPrefix(prefix)

    Set the prefix used for searching for options in the database.

    Logically collective.

    See also

    Working with PETSc options, `getOptionsPrefix`, `DMSetOptionsPrefix`

    Source code at petsc4py/PETSc/DM.pyx:270

    Parameters:

      prefix (str | None)

    Return type:

      None

  setPeriodicity(maxCell, Lstart, L)

    Set the description of mesh periodicity.

    Logically collective.

    Parameters:

      - maxCell (Sequence[float]) – The longest allowable cell dimension in each direction.

      - Lstart (Sequence[float]) – The start of each coordinate direction, usually [0, 0, 0]

      - L (Sequence[float]) – The periodic length of each coordinate direction, or -1 for non-periodic

    Return type:

      None

    See also

    `DMSetPeriodicity`

    Source code at petsc4py/PETSc/DM.pyx:1435

  setPointSF(sf)

    Set the `SF` encoding the parallel DOF overlap for the `DM`.

    Logically collective.

    See also

    `DMSetPointSF`

    Source code at petsc4py/PETSc/DM.pyx:1960

    Parameters:

      sf (SF)

    Return type:

      None

  setRefineLevel(level)

    Set the number of refinements.

    Not collective.

    Parameters:

      - nlevels – The number of refinement.

      - level (int)

    Return type:

      None

    See also

    `DMSetRefineLevel`

    Source code at petsc4py/PETSc/DM.pyx:1716

  setSNESFunction(function, args=None, kargs=None)

    Set `SNES` residual evaluation function.

    Not collective.

    Parameters:

      - function (SNESFunction) – The callback.

      - args (tuple[Any, ...] | None) – Positional arguments for the callback.

      - kargs (dict[str, Any] | None) – Keyword arguments for the callback.

    Return type:

      None

    See also

    `SNES.setFunction`, `DMSNESSetFunction`

    Source code at petsc4py/PETSc/DM.pyx:2374

  setSNESJacobian(jacobian, args=None, kargs=None)

    Set the `SNES` Jacobian evaluation function.

    Not collective.

    Parameters:

      - jacobian (SNESJacobianFunction) – The Jacobian callback.

      - args (tuple[Any, ...] | None) – Positional arguments for the callback.

      - kargs (dict[str, Any] | None) – Keyword arguments for the callback.

    Return type:

      None

    See also

    `SNES.setJacobian`, `DMSNESSetJacobian`

    Source code at petsc4py/PETSc/DM.pyx:2406

  setSectionSF(sf)

    Set the `Section` encoding the parallel DOF overlap for the `DM`.

    Logically collective.

    See also

    `DMSetSectionSF`

    Source code at petsc4py/PETSc/DM.pyx:1929

    Parameters:

      sf (SF)

    Return type:

      None

  setType(dm_type)

    Build a `DM`.

    Collective.

    Parameters:

      dm_type (Type | str) – The type of `DM`.

    Return type:

      None

    Notes

    `DM` types are available in `DM.Type` class.

    See also

    `DM.Type`, `DMSetType`

    Source code at petsc4py/PETSc/DM.pyx:169

  setUp()

    Return the data structure.

    Collective.

    See also

    `DMSetUp`

    Source code at petsc4py/PETSc/DM.pyx:324

    Return type:

      Self

  setUseNatural(useNatural)

    Set the flag for constructing a global-to-natural map.

    Not collective.

    Parameters:

      useNatural (`bool`) – Whether a global-to-natural map is created.

    Return type:

      None

    See also

    `DMSetUseNatural`

    Source code at petsc4py/PETSc/DM.pyx:368

  setVecType(vec_type)

    Set the type of vector.

    Logically collective.

    See also

    `Vec.Type`, `DMSetVecType`

    Source code at petsc4py/PETSc/DM.pyx:821

    Parameters:

      vec_type (Type | str)

    Return type:

      None

  view(viewer=None)

    View the `DM`.

    Collective.

    Parameters:

      viewer (Viewer | None) – The DM viewer.

    Return type:

      None

    See also

    `DMView`

    Source code at petsc4py/PETSc/DM.pyx:76

  Attributes Documentation

  appctx

    Application context.

    Source code at petsc4py/PETSc/DM.pyx:2490

  ds

    Discrete space.

    Source code at petsc4py/PETSc/DM.pyx:2500