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.DMStagCreate1dMethod
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 communicator
  • bndx - boundary type: DM_BOUNDARY_NONE, DM_BOUNDARY_PERIODIC, or DM_BOUNDARY_GHOSTED
  • M - global number of elements
  • dof0 - number of degrees of freedom per vertex/0-cell
  • dof1 - number of degrees of freedom per element/1-cell
  • stencilType - ghost/halo region type: DMSTAG_STENCIL_BOX or DMSTAG_STENCIL_NONE
  • stencilWidth - width, in elements, of halo/ghost region
  • lx - array of local sizes, of length equal to the comm size, summing to M or NULL

Output Parameter:

  • dm - the new DMSTAG object

Options Database Keys:

  • -dm_view - calls DMViewFromOptions() at the conclusion of DMSetUp()
  • -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> - DMBoundaryType value

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

source
PETSc.LibPETSc.DMStagCreate2dMethod
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 communicator
  • bndx - x boundary type, DM_BOUNDARY_NONE, DM_BOUNDARY_PERIODIC, or DM_BOUNDARY_GHOSTED
  • bndy - y boundary type, DM_BOUNDARY_NONE, DM_BOUNDARY_PERIODIC, or DM_BOUNDARY_GHOSTED
  • M - global number of elements in x direction
  • N - global number of elements in y direction
  • m - number of ranks in the x direction (may be PETSC_DECIDE)
  • n - number of ranks in the y direction (may be PETSC_DECIDE)
  • dof0 - number of degrees of freedom per vertex/0-cell
  • dof1 - number of degrees of freedom per face/1-cell
  • dof2 - number of degrees of freedom per element/2-cell
  • stencilType - ghost/halo region type: DMSTAG_STENCIL_NONE, DMSTAG_STENCIL_BOX, or DMSTAG_STENCIL_STAR
  • stencilWidth - width, in elements, of halo/ghost region
  • lx - array of local x element counts, of length equal to m, summing to M, or NULL
  • ly - array of local y element counts, of length equal to n, summing to N, or NULL

Output Parameter:

  • dm - the new DMSTAG object

Options Database Keys:

  • -dm_view - calls DMViewFromOptions() at the conclusion of DMSetUp()
  • -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> - DMBoundaryType value
  • -stag_boundary_type_y <none,ghosted,periodic> - DMBoundaryType value

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

source
PETSc.LibPETSc.DMStagCreate3dMethod
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 communicator
  • bndx - x boundary type, DM_BOUNDARY_NONE, DM_BOUNDARY_PERIODIC, or DM_BOUNDARY_GHOSTED
  • bndy - y boundary type, DM_BOUNDARY_NONE, DM_BOUNDARY_PERIODIC, or DM_BOUNDARY_GHOSTED
  • bndz - z boundary type, DM_BOUNDARY_NONE, DM_BOUNDARY_PERIODIC, or DM_BOUNDARY_GHOSTED
  • M - global number of elements in x direction
  • N - global number of elements in y direction
  • P - global number of elements in z direction
  • m - number of ranks in the x direction (may be PETSC_DECIDE)
  • n - number of ranks in the y direction (may be PETSC_DECIDE)
  • p - number of ranks in the z direction (may be PETSC_DECIDE)
  • dof0 - number of degrees of freedom per vertex/0-cell
  • dof1 - number of degrees of freedom per edge/1-cell
  • dof2 - number of degrees of freedom per face/2-cell
  • dof3 - number of degrees of freedom per element/3-cell
  • stencilType - ghost/halo region type: DMSTAG_STENCIL_NONE, DMSTAG_STENCIL_BOX, or DMSTAG_STENCIL_STAR
  • stencilWidth - width, in elements, of halo/ghost region
  • lx - array of local x element counts, of length equal to m, summing to M, or NULL
  • ly - arrays of local y element counts, of length equal to n, summing to N, or NULL
  • lz - arrays of local z element counts, of length equal to p, summing to P, or NULL

