DMClone — PETSc 3.21.4 documentation

Skip to main content
`Ctrl`+`K`

# DMClone

Creates a `DM` object with the same topology as the original.

## Synopsis

    #include "petscdm.h"
    #include "petscdmlabel.h"
    #include "petscds.h"
    PetscErrorCode DMClone(DM dm, DM *newdm)

Collective

## Input Parameter

- dm - The original `DM` object

## Output Parameter

- newdm - The new `DM` object

## Notes

For some `DM` implementations this is a shallow clone, the result of which may share (reference counted) information with its parent. For example, `DMClone()` applied to a `DMPLEX` object will result in a new `DMPLEX` that shares the topology with the original `DMPLEX`. It does not share the `PetscSection` of the original `DM`.

The clone is considered set up if the original has been set up.

Use `DMConvert()` for a general way to create new `DM` from a given `DM`

## See Also

DM Basics, `DM`, `DMDestroy()`, `DMCreate()`, `DMSetType()`, `DMSetLocalSection()`, `DMSetGlobalSection()`, `DMPLEX`, `DMConvert()`

## Level

beginner

## Location

src/dm/interface/dm.c

## Examples

src/snes/tutorials/ex11.c
src/ts/tutorials/ex11_sa.c
src/tao/tutorials/ex3.c
src/ts/tutorials/ex45.c
src/snes/tutorials/ex7.c
src/snes/tutorials/ex12.c
src/snes/tutorials/ex36.c
src/ts/tutorials/ex18.c
src/snes/tutorials/ex77.c
src/snes/tutorials/ex13.c

## Implementations

DMClone_DA() in src/dm/impls/da/dacreate.c
DMClone_Forest() in src/dm/impls/forest/forest.c
DMClone_pforest() in src/dm/impls/forest/p4est/pforest.h
DMClone_Moab() in src/dm/impls/moab/dmmoab.cxx
DMClone_Network() in src/dm/impls/network/networkcreate.c
DMClone_Plex() in src/dm/impls/plex/plexcreate.c
DMClone_Stag() in src/dm/impls/stag/stag.c
DMClone_Swarm() in src/dm/impls/swarm/swarm.c

Index of all DM routines
Table of Contents for all manual pages
Index of all manual pages