DMStag (Staggered Grids)
DMStag manages staggered grid discretizations, commonly used in computational fluid dynamics and geophysics. It handles variables defined at different locations (vertices, edges, faces, element centers).
Overview
DMStag provides:
- Staggered grid support for MAC/marker-and-cell schemes
- Multiple degrees of freedom at vertices, edges, faces, and element centers
- Efficient communication for staggered variables
- 1D, 2D, and 3D support
- Boundary type specification
Basic Usage Pattern
using PETSc, MPI
petsclib = PETSc.petsclibs[1]
PETSc.initialize(petsclib)
# Get PETSc types
PetscInt = petsclib.PetscInt
# Create a 2D staggered grid
# Velocity components on edges, pressure at cell centers
dm = LibPETSc.DMStagCreate2d(
petsclib,
MPI.COMM_WORLD,
LibPETSc.DM_BOUNDARY_NONE,
LibPETSc.DM_BOUNDARY_NONE,
PetscInt(10), PetscInt(10), # global dimensions
PetscInt(LibPETSc.PETSC_DECIDE),
PetscInt(LibPETSc.PETSC_DECIDE),
PetscInt(0), # dof per vertex
PetscInt(1), # dof per edge (velocity)
PetscInt(1), # dof per element (pressure)
LibPETSc.DMSTAG_STENCIL_BOX,
PetscInt(1), # stencil width
C_NULL, C_NULL
)
# Set up
LibPETSc.DMSetFromOptions(petsclib, dm)
LibPETSc.DMSetUp(petsclib, dm)
# Create vectors
x = LibPETSc.DMCreateGlobalVector(petsclib, dm)
# Access staggered components
# Use DMStagGetLocationSlot to get indices for each component
# Cleanup
LibPETSc.VecDestroy(petsclib, x)
LibPETSc.DMDestroy(petsclib, dm)
PETSc.finalize(petsclib)DMStag Functions
PETSc.LibPETSc.DMStagCreate1d — Method
dm::PetscDM = DMStagCreate1d(petsclib::PetscLibType,comm::MPI_Comm, bndx::DMBoundaryType, M::PetscInt, dof0::PetscInt, dof1::PetscInt, stencilType::DMStagStencilType, stencilWidth::PetscInt, lx::Vector{PetscInt})Create an object to manage data living on the elements and vertices of a parallelized regular 1D grid.
Collective
Input Parameters:
comm- MPI communicatorbndx- boundary type:DM_BOUNDARY_NONE,DM_BOUNDARY_PERIODIC, orDM_BOUNDARY_GHOSTEDM- global number of elementsdof0- number of degrees of freedom per vertex/0-celldof1- number of degrees of freedom per element/1-cellstencilType- ghost/halo region type:DMSTAG_STENCIL_BOXorDMSTAG_STENCIL_NONEstencilWidth- width, in elements, of halo/ghost regionlx- array of local sizes, of length equal to the comm size, summing toMorNULL
Output Parameter:
dm- the newDMSTAGobject
Options Database Keys:
-dm_view- callsDMViewFromOptions()at the conclusion ofDMSetUp()-stag_grid_x <nx>- number of elements in the x direction-stag_ghost_stencil_width- width of ghost region, in elements-stag_boundary_type_x <none,ghosted,periodic>-DMBoundaryTypevalue
Level: beginner
Notes: You must call DMSetUp() after this call before using the DM. If you wish to use the options database (see the keys above) to change values in the DMSTAG, you must call DMSetFromOptions() after this function but before DMSetUp().
See also:
DMSTAG, DMStagCreate2d(), DMStagCreate3d(), DMDestroy(), DMView(), DMCreateGlobalVector(), DMCreateLocalVector(), DMLocalToGlobalBegin(), DMDACreate1d()
External Links
- PETSc Manual:
DMStag/DMStagCreate1d
PETSc.LibPETSc.DMStagCreate2d — Method
dm::PetscDM = DMStagCreate2d(petsclib::PetscLibType,comm::MPI_Comm, bndx::DMBoundaryType, bndy::DMBoundaryType, M::PetscInt, N::PetscInt, m::PetscInt, n::PetscInt, dof0::PetscInt, dof1::PetscInt, dof2::PetscInt, stencilType::DMStagStencilType, stencilWidth::PetscInt, lx::Vector{PetscInt}, ly::Vector{PetscInt})Create an object to manage data living on the elements, faces, and vertices of a parallelized regular 2D grid.
Collective
Input Parameters:
comm- MPI communicatorbndx- x boundary type,DM_BOUNDARY_NONE,DM_BOUNDARY_PERIODIC, orDM_BOUNDARY_GHOSTEDbndy- y boundary type,DM_BOUNDARY_NONE,DM_BOUNDARY_PERIODIC, orDM_BOUNDARY_GHOSTEDM- global number of elements in x directionN- global number of elements in y directionm- number of ranks in the x direction (may bePETSC_DECIDE)n- number of ranks in the y direction (may bePETSC_DECIDE)dof0- number of degrees of freedom per vertex/0-celldof1- number of degrees of freedom per face/1-celldof2- number of degrees of freedom per element/2-cellstencilType- ghost/halo region type:DMSTAG_STENCIL_NONE,DMSTAG_STENCIL_BOX, orDMSTAG_STENCIL_STARstencilWidth- width, in elements, of halo/ghost regionlx- array of local x element counts, of length equal tom, summing toM, orNULLly- array of local y element counts, of length equal ton, summing toN, orNULL
Output Parameter:
dm- the newDMSTAGobject
Options Database Keys:
-dm_view- callsDMViewFromOptions()at the conclusion ofDMSetUp()-stag_grid_x <nx>- number of elements in the x direction-stag_grid_y <ny>- number of elements in the y direction-stag_ranks_x <rx>- number of ranks in the x direction-stag_ranks_y <ry>- number of ranks in the y direction-stag_ghost_stencil_width- width of ghost region, in elements-stag_boundary_type_x <none,ghosted,periodic>-DMBoundaryTypevalue-stag_boundary_type_y <none,ghosted,periodic>-DMBoundaryTypevalue
Level: beginner
Notes: You must call DMSetUp() after this call, before using the DM. If you wish to use the options database (see the keys above) to change values in the DMSTAG, you must call DMSetFromOptions() after this function but before DMSetUp().
See also:
DMSTAG, DMStagCreate1d(), DMStagCreate3d(), DMDestroy(), DMView(), DMCreateGlobalVector(), DMCreateLocalVector(), DMLocalToGlobalBegin(), DMDACreate2d()
External Links
- PETSc Manual:
DMStag/DMStagCreate2d
PETSc.LibPETSc.DMStagCreate3d — Method
dm::PetscDM = DMStagCreate3d(petsclib::PetscLibType,comm::MPI_Comm, bndx::DMBoundaryType, bndy::DMBoundaryType, bndz::DMBoundaryType, M::PetscInt, N::PetscInt, P::PetscInt, m::PetscInt, n::PetscInt, p::PetscInt, dof0::PetscInt, dof1::PetscInt, dof2::PetscInt, dof3::PetscInt, stencilType::DMStagStencilType, stencilWidth::PetscInt, lx::Vector{PetscInt}, ly::Vector{PetscInt}, lz::Vector{PetscInt})Create an object to manage data living on the elements, faces, edges, and vertices of a parallelized regular 3D grid.
Collective
Input Parameters:
comm- MPI communicatorbndx- x boundary type,DM_BOUNDARY_NONE,DM_BOUNDARY_PERIODIC, orDM_BOUNDARY_GHOSTEDbndy- y boundary type,DM_BOUNDARY_NONE,DM_BOUNDARY_PERIODIC, orDM_BOUNDARY_GHOSTEDbndz- z boundary type,DM_BOUNDARY_NONE,DM_BOUNDARY_PERIODIC, orDM_BOUNDARY_GHOSTEDM- global number of elements in x directionN- global number of elements in y directionP- global number of elements in z directionm- number of ranks in the x direction (may bePETSC_DECIDE)n- number of ranks in the y direction (may bePETSC_DECIDE)p- number of ranks in the z direction (may bePETSC_DECIDE)dof0- number of degrees of freedom per vertex/0-celldof1- number of degrees of freedom per edge/1-celldof2- number of degrees of freedom per face/2-celldof3- number of degrees of freedom per element/3-cellstencilType- ghost/halo region type:DMSTAG_STENCIL_NONE,DMSTAG_STENCIL_BOX, orDMSTAG_STENCIL_STARstencilWidth- width, in elements, of halo/ghost regionlx- array of local x element counts, of length equal tom, summing toM, orNULLly- arrays of local y element counts, of length equal ton, summing toN, orNULLlz- arrays of local z element counts, of length equal top, summing toP, orNULL
Output Parameter:
dm- the newDMSTAGobject
Options Database Keys:
-dm_view- callsDMViewFromOptions()at the conclusion ofDMSetUp()-stag_grid_x <nx>- number of elements in the x direction-stag_grid_y <ny>- number of elements in the y direction-stag_grid_z <nz>- number of elements in the z direction-stag_ranks_x <rx>- number of ranks in the x direction-stag_ranks_y <ry>- number of ranks in the y direction-stag_ranks_z <rz>- number of ranks in the z direction-stag_ghost_stencil_width- width of ghost region, in elements-stag_boundary_type x <none,ghosted,periodic>-DMBoundaryTypevalue-stag_boundary_type y <none,ghosted,periodic>-DMBoundaryTypevalue-stag_boundary_type z <none,ghosted,periodic>-DMBoundaryTypevalue
Level: beginner
Notes: You must call DMSetUp() after this call before using the DM. If you wish to use the options database (see the keys above) to change values in the DMSTAG, you must call DMSetFromOptions() after this function but before DMSetUp().
See also:
DMSTAG, DMStagCreate1d(), DMStagCreate2d(), DMDestroy(), DMView(), DMCreateGlobalVector(), DMCreateLocalVector(), DMLocalToGlobalBegin(), DMDACreate3d()
External Links
- PETSc Manual:
DMStag/DMStagCreate3d
PETSc.LibPETSc.DMStagCreateCompatibleDMStag — Method
newdm::PetscDM = DMStagCreateCompatibleDMStag(petsclib::PetscLibType,dm::PetscDM, dof0::PetscInt, dof1::PetscInt, dof2::PetscInt, dof3::PetscInt)create a compatible DMSTAG with different dof/stratum
Collective
Input Parameters:
dm- theDMSTAGobjectdof0- number of dof on the first stratum in the newDMSTAGdof1- number of dof on the second stratum in the newDMSTAGdof2- number of dof on the third stratum in the newDMSTAGdof3- number of dof on the fourth stratum in the newDMSTAG
Output Parameter:
newdm- the new, compatibleDMSTAG
Level: intermediate
Notes: DOF supplied for strata too big for the dimension are ignored; these may be set to 0. For example, for a 2-dimensional DMSTAG, dof2 sets the number of dof per element, and dof3 is unused. For a 3-dimensional DMSTAG, dof3 sets the number of DOF per element.
In contrast to DMDACreateCompatibleDMDA(), coordinates are not reused.
See also:
DMSTAG, DMDACreateCompatibleDMDA(), DMGetCompatibility(), DMStagMigrateVec()
External Links
- PETSc Manual:
DMStag/DMStagCreateCompatibleDMStag
PETSc.LibPETSc.DMStagCreateISFromStencils — Method
is::IS = DMStagCreateISFromStencils(petsclib::PetscLibType,dm::PetscDM, n_stencil::PetscInt, stencils::Vector{DMStagStencil})Create an IS, using global numberings, for a subset of DOF in a DMSTAG object
Collective
Input Parameters:
dm- theDMSTAGobjectn_stencil- the number of stencils providedstencils- an array ofDMStagStencilobjects (i,j, andkare ignored)
Output Parameter:
is- the globalIS
Note: Redundant entries in the stencils argument are ignored
Level: advanced
See also:
DMSTAG, IS, DMStagStencil, DMCreateGlobalVector
External Links
- PETSc Manual:
DMStag/DMStagCreateISFromStencils
PETSc.LibPETSc.DMStagGetBoundaryTypes — Method
boundaryTypeX::DMBoundaryType,boundaryTypeY::DMBoundaryType,boundaryTypeZ::DMBoundaryType = DMStagGetBoundaryTypes(petsclib::PetscLibType,dm::PetscDM)get boundary types
Not Collective
Input Parameter:
dm- theDMSTAGobject
Output Parameters:
boundaryTypeX- boundary type for x directionboundaryTypeY- boundary type for y direction, not set for one dimensional problemsboundaryTypeZ- boundary type for z direction, not set for one and two dimensional problems
Level: intermediate
See also:
DMSTAG, DMBoundaryType
External Links
- PETSc Manual:
DMStag/DMStagGetBoundaryTypes
PETSc.LibPETSc.DMStagGetCorners — Method
x::PetscInt,y::PetscInt,z::PetscInt,m::PetscInt,n::PetscInt,p::PetscInt,nExtrax::PetscInt,nExtray::PetscInt,nExtraz::PetscInt = DMStagGetCorners(petsclib::PetscLibType,dm::PetscDM)return global element indices of the local region (excluding ghost points)
Not Collective
Input Parameter:
dm- theDMSTAGobject
Output Parameters:
x- starting element index in first directiony- starting element index in second directionz- starting element index in third directionm- element width in first directionn- element width in second directionp- element width in third directionnExtrax- number of extra partial elements in first directionnExtray- number of extra partial elements in second directionnExtraz- number of extra partial elements in third direction
Level: beginner
Notes: Arguments corresponding to higher dimensions are ignored for 1D and 2D grids. These arguments may be set to NULL in this case.
The number of extra partial elements is either 1 or 0. The value is 1 on right, top, and front non-periodic domain ("physical") boundaries, in the x, y, and z directions respectively, and otherwise 0.
See also:
DMSTAG, DMStagGetGhostCorners(), DMDAGetCorners()
External Links
- PETSc Manual:
DMStag/DMStagGetCorners
PETSc.LibPETSc.DMStagGetDOF — Method
dof0::PetscInt,dof1::PetscInt,dof2::PetscInt,dof3::PetscInt = DMStagGetDOF(petsclib::PetscLibType,dm::PetscDM)get number of DOF associated with each stratum of the grid
Not Collective
Input Parameter:
dm- theDMSTAGobject
Output Parameters:
dof0- the number of points per 0-cell (vertex/node)dof1- the number of points per 1-cell (element in 1D, edge in 2D and 3D)dof2- the number of points per 2-cell (element in 2D, face in 3D)dof3- the number of points per 3-cell (element in 3D)
Level: beginner
See also:
DMSTAG, DMStagGetCorners(), DMStagGetGhostCorners(), DMStagGetGlobalSizes(), DMStagGetStencilWidth(), DMStagGetBoundaryTypes(), DMStagGetLocationDOF(), DMDAGetDof()
External Links
- PETSc Manual:
DMStag/DMStagGetDOF
PETSc.LibPETSc.DMStagGetEntries — Method
entries::PetscInt = DMStagGetEntries(petsclib::PetscLibType,dm::PetscDM)get number of native entries in the global representation
Not Collective
Input Parameter:
dm- theDMSTAGobject
Output Parameter:
entries- number of rank-native entries in the global representation
Level: developer
Note: This is the number of entries on this rank for a global vector associated with dm. That is, it is value of size returned by VecGetLocalSize(vec,&size) when DMCreateGlobalVector(dm,&vec) is used to create aVec`. Users would typically use these functions.
See also:
DMSTAG, DMStagGetDOF(), DMStagGetEntriesLocal(), DMStagGetEntriesPerElement(), DMCreateLocalVector()
External Links
- PETSc Manual:
DMStag/DMStagGetEntries
PETSc.LibPETSc.DMStagGetEntriesLocal — Method
entries::PetscInt = DMStagGetEntriesLocal(petsclib::PetscLibType,dm::PetscDM)get number of entries in the local representation
Not Collective
Input Parameter:
dm- theDMSTAGobject
Output Parameter:
entries- number of entries in the local representation
Level: developer
Note: This is the number of entries on this rank in the local representation. That is, it is value of size returned by VecGetSize(vec,&size) or VecGetLocalSize(vec,&size) when DMCreateLocalVector(dm,&vec) is used to create a Vec. Users would typically use these functions.
See also:
DMSTAG, DMStagGetDOF(), DMStagGetEntries(), DMStagGetEntriesPerElement(), DMCreateLocalVector()
External Links
- PETSc Manual:
DMStag/DMStagGetEntriesLocal
PETSc.LibPETSc.DMStagGetEntriesPerElement — Method
entriesPerElement::PetscInt = DMStagGetEntriesPerElement(petsclib::PetscLibType,dm::PetscDM)get number of entries per element in the local representation
Not Collective
Input Parameter:
dm- theDMSTAGobject
Output Parameter:
entriesPerElement- number of entries associated with each element in the local representation
Level: developer
Notes: This is the natural block size for most local operations. In 1D it is equal to dof0 + dof1, in 2D it is equal to dof0 + 2dof1 + dof2, and in 3D it is equal to dof0 + 3dof1 + 3dof2 + dof3
See also:
DMSTAG, DMStagGetDOF()
External Links
- PETSc Manual:
DMStag/DMStagGetEntriesPerElement
PETSc.LibPETSc.DMStagGetGhostCorners — Method
x::PetscInt,y::PetscInt,z::PetscInt,m::PetscInt,n::PetscInt,p::PetscInt = DMStagGetGhostCorners(petsclib::PetscLibType,dm::PetscDM)return global element indices of the local region, including ghost points
Not Collective
Input Parameter:
dm- theDMSTAGobject
Output Parameters:
x- the starting element index in the first directiony- the starting element index in the second directionz- the starting element index in the third directionm- the element width in the first directionn- the element width in the second directionp- the element width in the third direction
Level: beginner
Note: Arguments corresponding to higher dimensions are ignored for 1D and 2D grids. These arguments may be set to NULL in this case.
See also:
DMSTAG, DMStagGetCorners(), DMDAGetGhostCorners()
External Links
- PETSc Manual:
DMStag/DMStagGetGhostCorners
PETSc.LibPETSc.DMStagGetGlobalSizes — Method
M::PetscInt,N::PetscInt,P::PetscInt = DMStagGetGlobalSizes(petsclib::PetscLibType,dm::PetscDM)get global element counts
Not Collective
Input Parameter:
dm- theDMSTAGobject
Output Parameters:
M- global element counts in the x directionN- global element counts in the y directionP- global element counts in the z direction
Level: beginner
Note: Arguments corresponding to higher dimensions are ignored for 1D and 2D grids. These arguments may be set to NULL in this case.
See also:
DMSTAG, DMStagGetLocalSizes(), DMDAGetInfo()
External Links
- PETSc Manual:
DMStag/DMStagGetGlobalSizes
PETSc.LibPETSc.DMStagGetIsFirstRank — Method
isFirstRank0::PetscBool,isFirstRank1::PetscBool,isFirstRank2::PetscBool = DMStagGetIsFirstRank(petsclib::PetscLibType,dm::PetscDM)get boolean value for whether this rank is first in each direction in the rank grid
Not Collective
Input Parameter:
dm- theDMSTAGobject
Output Parameters:
isFirstRank0- whether this rank is first in the x directionisFirstRank1- whether this rank is first in the y directionisFirstRank2- whether this rank is first in the z direction
Level: intermediate
Note: Arguments corresponding to higher dimensions are ignored for 1D and 2D grids. These arguments may be set to NULL in this case.
See also:
DMSTAG, DMStagGetIsLastRank()
External Links
- PETSc Manual:
DMStag/DMStagGetIsFirstRank
PETSc.LibPETSc.DMStagGetIsLastRank — Method
isLastRank0::PetscBool,isLastRank1::PetscBool,isLastRank2::PetscBool = DMStagGetIsLastRank(petsclib::PetscLibType,dm::PetscDM)get boolean value for whether this rank is last in each direction in the rank grid
Not Collective
Input Parameter:
dm- theDMSTAGobject
Output Parameters:
isLastRank0- whether this rank is last in the x directionisLastRank1- whether this rank is last in the y directionisLastRank2- whether this rank is last in the z direction
Level: intermediate
Note: Arguments corresponding to higher dimensions are ignored for 1D and 2D grids. These arguments may be set to NULL in this case.
See also:
DMSTAG, DMStagGetIsFirstRank()
External Links
- PETSc Manual:
DMStag/DMStagGetIsLastRank
PETSc.LibPETSc.DMStagGetLocalSizes — Method
m::PetscInt,n::PetscInt,p::PetscInt = DMStagGetLocalSizes(petsclib::PetscLibType,dm::PetscDM)get local elementwise sizes
Not Collective
Input Parameter:
dm- theDMSTAGobject
Output Parameters:
m- local element counts (excluding ghosts) in the x directionn- local element counts (excluding ghosts) in the y directionp- local element counts (excluding ghosts) in the z direction
Level: beginner
Note: Arguments corresponding to higher dimensions are ignored for 1D and 2D grids. These arguments may be set to NULL in this case.
See also:
DMSTAG, DMStagGetGlobalSizes(), DMStagGetDOF(), DMStagGetNumRanks(), DMDAGetLocalInfo()
External Links
- PETSc Manual:
DMStag/DMStagGetLocalSizes
PETSc.LibPETSc.DMStagGetLocationDOF — Method
dof::PetscInt = DMStagGetLocationDOF(petsclib::PetscLibType,dm::PetscDM, loc::DMStagStencilLocation)Get number of DOF associated with a given point in a DMSTAG grid
Not Collective
Input Parameters:
dm- theDMSTAGobjectloc- grid point (seeDMStagStencilLocation)
Output Parameter:
dof- the number of DOF (components) living atlocindm
Level: intermediate
See also:
DMSTAG, DMStagStencilLocation, DMStagStencil, DMDAGetDof()
External Links
- PETSc Manual:
DMStag/DMStagGetLocationDOF
PETSc.LibPETSc.DMStagGetLocationSlot — Method
slot::PetscInt = DMStagGetLocationSlot(petsclib::PetscLibType,dm::PetscDM, loc::DMStagStencilLocation, c::PetscInt)get index to use in accessing raw local arrays
Not Collective
Input Parameters:
dm- theDMSTAGobjectloc- location relative to an elementc- component
Output Parameter:
slot- index to use
Level: beginner
Notes: Provides an appropriate index to use with DMStagVecGetArray() and friends. This is required so that the user doesn't need to know about the ordering of dof associated with each local element.
See also:
DMSTAG, DMStagVecGetArray(), DMStagVecGetArrayRead(), DMStagGetDOF(), DMStagGetEntriesPerElement()
External Links
- PETSc Manual:
DMStag/DMStagGetLocationSlot
PETSc.LibPETSc.DMStagGetNumRanks — Method
nRanks0::PetscInt,nRanks1::PetscInt,nRanks2::PetscInt = DMStagGetNumRanks(petsclib::PetscLibType,dm::PetscDM)get number of ranks in each direction in the global grid decomposition
Not Collective
Input Parameter:
dm- theDMSTAGobject
Output Parameters:
nRanks0- number of ranks in the x direction in the grid decompositionnRanks1- number of ranks in the y direction in the grid decompositionnRanks2- number of ranks in the z direction in the grid decomposition
Level: intermediate
See also:
DMSTAG, DMStagGetGlobalSizes(), DMStagGetLocalSize(), DMStagSetNumRanks(), DMDAGetInfo()
External Links
- PETSc Manual:
DMStag/DMStagGetNumRanks
PETSc.LibPETSc.DMStagGetOwnershipRanges — Method
lx::Vector{PetscInt},ly::Vector{PetscInt},lz::Vector{PetscInt} = DMStagGetOwnershipRanges(petsclib::PetscLibType,dm::PetscDM)get elements per rank in each direction
Not Collective
Input Parameter:
dm- theDMSTAGobject
Output Parameters:
lx- ownership along x direction (optional)ly- ownership along y direction (optional)lz- ownership along z direction (optional)
Level: intermediate
Notes: These correspond to the optional final arguments passed to DMStagCreate1d(), DMStagCreate2d(), and DMStagCreate3d().
Arguments corresponding to higher dimensions are ignored for 1D and 2D grids. These arguments may be set to NULL in this case.
In C you should not free these arrays, nor change the values in them. They will only have valid values while the DMSTAG they came from still exists (has not been destroyed).
See also:
DMSTAG, DMStagSetGlobalSizes(), DMStagSetOwnershipRanges(), DMStagCreate1d(), DMStagCreate2d(), DMStagCreate3d(), DMDAGetOwnershipRanges()
External Links
- PETSc Manual:
DMStag/DMStagGetOwnershipRanges
PETSc.LibPETSc.DMStagGetProductCoordinateArrays — Method
arrX,arrY,arrZ = DMStagGetProductCoordinateArrays(petsclib::PetscLibType,dm::PetscDM)extract local product coordinate arrays, one per dimension
Logically Collective
Input Parameter:
dm- theDMSTAGobject
Output Parameters:
arrX- local 1D coordinate arrays for x directionarrY- local 1D coordinate arrays for y direction, not set for one dimensional problemsarrZ- local 1D coordinate arrays for z direction, not set for one and two dimensional problems
Level: intermediate
Notes: A high-level helper function to quickly extract local coordinate arrays.
Note that 2-dimensional arrays are returned. See DMStagVecGetArray(), which is called internally to produce these arrays representing coordinates on elements and vertices (element boundaries) for a 1-dimensional DMSTAG in each coordinate direction.
One should use DMStagGetProductCoordinateLocationSlot() to determine appropriate indices for the second dimension in these returned arrays. This function checks that the coordinate array is a suitable product of 1-dimensional DMSTAG objects.
See also:
DMSTAG, DMPRODUCT, DMStagGetProductCoordinateArraysRead(), DMStagSetUniformCoordinates(), DMStagSetUniformCoordinatesProduct(), DMStagGetProductCoordinateLocationSlot()
External Links
- PETSc Manual:
DMStag/DMStagGetProductCoordinateArrays
PETSc.LibPETSc.DMStagGetProductCoordinateArraysRead — Method
arrX::PetscArray, arrY::PetscArray, arrZ::PetscArray = DMStagGetProductCoordinateArraysRead(petsclib::PetscLibType,dm::PetscDM)extract product coordinate arrays, read
Logically Collective
Input Parameter:
dm- theDMSTAGobject
Output Parameters:
arrX- local 1D coordinate arrays forxdirectionarrY- local 1D coordinate arrays forydirection, not set for one dimensional problemsarrZ- local 1D coordinate arrays forzdirection, not set for one and two dimensional problems
Level: intermediate
Note: See DMStagGetProductCoordinateArrays() for more information.
See also:
DMSTAG, DMPRODUCT, DMStagGetProductCoordinateArrays(), DMStagSetUniformCoordinates(), DMStagSetUniformCoordinatesProduct(), DMStagGetProductCoordinateLocationSlot()
External Links
- PETSc Manual:
DMStag/DMStagGetProductCoordinateArraysRead
PETSc.LibPETSc.DMStagGetRefinementFactor — Method
refine_x::PetscInt,refine_y::PetscInt,refine_z::PetscInt = DMStagGetRefinementFactor(petsclib::PetscLibType,dm::PetscDM)get refinement ratios in each direction
Not Collective
Input Parameter:
dm- theDMSTAGobject
Output Parameters:
refine_x- ratio of fine grid to coarse in x-direction (2 by default)refine_y- ratio of fine grid to coarse in y-direction (2 by default)refine_z- ratio of fine grid to coarse in z-direction (2 by default)
Level: intermediate
See also:
DMSTAG, DMRefine(), DMCoarsen(), DMStagSetRefinementFactor(), DMDASetRefinementFactor()
External Links
- PETSc Manual:
DMStag/DMStagGetRefinementFactor
PETSc.LibPETSc.DMStagGetStencilType — Method
stencilType::DMStagStencilType = DMStagGetStencilType(petsclib::PetscLibType,dm::PetscDM)get elementwise ghost/halo stencil type
Not Collective
Input Parameter:
dm- theDMSTAGobject
Output Parameter:
stencilType- the elementwise ghost stencil type:DMSTAG_STENCIL_BOX,DMSTAG_STENCIL_STAR, orDMSTAG_STENCIL_NONE
Level: beginner
See also:
DMSTAG, DMStagSetStencilType(), DMStagGetStencilWidth, DMStagStencilType
External Links
- PETSc Manual:
DMStag/DMStagGetStencilType
PETSc.LibPETSc.DMStagGetStencilWidth — Method
stencilWidth::PetscInt = DMStagGetStencilWidth(petsclib::PetscLibType,dm::PetscDM)get elementwise stencil width
Not Collective
Input Parameter:
dm- theDMSTAGobject
Output Parameter:
stencilWidth- stencil/halo/ghost width in elements
Level: beginner
See also:
DMSTAG, DMStagSetStencilWidth(), DMStagGetStencilType(), DMDAGetStencilType()
External Links
- PETSc Manual:
DMStag/DMStagGetStencilWidth
PETSc.LibPETSc.DMStagMatGetValuesStencil — Method
val::PetscScalar = DMStagMatGetValuesStencil(petsclib::PetscLibType,dm::PetscDM, mat::PetscMat, nRow::PetscInt, posRow::DMStagStencil, nCol::PetscInt, posCol::DMStagStencil)retrieve local matrix entries using grid indexing
Not Collective
Input Parameters:
dm- theDMSTAGobjectmat- the matrixnRow- number of rowsposRow- grid locations (including components) of rowsnCol- number of columnsposCol- grid locations (including components) of columns
Output Parameter:
val- logically two-dimensional array of values
Level: advanced
See also:
DMSTAG, DMStagStencil, DMStagStencilLocation, DMStagVecGetValuesStencil(), DMStagVecSetValuesStencil(), DMStagMatSetValuesStencil(), MatSetValuesStencil(), MatAssemblyBegin(), MatAssemblyEnd(), DMCreateMatrix()
External Links
- PETSc Manual:
DMStag/DMStagMatGetValuesStencil
PETSc.LibPETSc.DMStagMatSetValuesStencil — Method
DMStagMatSetValuesStencil(petsclib::PetscLibType,dm::PetscDM, mat::PetscMat, nRow::PetscInt, posRow::DMStagStencil, nCol::PetscInt, posCol::DMStagStencil, val::PetscScalar, insertMode::InsertMode)insert or add matrix entries using grid indexing
Not Collective
Input Parameters:
dm- theDMSTAGobjectmat- the matrixnRow- number of rowsposRow- grid locations (including components) of rowsnCol- number of columnsposCol- grid locations (including components) of columnsval- logically two-dimensional array of valuesinsertMode-INSERT_VALUESorADD_VALUES
Notes: See notes for MatSetValuesStencil()
Level: intermediate
See also:
DMSTAG, DMStagStencil, DMStagStencilLocation, DMStagVecGetValuesStencil(), DMStagVecSetValuesStencil(), DMStagMatGetValuesStencil(), MatSetValuesStencil(), MatAssemblyBegin(), MatAssemblyEnd(), DMCreateMatrix()
External Links
- PETSc Manual:
DMStag/DMStagMatSetValuesStencil
PETSc.LibPETSc.DMStagMigrateVec — Method
DMStagMigrateVec(petsclib::PetscLibType,dm::PetscDM, vec::PetscVec, dmTo::PetscDM, vecTo::PetscVec)transfer a vector associated with a DMSTAG to a vector associated with a compatible DMSTAG
Collective
Input Parameters:
dm- the sourceDMSTAGobjectvec- the source vector, compatible withdmdmTo- the compatible destinationDMSTAGobjectvecTo- the destination vector, compatible withdmTo
Level: advanced
Notes: Extra dof are ignored, and unfilled dof are zeroed. Currently only implemented to migrate global vectors to global vectors. For the definition of compatibility of DMs, see DMGetCompatibility().
See also:
DMSTAG, DMStagCreateCompatibleDMStag(), DMGetCompatibility(), DMStagVecSplitToDMDA()
External Links
- PETSc Manual:
DMStag/DMStagMigrateVec
PETSc.LibPETSc.DMStagPopulateLocalToGlobalInjective — Method
DMStagPopulateLocalToGlobalInjective(petsclib::PetscLibType,dm::PetscDM)populate an internal 1
Collective
Creates an internal object which explicitly maps a single local degree of freedom to each global degree of freedom. This is used, if populated, instead of SCATTERREVERSELOCAL with the (1-to-many, in general) global-to-local map, when DMLocalToGlobal() is called with INSERT_VALUES. This allows usage, for example, even in the periodic, 1-rank case, where the inverse of the global-to-local map, even when restricted to on-rank communication, is non-injective. This is at the cost of storing an additional VecScatter object inside each DMSTAG object.
Input Parameter:
dm- theDMSTAGobject
Level: developer
Notes: In normal usage, library users shouldn't be concerned with this function, as it is called during DMSetUp(), when required.
Returns immediately if the internal map is already populated.
Developer Notes: This could, if desired, be moved up to a general DM routine. It would allow, for example, DMDA to support DMLocalToGlobal() with INSERT_VALUES, even in the single-rank periodic case.
See also:
DMSTAG, DMLocalToGlobal(), VecScatter
External Links
- PETSc Manual:
DMStag/DMStagPopulateLocalToGlobalInjective
PETSc.LibPETSc.DMStagRestoreProductCoordinateArrays — Method
DMStagRestoreProductCoordinateArrays(petsclib::PetscLibType,dm::PetscDM, arrX::PetscArray, arrY::PetscArray, arrZ::PetscArray)restore local array access
Logically Collective
Input Parameter:
dm- theDMSTAGobjectarrX- local 1D coordinate arrays for x directionarrY- local 1D coordinate arrays for y directionarrZ- local 1D coordinate arrays for z direction
Level: intermediate
Notes: This function does not automatically perform a local->global scatter to populate global coordinates from the local coordinates. Thus, it may be required to explicitly perform these operations in some situations, as in the following partial example: -vb PetscCall(DMGetCoordinateDM(dm, &cdm)); for (PetscInt d = 0; d < 3; ++d) { DM subdm; Vec coor, coor_local;
PetscCall(DMProductGetDM(cdm, d, &subdm)); PetscCall(DMGetCoordinates(subdm, &coor)); PetscCall(DMGetCoordinatesLocal(subdm, &coorlocal)); PetscCall(DMLocalToGlobal(subdm, coorlocal, INSERTVALUES, coor)); PetscCall(PetscPrintf(PETSCCOMMWORLD, "Coordinates dim %" PetscIntFMT ": ", d)); PetscCall(VecView(coor, PETSCVIEWERSTDOUT_WORLD)); } -ve
See also:
DMSTAG, DMStagGetProductCoordinateArrays(), DMStagGetProductCoordinateArraysRead()
External Links
- PETSc Manual:
DMStag/DMStagRestoreProductCoordinateArrays
PETSc.LibPETSc.DMStagRestoreProductCoordinateArraysRead — Method
DMStagRestoreProductCoordinateArraysRead(petsclib::PetscLibType,dm::PetscDM, arrX::PetscArray, arrY::PetscArray, arrZ::PetscArray)restore local product array access, read
Logically Collective
Input Parameters:
dm- theDMSTAGobjectarrX- local 1D coordinate arrays for x directionarrY- local 1D coordinate arrays for y directionarrZ- local 1D coordinate arrays for z direction
Level: intermediate
See also:
DMSTAG, DMStagGetProductCoordinateArrays(), DMStagGetProductCoordinateArraysRead()
External Links
- PETSc Manual:
DMStag/DMStagRestoreProductCoordinateArraysRead
PETSc.LibPETSc.DMStagRestrictSimple — Method
DMStagRestrictSimple(petsclib::PetscLibType,dmf::PetscDM, xf::PetscVec, dmc::PetscDM, xc::PetscVec)restricts data from a fine to a coarse DMSTAG, in the simplest way
Values on coarse cells are averages of all fine cells that they cover. Thus, values on vertices are injected, values on edges are averages of the underlying two fine edges, and values on elements in d dimensions are averages of 2^d underlying elements.
Input Parameters:
dmf- fineDMxf- data on fineDMdmc- coarseDM
Output Parameter:
xc- data on coarseDM
Level: advanced
See also:
DMSTAG, DM, DMRestrict(), DMCoarsen(), DMCreateInjection()
External Links
- PETSc Manual:
DMStag/DMStagRestrictSimple
PETSc.LibPETSc.DMStagSetBoundaryTypes — Method
DMStagSetBoundaryTypes(petsclib::PetscLibType,dm::PetscDM, boundaryType0::DMBoundaryType, boundaryType1::DMBoundaryType, boundaryType2::DMBoundaryType)set DMSTAG boundary types
Logically Collective; boundaryType0, boundaryType1, and boundaryType2 must contain common values
Input Parameters:
dm- theDMSTAGobjectboundaryType2- boundary type for x directionboundaryType1- boundary type for y direction, not set for one dimensional problemsboundaryType0- boundary type for z direction, not set for one and two dimensional problems
Level: advanced
Note: Arguments corresponding to higher dimensions are ignored for 1D and 2D grids.
See also:
DMSTAG, DMBoundaryType, DMStagCreate1d(), DMStagCreate2d(), DMStagCreate3d(), DMDASetBoundaryType()
External Links
- PETSc Manual:
DMStag/DMStagSetBoundaryTypes
PETSc.LibPETSc.DMStagSetCoordinateDMType — Method
DMStagSetCoordinateDMType(petsclib::PetscLibType,dm::PetscDM, dmtype::DMType)set DM type to store coordinates
Logically Collective; dmtype must contain common value
Input Parameters:
dm- theDMSTAGobjectdmtype-DMtypefor coordinates, eitherDMSTAGorDMPRODUCT
Level: advanced
See also:
DMSTAG, DMPRODUCT, DMGetCoordinateDM(), DMStagSetUniformCoordinates(), DMStagSetUniformCoordinatesExplicit(), DMStagSetUniformCoordinatesProduct(), DMType
External Links
- PETSc Manual:
DMStag/DMStagSetCoordinateDMType
PETSc.LibPETSc.DMStagSetDOF — Method
DMStagSetDOF(petsclib::PetscLibType,dm::PetscDM, dof0::PetscInt, dof1::PetscInt, dof2::PetscInt, dof3::PetscInt)set dof/stratum
Logically Collective; dof0, dof1, dof2, and dof3 must contain common values
Input Parameters:
dm- theDMSTAGobjectdof0- the number of points per 0-cell (vertex/node)dof1- the number of points per 1-cell (element in 1D, edge in 2D and 3D)dof2- the number of points per 2-cell (element in 2D, face in 3D)dof3- the number of points per 3-cell (element in 3D)
Level: advanced
Note: Arguments corresponding to higher dimensions are ignored for 1D and 2D grids.
See also:
DMSTAG, DMDASetDof()
External Links
- PETSc Manual:
DMStag/DMStagSetDOF
PETSc.LibPETSc.DMStagSetGlobalSizes — Method
DMStagSetGlobalSizes(petsclib::PetscLibType,dm::PetscDM, N0::PetscInt, N1::PetscInt, N2::PetscInt)set global element counts in each direction
Logically Collective; N0, N1, and N2 must contain common values
Input Parameters:
dm- theDMSTAGobjectN0- global elementwise size in the x directionN1- global elementwise size in the y directionN2- global elementwise size in the z direction
Level: advanced
Note: Arguments corresponding to higher dimensions are ignored for 1D and 2D grids.
See also:
DMSTAG, DMStagGetGlobalSizes(), DMDASetSizes()
External Links
- PETSc Manual:
DMStag/DMStagSetGlobalSizes
PETSc.LibPETSc.DMStagSetNumRanks — Method
DMStagSetNumRanks(petsclib::PetscLibType,dm::PetscDM, nRanks0::PetscInt, nRanks1::PetscInt, nRanks2::PetscInt)set ranks in each direction in the global rank grid
Logically Collective; nRanks0, nRanks1, and nRanks2 must contain common values
Input Parameters:
dm- theDMSTAGobjectnRanks0- number of ranks in the x directionnRanks1- number of ranks in the y directionnRanks2- number of ranks in the z direction
Level: developer
Note: Arguments corresponding to higher dimensions are ignored for 1D and 2D grids.
See also:
DMSTAG, DMDASetNumProcs()
External Links
- PETSc Manual:
DMStag/DMStagSetNumRanks
PETSc.LibPETSc.DMStagSetOwnershipRanges — Method
DMStagSetOwnershipRanges(petsclib::PetscLibType,dm::PetscDM, lx::Vector{PetscInt}, ly::Vector{PetscInt}, lz::Vector{PetscInt})set elements per rank in each direction
Logically Collective; lx, ly, and lz must contain common values
Input Parameters:
dm- theDMSTAGobjectlx- element counts for each rank in the x direction, may beNULLly- element counts for each rank in the y direction, may beNULLlz- element counts for each rank in the z direction, may beNULL
Level: developer
Note: Arguments corresponding to higher dimensions are ignored for 1D and 2D grids. These arguments may be set to NULL in this case.
See also:
DMSTAG, DMStagSetGlobalSizes(), DMStagGetOwnershipRanges(), DMDASetOwnershipRanges()
External Links
- PETSc Manual:
DMStag/DMStagSetOwnershipRanges
PETSc.LibPETSc.DMStagSetRefinementFactor — Method
DMStagSetRefinementFactor(petsclib::PetscLibType,dm::PetscDM, refine_x::PetscInt, refine_y::PetscInt, refine_z::PetscInt)set refinement ratios in each direction
Logically Collective
Input Parameters:
dm- theDMSTAGobjectrefine_x- ratio of fine grid to coarse in x-direction (2 by default)refine_y- ratio of fine grid to coarse in y-direction (2 by default)refine_z- ratio of fine grid to coarse in z-direction (2 by default)
Level: intermediate
Note: Pass PETSC_IGNORE to leave a value unchanged
See also:
DMSTAG, DMRefine(), DMCoarsen(), DMStagGetRefinementFactor(), DMDAGetRefinementFactor()
External Links
- PETSc Manual:
DMStag/DMStagSetRefinementFactor
PETSc.LibPETSc.DMStagSetStencilType — Method
DMStagSetStencilType(petsclib::PetscLibType,dm::PetscDM, stencilType::DMStagStencilType)set elementwise ghost/halo stencil type
Logically Collective; stencilType must contain common value
Input Parameters:
dm- theDMSTAGobjectstencilType- the elementwise ghost stencil type:DMSTAG_STENCIL_BOX,DMSTAG_STENCIL_STAR, orDMSTAG_STENCIL_NONE
Level: beginner
See also:
DMSTAG, DMStagGetStencilType(), DMStagSetStencilWidth(), DMStagStencilType
External Links
- PETSc Manual:
DMStag/DMStagSetStencilType
PETSc.LibPETSc.DMStagSetStencilWidth — Method
DMStagSetStencilWidth(petsclib::PetscLibType,dm::PetscDM, stencilWidth::PetscInt)set elementwise stencil width
Logically Collective; stencilWidth must contain common value
Input Parameters:
dm- theDMSTAGobjectstencilWidth- stencil/halo/ghost width in elements
Level: beginner
Note: The width value is not used when DMSTAG_STENCIL_NONE is specified.
See also:
DMSTAG, DMStagGetStencilWidth(), DMStagGetStencilType(), DMStagStencilType
External Links
- PETSc Manual:
DMStag/DMStagSetStencilWidth
PETSc.LibPETSc.DMStagSetUniformCoordinates — Method
DMStagSetUniformCoordinates(petsclib::PetscLibType,dm::PetscDM, xmin::PetscReal, xmax::PetscReal, ymin::PetscReal, ymax::PetscReal, zmin::PetscReal, zmax::PetscReal)set DMSTAG coordinates to be a uniform grid
Collective
Input Parameters:
dm- theDMSTAGobjectxmin- minimum global coordinate value in thexdirectionxmax- maximum global coordinate values in thexdirectionymin- minimum global coordinate value in theydirectionymax- maximum global coordinate value in theydirectionzmin- minimum global coordinate value in thezdirectionzmax- maximum global coordinate value in thezdirection
Level: advanced
Notes: DMSTAG supports 2 different types of coordinate DM: DMSTAG and DMPRODUCT. Arguments corresponding to higher dimensions are ignored for 1D and 2D grids.
Local coordinates are populated (using DMSetCoordinatesLocal()), linearly extrapolated to ghost cells, including those outside the physical domain. This is also done in case of periodic boundaries, meaning that the same global point may have different coordinates in different local representations, which are equivalent assuming a periodicity implied by the arguments to this function, i.e. two points are equivalent if their difference is a multiple of (xmax - xmin ) in the x direction, ( ymax - ymin ) in the y direction, and ( zmax - zmin ) in the z direction.
See also:
DMSTAG, DMPRODUCT, DMStagSetUniformCoordinatesExplicit(), DMStagSetUniformCoordinatesProduct(), DMStagSetCoordinateDMType(), DMGetCoordinateDM(), DMGetCoordinates(), DMDASetUniformCoordinates(), DMBoundaryType
External Links
- PETSc Manual:
DMStag/DMStagSetUniformCoordinates
PETSc.LibPETSc.DMStagSetUniformCoordinatesExplicit — Method
DMStagSetUniformCoordinatesExplicit(petsclib::PetscLibType,dm::PetscDM, xmin::PetscReal, xmax::PetscReal, ymin::PetscReal, ymax::PetscReal, zmin::PetscReal, zmax::PetscReal)set DMSTAG coordinates to be a uniform grid, storing all values
Collective
Input Parameters:
dm- theDMSTAGobjectxmin- minimum global coordinate value in thexdirectionxmax- maximum global coordinate value in thexdirectionymin- minimum global coordinate value in theydirectionymax- maximum global coordinate value in theydirectionzmin- minimum global coordinate value in thezdirectionzmax- maximum global coordinate value in thezdirection
Level: beginner
Notes: DMSTAG supports 2 different types of coordinate DM: either another DMSTAG, or a DMPRODUCT. If the grid is orthogonal, using DMPRODUCT should be more efficient.
Arguments corresponding to higher dimensions are ignored for 1D and 2D grids.
See the manual page for DMStagSetUniformCoordinates() for information on how coordinates for dummy cells outside the physical domain boundary are populated.
See also:
DMSTAG, DMStagSetUniformCoordinates(), DMStagSetUniformCoordinatesProduct(), DMStagSetCoordinateDMType()
External Links
- PETSc Manual:
DMStag/DMStagSetUniformCoordinatesExplicit
PETSc.LibPETSc.DMStagSetUniformCoordinatesProduct — Method
DMStagSetUniformCoordinatesProduct(petsclib::PetscLibType,dm::PetscDM, xmin::PetscReal, xmax::PetscReal, ymin::PetscReal, ymax::PetscReal, zmin::PetscReal, zmax::PetscReal)create uniform coordinates, as a product of 1D arrays
Set the coordinate DM to be a DMPRODUCT of 1D DMSTAG objects, each of which have a coordinate DM (also a 1d DMSTAG) holding uniform coordinates.
Collective
Input Parameters:
dm- theDMSTAGobjectxmin- minimum global coordinate value in thexdirectionxmax- maximum global coordinate value in thexdirectionymin- minimum global coordinate value in theydirectionymax- maximum global coordinate value in theydirectionzmin- minimum global coordinate value in thezdirectionzmax- maximum global coordinate value in thezdirection
Level: intermediate
Notes: Arguments corresponding to higher dimensions are ignored for 1D and 2D grids.
The per-dimension 1-dimensional DMSTAG objects that comprise the product always have active 0-cells (vertices, element boundaries) and 1-cells (element centers).
See the manual page for DMStagSetUniformCoordinates() for information on how coordinates for dummy cells outside the physical domain boundary are populated.
See also:
DMSTAG, DMPRODUCT, DMStagSetUniformCoordinates(), DMStagSetUniformCoordinatesExplicit(), DMStagSetCoordinateDMType()
External Links
- PETSc Manual:
DMStag/DMStagSetUniformCoordinatesProduct
PETSc.LibPETSc.DMStagStencilToIndexLocal — Method
ix::PetscInt = DMStagStencilToIndexLocal(petsclib::PetscLibType,dm::PetscDM, dim::PetscInt, n::PetscInt, pos::DMStagStencil)Convert an array of DMStagStencil objects to an array of indices into a local vector.
Not Collective
Input Parameters:
dm- theDMSTAGobjectdim- the dimension of theDMSTAGobjectn- the number ofDMStagStencilobjectspos- an array ofnDMStagStencilobjects
Output Parameter:
ix- output array ofnindices
Notes: The DMStagStencil objects in pos use global element indices.
The .c fields in pos must always be set (even if to 0).
Developer Notes: This is a "hot" function, and accepts the dimension redundantly to avoid having to perform any error checking inside the function.
Level: developer
See also:
DMSTAG, DMStagStencilLocation, DMStagStencil, DMGetLocalVector, DMCreateLocalVector
External Links
- PETSc Manual:
DMStag/DMStagStencilToIndexLocal
PETSc.LibPETSc.DMStagVecGetArray — Method
array::PetscArray = DMStagVecGetArray(petsclib::PetscLibType,dm::PetscDM, vec::PetscVec)get access to local array
Logically Collective
Input Parameters:
dm- theDMSTAGobjectvec- theVecobject
Output Parameter:
array- the array
Level: beginner
Note: This function returns a (dim+1)-dimensional array for a dim-dimensional DMSTAG.
The first 1-3 dimensions indicate an element in the global numbering, using the standard C ordering.
The final dimension in this array corresponds to a degree of freedom with respect to this element, for example corresponding to the element or one of its neighboring faces, edges, or vertices.
For example, for a 3D DMSTAG, indexing is array[k][j][i][idx], where k is the index in the z-direction, j is the index in the y-direction, and i is the index in the x-direction.
idx is obtained with DMStagGetLocationSlot(), since the correct offset into the (d+1)-dimensional C array for a d-dimensional DMSTAG depends on the grid size and the number of DOF stored at each location.
DMStagVecRestoreArray() must be called, once finished with the array
See also:
DMSTAG, DMStagVecGetArrayRead(), DMStagGetLocationSlot(), DMGetLocalVector(), DMCreateLocalVector(), DMGetGlobalVector(), DMCreateGlobalVector(), DMDAVecGetArray(), DMDAVecGetArrayDOF()
External Links
- PETSc Manual:
DMStag/DMStagVecGetArray
PETSc.LibPETSc.DMStagVecGetArrayRead — Method
array::PetscArray = DMStagVecGetArrayRead(petsclib::PetscLibType,dm::PetscDM, vec::PetscVec)get read
Logically Collective
See the man page for DMStagVecGetArray() for more information.
Input Parameters:
dm- theDMSTAGobjectvec- theVecobject
Output Parameter:
array- the read-only array
Level: beginner
Note: DMStagVecRestoreArrayRead() must be called, once finished with the array
See also:
DMSTAG, DMStagGetLocationSlot(), DMGetLocalVector(), DMCreateLocalVector(), DMGetGlobalVector(), DMCreateGlobalVector(), DMDAVecGetArrayRead(), DMDAVecGetArrayDOFRead()
External Links
- PETSc Manual:
DMStag/DMStagVecGetArrayRead
PETSc.LibPETSc.DMStagVecGetValuesStencil — Method
val::PetscScalar = DMStagVecGetValuesStencil(petsclib::PetscLibType,dm::PetscDM, vec::PetscVec, n::PetscInt, pos::DMStagStencil)get vector values using grid indexing
Not Collective
Input Parameters:
dm- theDMSTAGobjectvec- the vector objectn- the number of values to obtainpos- locations to obtain values from (as an array ofDMStagStencilvalues)
Output Parameter:
val- value at the point
Notes: Accepts stencils which refer to global element numbers, but only allows access to entries in the local representation (including ghosts).
This approach is not as efficient as getting values directly with DMStagVecGetArray(), which is recommended for matrix-free operators.
Level: advanced
See also:
DMSTAG, DMStagStencil, DMStagStencilLocation, DMStagVecSetValuesStencil(), DMStagMatSetValuesStencil(), DMStagVecGetArray()
External Links
- PETSc Manual:
DMStag/DMStagVecGetValuesStencil
PETSc.LibPETSc.DMStagVecRestoreArray — Method
DMStagVecRestoreArray(petsclib::PetscLibType,dm::PetscDM, vec::PetscVec, array::PetscArray)restore access to a raw array
Logically Collective
Input Parameters:
dm- theDMSTAGobjectvec- theVecobject
Output Parameter:
array- the array
Level: beginner
See also:
DMSTAG, DMStagVecGetArray(), DMDAVecRestoreArray(), DMDAVecRestoreArrayDOF()
External Links
- PETSc Manual:
DMStag/DMStagVecRestoreArray
PETSc.LibPETSc.DMStagVecRestoreArrayRead — Method
DMStagVecRestoreArrayRead(petsclib::PetscLibType,dm::PetscDM, vec::PetscVec, array::PetscArray)restore read
Logically Collective
Input Parameters:
dm- theDMSTAGobjectvec- the Vec object
Output Parameter:
array- the read-only array
Level: beginner
See also:
DMSTAG, DMStagVecGetArrayRead(), DMDAVecRestoreArrayRead(), DMDAVecRestoreArrayDOFRead()
External Links
- PETSc Manual:
DMStag/DMStagVecRestoreArrayRead
PETSc.LibPETSc.DMStagVecSetValuesStencil — Method
DMStagVecSetValuesStencil(petsclib::PetscLibType,dm::PetscDM, vec::PetscVec, n::PetscInt, pos::DMStagStencil, val::PetscScalar, insertMode::InsertMode)Set Vec values using global grid indexing
Not Collective
Input Parameters:
dm- theDMSTAGobjectvec- theVecn- the number of values to setpos- the locations to set values, as an array ofDMStagStencilstructsval- the values to setinsertMode-INSERT_VALUESorADD_VALUES
Notes: The vector is expected to be a global vector compatible with the DM (usually obtained by DMGetGlobalVector() or DMCreateGlobalVector()).
This approach is not as efficient as setting values directly with DMStagVecGetArray(), which is recommended for matrix-free operators. For assembling systems, where overhead may be less important than convenience, this routine could be helpful in assembling a righthand side and a matrix (using DMStagMatSetValuesStencil()).
Level: advanced
See also:
DMSTAG, Vec, DMStagStencil, DMStagStencilLocation, DMStagVecGetValuesStencil(), DMStagMatSetValuesStencil(), DMCreateGlobalVector(), DMGetLocalVector(), DMStagVecGetArray()
External Links
- PETSc Manual:
DMStag/DMStagVecSetValuesStencil
PETSc.LibPETSc.DMStagVecSplitToDMDA — Method
DMStagVecSplitToDMDA(petsclib::PetscLibType,dm::PetscDM, vec::PetscVec, loc::DMStagStencilLocation, c::PetscInt, pda::PetscDM, pdavec::PetscVec)create a DMDA and Vec from a subgrid of a DMSTAG and its Vec
Collective
Input Parameters:
dm- theDMSTAGobjectvec-Vecobject associated withdmloc- which subgrid to extract (seeDMStagStencilLocation)c- which component to extract (see note below)
Output Parameters:
pda- theDMDApdavec- the newVec
Level: advanced
Notes: If a c value of -k is provided, the first k DOF for that position are extracted, padding with zero values if needed. If a non-negative value is provided, a single DOF is extracted.
The caller is responsible for destroying the created DMDA and Vec.
See also:
DMSTAG, DMDA, DMStagStencilLocation, DM, Vec, DMStagMigrateVec(), DMStagCreateCompatibleDMStag()
External Links
- PETSc Manual:
DMStag/DMStagVecSplitToDMDA