Output Parameter:

  • dm - the new DMSTAG object

Options Database Keys:

  • -dm_view - calls DMViewFromOptions() at the conclusion of DMSetUp()
  • -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> - DMBoundaryType value
  • -stag_boundary_type y <none,ghosted,periodic> - DMBoundaryType value
  • -stag_boundary_type z <none,ghosted,periodic> - DMBoundaryType value

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

source
PETSc.LibPETSc.DMStagCreateCompatibleDMStagMethod
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 - the DMSTAG object
  • dof0 - number of dof on the first stratum in the new DMSTAG
  • dof1 - number of dof on the second stratum in the new DMSTAG
  • dof2 - number of dof on the third stratum in the new DMSTAG
  • dof3 - number of dof on the fourth stratum in the new DMSTAG

Output Parameter:

  • newdm - the new, compatible DMSTAG

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

source
PETSc.LibPETSc.DMStagCreateISFromStencilsMethod
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 - the DMSTAG object
  • n_stencil - the number of stencils provided
  • stencils - an array of DMStagStencil objects (i, j, and k are ignored)

Output Parameter:

  • is - the global IS

Note: Redundant entries in the stencils argument are ignored

Level: advanced

See also:

DMSTAG, IS, DMStagStencil, DMCreateGlobalVector

External Links

source
PETSc.LibPETSc.DMStagGetBoundaryTypesMethod
boundaryTypeX::DMBoundaryType,boundaryTypeY::DMBoundaryType,boundaryTypeZ::DMBoundaryType = DMStagGetBoundaryTypes(petsclib::PetscLibType,dm::PetscDM)

get boundary types

Not Collective

Input Parameter:

  • dm - the DMSTAG object

Output Parameters:

  • boundaryTypeX - boundary type for x direction
  • boundaryTypeY - boundary type for y direction, not set for one dimensional problems
  • boundaryTypeZ - boundary type for z direction, not set for one and two dimensional problems

Level: intermediate

See also:

DMSTAG, DMBoundaryType

External Links

source
PETSc.LibPETSc.DMStagGetCornersMethod
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 - the DMSTAG object

Output Parameters:

  • x - starting element index in first direction
  • y - starting element index in second direction
  • z - starting element index in third direction
  • m - element width in first direction
  • n - element width in second direction
  • p - element width in third direction
  • nExtrax - number of extra partial elements in first direction
  • nExtray - number of extra partial elements in second direction
  • nExtraz - 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

source
PETSc.LibPETSc.DMStagGetDOFMethod
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 - the DMSTAG object

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

source
PETSc.LibPETSc.DMStagGetEntriesMethod
entries::PetscInt = DMStagGetEntries(petsclib::PetscLibType,dm::PetscDM)

get number of native entries in the global representation

Not Collective

Input Parameter:

  • dm - the DMSTAG object

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

source
PETSc.LibPETSc.DMStagGetEntriesLocalMethod
entries::PetscInt = DMStagGetEntriesLocal(petsclib::PetscLibType,dm::PetscDM)

get number of entries in the local representation

Not Collective

Input Parameter:

  • dm - the DMSTAG object

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

source
PETSc.LibPETSc.DMStagGetEntriesPerElementMethod
entriesPerElement::PetscInt = DMStagGetEntriesPerElement(petsclib::PetscLibType,dm::PetscDM)

get number of entries per element in the local representation

Not Collective

Input Parameter:

  • dm - the DMSTAG object

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

source
PETSc.LibPETSc.DMStagGetGhostCornersMethod
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 - the DMSTAG object

Output Parameters:

  • x - the starting element index in the first direction
  • y - the starting element index in the second direction
  • z - the starting element index in the third direction
  • m - the element width in the first direction
  • n - the element width in the second direction
  • p - 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

source
PETSc.LibPETSc.DMStagGetGlobalSizesMethod
M::PetscInt,N::PetscInt,P::PetscInt = DMStagGetGlobalSizes(petsclib::PetscLibType,dm::PetscDM)

get global element counts

Not Collective

Input Parameter:

  • dm - the DMSTAG object

Output Parameters:

  • M - global element counts in the x direction
  • N - global element counts in the y direction
  • P - 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

source
PETSc.LibPETSc.DMStagGetIsFirstRankMethod
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 - the DMSTAG object

Output Parameters:

  • isFirstRank0 - whether this rank is first in the x direction
  • isFirstRank1 - whether this rank is first in the y direction
  • isFirstRank2 - 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

source
PETSc.LibPETSc.DMStagGetIsLastRankMethod
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 - the DMSTAG object

Output Parameters:

  • isLastRank0 - whether this rank is last in the x direction
  • isLastRank1 - whether this rank is last in the y direction
  • isLastRank2 - 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

source
PETSc.LibPETSc.DMStagGetLocalSizesMethod
m::PetscInt,n::PetscInt,p::PetscInt = DMStagGetLocalSizes(petsclib::PetscLibType,dm::PetscDM)

get local elementwise sizes

Not Collective

Input Parameter:

  • dm - the DMSTAG object

Output Parameters:

  • m - local element counts (excluding ghosts) in the x direction
  • n - local element counts (excluding ghosts) in the y direction
  • p - 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

source
PETSc.LibPETSc.DMStagGetLocationDOFMethod
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 - the DMSTAG object
  • loc - grid point (see DMStagStencilLocation)

Output Parameter:

  • dof - the number of DOF (components) living at loc in dm

Level: intermediate

See also:

DMSTAG, DMStagStencilLocation, DMStagStencil, DMDAGetDof()

External Links

source
PETSc.LibPETSc.DMStagGetLocationSlotMethod
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 - the DMSTAG object
  • loc - location relative to an element
  • c - 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

source
PETSc.LibPETSc.DMStagGetNumRanksMethod
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 - the DMSTAG object

Output Parameters:

  • nRanks0 - number of ranks in the x direction in the grid decomposition
  • nRanks1 - number of ranks in the y direction in the grid decomposition
  • nRanks2 - number of ranks in the z direction in the grid decomposition

Level: intermediate

See also:

DMSTAG, DMStagGetGlobalSizes(), DMStagGetLocalSize(), DMStagSetNumRanks(), DMDAGetInfo()

External Links

source
PETSc.LibPETSc.DMStagGetOwnershipRangesMethod
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 - the DMSTAG object

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

source
PETSc.LibPETSc.DMStagGetProductCoordinateArraysMethod
arrX,arrY,arrZ = DMStagGetProductCoordinateArrays(petsclib::PetscLibType,dm::PetscDM)

extract local product coordinate arrays, one per dimension

Logically Collective

Input Parameter:

  • dm - the DMSTAG object

Output Parameters:

  • arrX - local 1D coordinate arrays for x direction
  • arrY - local 1D coordinate arrays for y direction, not set for one dimensional problems
  • arrZ - 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

source
PETSc.LibPETSc.DMStagGetProductCoordinateArraysReadMethod
arrX::PetscArray, arrY::PetscArray, arrZ::PetscArray = DMStagGetProductCoordinateArraysRead(petsclib::PetscLibType,dm::PetscDM)

extract product coordinate arrays, read

Logically Collective

Input Parameter:

  • dm - the DMSTAG object

Output Parameters:

  • arrX - local 1D coordinate arrays for x direction
  • arrY - local 1D coordinate arrays for y direction, not set for one dimensional problems
  • arrZ - local 1D coordinate arrays for z direction, 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

source
PETSc.LibPETSc.DMStagGetRefinementFactorMethod
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 - the DMSTAG object

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

source
PETSc.LibPETSc.DMStagGetStencilTypeMethod
stencilType::DMStagStencilType = DMStagGetStencilType(petsclib::PetscLibType,dm::PetscDM)

get elementwise ghost/halo stencil type

Not Collective

Input Parameter:

  • dm - the DMSTAG object

Output Parameter:

  • stencilType - the elementwise ghost stencil type: DMSTAG_STENCIL_BOX, DMSTAG_STENCIL_STAR, or DMSTAG_STENCIL_NONE

Level: beginner

See also:

DMSTAG, DMStagSetStencilType(), DMStagGetStencilWidth, DMStagStencilType

External Links

source
PETSc.LibPETSc.DMStagGetStencilWidthMethod
stencilWidth::PetscInt = DMStagGetStencilWidth(petsclib::PetscLibType,dm::PetscDM)

get elementwise stencil width

Not Collective

Input Parameter:

  • dm - the DMSTAG object

Output Parameter:

  • stencilWidth - stencil/halo/ghost width in elements

Level: beginner

See also:

DMSTAG, DMStagSetStencilWidth(), DMStagGetStencilType(), DMDAGetStencilType()

External Links

source
PETSc.LibPETSc.DMStagMatGetValuesStencilMethod
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 - the DMSTAG object
  • mat - the matrix
  • nRow - number of rows
  • posRow - grid locations (including components) of rows
  • nCol - number of columns
  • posCol - 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

source
PETSc.LibPETSc.DMStagMatSetValuesStencilMethod
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 - the DMSTAG object
  • mat - the matrix
  • nRow - number of rows
  • posRow - grid locations (including components) of rows
  • nCol - number of columns
  • posCol - grid locations (including components) of columns
  • val - logically two-dimensional array of values
  • insertMode - INSERT_VALUES or ADD_VALUES

Notes: See notes for MatSetValuesStencil()

Level: intermediate

See also:

DMSTAG, DMStagStencil, DMStagStencilLocation, DMStagVecGetValuesStencil(), DMStagVecSetValuesStencil(), DMStagMatGetValuesStencil(), MatSetValuesStencil(), MatAssemblyBegin(), MatAssemblyEnd(), DMCreateMatrix()

External Links

source
PETSc.LibPETSc.DMStagMigrateVecMethod
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 source DMSTAG object
  • vec - the source vector, compatible with dm
  • dmTo - the compatible destination DMSTAG object
  • vecTo - the destination vector, compatible with dmTo

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

source
PETSc.LibPETSc.DMStagPopulateLocalToGlobalInjectiveMethod
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 - the DMSTAG object

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

source
PETSc.LibPETSc.DMStagRestoreProductCoordinateArraysMethod
DMStagRestoreProductCoordinateArrays(petsclib::PetscLibType,dm::PetscDM, arrX::PetscArray, arrY::PetscArray, arrZ::PetscArray)

restore local array access

Logically Collective

Input Parameter:

  • dm - the DMSTAG object
  • arrX - local 1D coordinate arrays for x direction
  • arrY - local 1D coordinate arrays for y direction
  • arrZ - 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

source
PETSc.LibPETSc.DMStagRestoreProductCoordinateArraysReadMethod
DMStagRestoreProductCoordinateArraysRead(petsclib::PetscLibType,dm::PetscDM, arrX::PetscArray, arrY::PetscArray, arrZ::PetscArray)

restore local product array access, read

Logically Collective

Input Parameters:

  • dm - the DMSTAG object
  • arrX - local 1D coordinate arrays for x direction
  • arrY - local 1D coordinate arrays for y direction
  • arrZ - local 1D coordinate arrays for z direction

Level: intermediate

See also:

DMSTAG, DMStagGetProductCoordinateArrays(), DMStagGetProductCoordinateArraysRead()

External Links

source
PETSc.LibPETSc.DMStagRestrictSimpleMethod
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 - fine DM
  • xf - data on fine DM
  • dmc - coarse DM

Output Parameter:

  • xc - data on coarse DM

Level: advanced

See also:

DMSTAG, DM, DMRestrict(), DMCoarsen(), DMCreateInjection()

External Links

source
PETSc.LibPETSc.DMStagSetBoundaryTypesMethod
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 - the DMSTAG object
  • boundaryType2 - boundary type for x direction
  • boundaryType1 - boundary type for y direction, not set for one dimensional problems
  • boundaryType0 - 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

source
PETSc.LibPETSc.DMStagSetCoordinateDMTypeMethod
DMStagSetCoordinateDMType(petsclib::PetscLibType,dm::PetscDM, dmtype::DMType)

set DM type to store coordinates

Logically Collective; dmtype must contain common value

Input Parameters:

  • dm - the DMSTAG object
  • dmtype - DMtype for coordinates, either DMSTAG or DMPRODUCT

Level: advanced

See also:

DMSTAG, DMPRODUCT, DMGetCoordinateDM(), DMStagSetUniformCoordinates(), DMStagSetUniformCoordinatesExplicit(), DMStagSetUniformCoordinatesProduct(), DMType

External Links

source
PETSc.LibPETSc.DMStagSetDOFMethod
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 - the DMSTAG object
  • 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: advanced

Note: Arguments corresponding to higher dimensions are ignored for 1D and 2D grids.

See also:

DMSTAG, DMDASetDof()

External Links

source
PETSc.LibPETSc.DMStagSetGlobalSizesMethod
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 - the DMSTAG object
  • N0 - global elementwise size in the x direction
  • N1 - global elementwise size in the y direction
  • N2 - 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

source
PETSc.LibPETSc.DMStagSetNumRanksMethod
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 - the DMSTAG object
  • nRanks0 - number of ranks in the x direction
  • nRanks1 - number of ranks in the y direction
  • nRanks2 - 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

source
PETSc.LibPETSc.DMStagSetOwnershipRangesMethod
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 - the DMSTAG object
  • lx - element counts for each rank in the x direction, may be NULL
  • ly - element counts for each rank in the y direction, may be NULL
  • lz - element counts for each rank in the z direction, may be NULL

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

source
PETSc.LibPETSc.DMStagSetRefinementFactorMethod
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 - the DMSTAG object
  • 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

Note: Pass PETSC_IGNORE to leave a value unchanged

See also:

DMSTAG, DMRefine(), DMCoarsen(), DMStagGetRefinementFactor(), DMDAGetRefinementFactor()

External Links

source
PETSc.LibPETSc.DMStagSetStencilTypeMethod
DMStagSetStencilType(petsclib::PetscLibType,dm::PetscDM, stencilType::DMStagStencilType)

set elementwise ghost/halo stencil type

Logically Collective; stencilType must contain common value

Input Parameters:

  • dm - the DMSTAG object
  • stencilType - the elementwise ghost stencil type: DMSTAG_STENCIL_BOX, DMSTAG_STENCIL_STAR, or DMSTAG_STENCIL_NONE

Level: beginner

See also:

DMSTAG, DMStagGetStencilType(), DMStagSetStencilWidth(), DMStagStencilType

External Links

source
PETSc.LibPETSc.DMStagSetStencilWidthMethod
DMStagSetStencilWidth(petsclib::PetscLibType,dm::PetscDM, stencilWidth::PetscInt)

set elementwise stencil width

Logically Collective; stencilWidth must contain common value

Input Parameters:

  • dm - the DMSTAG object
  • stencilWidth - 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

source
PETSc.LibPETSc.DMStagSetUniformCoordinatesMethod
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 - the DMSTAG object
  • xmin - minimum global coordinate value in the x direction
  • xmax - maximum global coordinate values in the x direction
  • ymin - minimum global coordinate value in the y direction
  • ymax - maximum global coordinate value in the y direction
  • zmin - minimum global coordinate value in the z direction
  • zmax - maximum global coordinate value in the z direction

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

source
PETSc.LibPETSc.DMStagSetUniformCoordinatesExplicitMethod
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 - the DMSTAG object
  • xmin - minimum global coordinate value in the x direction
  • xmax - maximum global coordinate value in the x direction
  • ymin - minimum global coordinate value in the y direction
  • ymax - maximum global coordinate value in the y direction
  • zmin - minimum global coordinate value in the z direction
  • zmax - maximum global coordinate value in the z direction

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

source
PETSc.LibPETSc.DMStagSetUniformCoordinatesProductMethod
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 - the DMSTAG object
  • xmin - minimum global coordinate value in the x direction
  • xmax - maximum global coordinate value in the x direction
  • ymin - minimum global coordinate value in the y direction
  • ymax - maximum global coordinate value in the y direction
  • zmin - minimum global coordinate value in the z direction
  • zmax - maximum global coordinate value in the z direction

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

source
PETSc.LibPETSc.DMStagStencilToIndexLocalMethod
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 - the DMSTAG object
  • dim - the dimension of the DMSTAG object
  • n - the number of DMStagStencil objects
  • pos - an array of n DMStagStencil objects

Output Parameter:

  • ix - output array of n indices

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

source
PETSc.LibPETSc.DMStagVecGetArrayMethod
array::PetscArray = DMStagVecGetArray(petsclib::PetscLibType,dm::PetscDM, vec::PetscVec)

get access to local array

Logically Collective

Input Parameters:

  • dm - the DMSTAG object
  • vec - the Vec object

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

source
PETSc.LibPETSc.DMStagVecGetArrayReadMethod
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 - the DMSTAG object
  • vec - the Vec object

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

source
PETSc.LibPETSc.DMStagVecGetValuesStencilMethod
val::PetscScalar = DMStagVecGetValuesStencil(petsclib::PetscLibType,dm::PetscDM, vec::PetscVec, n::PetscInt, pos::DMStagStencil)

get vector values using grid indexing

Not Collective

Input Parameters:

  • dm - the DMSTAG object
  • vec - the vector object
  • n - the number of values to obtain
  • pos - locations to obtain values from (as an array of DMStagStencil values)

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

source
PETSc.LibPETSc.DMStagVecRestoreArrayMethod
DMStagVecRestoreArray(petsclib::PetscLibType,dm::PetscDM, vec::PetscVec, array::PetscArray)

restore access to a raw array

Logically Collective

Input Parameters:

  • dm - the DMSTAG object
  • vec - the Vec object

Output Parameter:

  • array - the array

Level: beginner

See also:

DMSTAG, DMStagVecGetArray(), DMDAVecRestoreArray(), DMDAVecRestoreArrayDOF()

External Links

source
PETSc.LibPETSc.DMStagVecRestoreArrayReadMethod
DMStagVecRestoreArrayRead(petsclib::PetscLibType,dm::PetscDM, vec::PetscVec, array::PetscArray)

restore read

Logically Collective

Input Parameters:

  • dm - the DMSTAG object
  • vec - the Vec object

Output Parameter:

  • array - the read-only array

Level: beginner

See also:

DMSTAG, DMStagVecGetArrayRead(), DMDAVecRestoreArrayRead(), DMDAVecRestoreArrayDOFRead()

External Links

source
PETSc.LibPETSc.DMStagVecSetValuesStencilMethod
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 - the DMSTAG object
  • vec - the Vec
  • n - the number of values to set
  • pos - the locations to set values, as an array of DMStagStencil structs
  • val - the values to set
  • insertMode - INSERT_VALUES or ADD_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

source
PETSc.LibPETSc.DMStagVecSplitToDMDAMethod
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 - the DMSTAG object
  • vec - Vec object associated with dm
  • loc - which subgrid to extract (see DMStagStencilLocation)
  • c - which component to extract (see note below)

Output Parameters:

  • pda - the DMDA
  • pdavec - the new Vec

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

source