DMSwarm (Particle Methods)

DMSwarm manages particle-based methods including particle-in-cell (PIC), smoothed particle hydrodynamics (SPH), and general particle simulations.

Overview

DMSwarm provides:

  • Dynamic particle creation and migration
  • Field registration for particle data
  • Particle-mesh coupling
  • Particle migration across MPI processes
  • Support for PIC and general particle methods
  • Cell-based particle management

Basic Usage Pattern

using PETSc, MPI

# Initialize MPI and PETSc
MPI.Init()
petsclib = PETSc.getlib()
PETSc.initialize(petsclib)

# Create a DMSwarm in PIC mode
swarm = LibPETSc.DMCreate(petsclib, MPI.COMM_WORLD)
LibPETSc.DMSetType(petsclib, swarm, "swarm")  # String convenience wrapper
# Set the geometric/topological dimension for the swarm (required)
LibPETSc.DMSetDimension(petsclib, swarm, 1)

# Set swarm type to PIC
LibPETSc.DMSwarmSetType(petsclib, swarm, LibPETSc.DMSWARM_PIC)

# Create background mesh (here we use a 1D DMDA for simplicity)
da = LibPETSc.DMDACreate1d(petsclib, MPI.COMM_WORLD, LibPETSc.DM_BOUNDARY_NONE, 10, 1, 1, C_NULL)

# Set the cell DM for PIC
LibPETSc.DMSwarmSetCellDM(petsclib, swarm, da)

# Register a particle field `velocity` with blocksize 3 (x,y,z components)
LibPETSc.DMSwarmRegisterPetscDatatypeField(
    petsclib, swarm,
    "velocity", 3, LibPETSc.PETSC_DOUBLE
)

# Finalize field registration
LibPETSc.DMSwarmFinalizeFieldRegister(petsclib, swarm)

# Set number of particles
nparticles = 100
LibPETSc.DMSwarmSetLocalSizes(petsclib, swarm, nparticles, 0)

# Access and set particle data using DMSwarmGetField / DMSwarmRestoreField
# `DMSwarmGetField` returns the blocksize and fills a pointer to the underlying
# data array. In Julia, pass a `Vector{Ptr{Cvoid}}(undef,1)` and a `Ref{PetscDataType}`
# to receive the out parameters and then wrap the returned pointer with `unsafe_wrap`.
ptr_store = Vector{Ptr{Cvoid}}(undef, 1)
type_store = Ref{LibPETSc.PetscDataType}()
blocksize = LibPETSc.DMSwarmGetField(petsclib, swarm, "velocity", type_store, pointer(ptr_store))
# `ptr_store[1]` is a pointer to `PetscReal` (Float64 by default) array of length blocksize * nparticles
@assert type_store[] == LibPETSc.PETSC_DOUBLE
data = unsafe_wrap(Array, Ptr{Float64}(ptr_store[1]), (blocksize * nparticles,))
# Initialize velocity values
for i in 1:length(data)
    data[i] = 0.1 * i
end
# Restore the field when done (unlocks internal storage)
LibPETSc.DMSwarmRestoreField(petsclib, swarm, "velocity", type_store, pointer(ptr_store))

# Cleanup
LibPETSc.DMDestroy(petsclib, swarm)
LibPETSc.DMDestroy(petsclib, da)

# Finalize PETSc and MPI
PETSc.finalize(petsclib)
MPI.Finalize()

DMSwarm Functions

PETSc.LibPETSc.DMSwarmAddCellDMMethod
DMSwarmAddCellDM(petsclib::PetscLibType,sw::PetscDM, celldm::DMSwarmCellDM)

Adds a cell DM to the DMSWARM

Collective

Input Parameters:

  • sw - a DMSWARM
  • celldm - the DMSwarmCellDM

Level: beginner

-seealso: DM, DMSWARM, DMSwarmSetType(), DMSwarmPushCellDM(), DMSwarmSetCellDM(), DMSwarmMigrate()

External Links

source
PETSc.LibPETSc.DMSwarmAddNPointsMethod
DMSwarmAddNPoints(petsclib::PetscLibType,dm::PetscDM, npoints::PetscInt)

Add space for a number of new points in the DMSWARM

Not Collective

Input Parameters:

  • dm - a DMSWARM
  • npoints - the number of new points to add

Level: beginner

-seealso: DM, DMSWARM, DMSwarmAddPoint()

External Links

source
PETSc.LibPETSc.DMSwarmCollectViewCreateMethod
DMSwarmCollectViewCreate(petsclib::PetscLibType,dm::PetscDM)

Applies a collection method and gathers points in neighbour ranks into the DMSWARM

Collective

Input Parameter:

  • dm - the DMSWARM

Level: advanced

-seealso: DM, DMSWARM, DMSwarmCollectViewDestroy(), DMSwarmSetCollectType()

External Links

source
PETSc.LibPETSc.DMSwarmComputeLocalSizeMethod
DMSwarmComputeLocalSize(petsclib::PetscLibType,sw::PetscDM, N::PetscInt, density::PetscProbFn)

Compute the local number and distribution of particles based upon a density function

Not Collective

Input Parameters:

  • sw - The DMSWARM
  • N - The target number of particles
  • density - The density field for the particle layout, normalized to unity

Level: advanced

-seealso: DMSWARM, DMSwarmComputeLocalSizeFromOptions()

External Links

source
PETSc.LibPETSc.DMSwarmComputeMomentsMethod
moments::Vector{PetscReal} = DMSwarmComputeMoments(petsclib::PetscLibType,sw::PetscDM, coordinate::String, weight::String)

Compute the first three particle moments for a given field

Noncollective

Input Parameters:

  • sw - the DMSWARM
  • coordinate - the coordinate field name
  • weight - the weight field name

Output Parameter:

  • moments - the field moments

Level: intermediate

-seealso: DM, DMSWARM, DMPlexComputeMoments()

External Links

source
PETSc.LibPETSc.DMSwarmCopyPointMethod
DMSwarmCopyPoint(petsclib::PetscLibType,dm::PetscDM, pi::PetscInt, pj::PetscInt)

Copy point pj to point pi in the DMSWARM

Not Collective

Input Parameters:

  • dm - a DMSWARM
  • pi - the index of the point to copy
  • pj - the point index where the copy should be located

Level: beginner

-seealso: DM, DMSWARM, DMSwarmRemovePoint()

External Links

source
PETSc.LibPETSc.DMSwarmCreateGlobalVectorFromFieldMethod
vec::PetscVec = DMSwarmCreateGlobalVectorFromField(petsclib::PetscLibType,dm::PetscDM, fieldname::String)

Creates a Vec object sharing the array associated with a given field

Collective

Input Parameters:

  • dm - a DMSWARM
  • fieldname - the textual name given to a registered field

Output Parameter:

  • vec - the vector

Level: beginner

-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmDestroyGlobalVectorFromField()

External Links

source
PETSc.LibPETSc.DMSwarmCreateGlobalVectorFromFieldsMethod
vec::PetscVec = DMSwarmCreateGlobalVectorFromFields(petsclib::PetscLibType,dm::PetscDM, Nf::PetscInt, fieldnames::String)

Creates a Vec object sharing the array associated with a given field set

Collective

Input Parameters:

  • dm - a DMSWARM
  • Nf - the number of fields
  • fieldnames - the textual names given to the registered fields

Output Parameter:

  • vec - the vector

Level: beginner

-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmDestroyGlobalVectorFromFields()

External Links

source
PETSc.LibPETSc.DMSwarmCreateLocalVectorFromFieldMethod
vec::PetscVec = DMSwarmCreateLocalVectorFromField(petsclib::PetscLibType,dm::PetscDM, fieldname::String)

Creates a Vec object sharing the array associated with a given field

Collective

Input Parameters:

  • dm - a DMSWARM
  • fieldname - the textual name given to a registered field

Output Parameter:

  • vec - the vector

Level: beginner

-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmDestroyLocalVectorFromField()

External Links

source
PETSc.LibPETSc.DMSwarmCreateLocalVectorFromFieldsMethod
vec::PetscVec = DMSwarmCreateLocalVectorFromFields(petsclib::PetscLibType,dm::PetscDM, Nf::PetscInt, fieldnames::String)

Creates a Vec object sharing the array associated with a given field set

Collective

Input Parameters:

  • dm - a DMSWARM
  • Nf - the number of fields
  • fieldnames - the textual names given to the registered fields

Output Parameter:

  • vec - the vector

Level: beginner

-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmDestroyLocalVectorFromField()

External Links

source
PETSc.LibPETSc.DMSwarmCreatePointPerCellCountMethod
ncells::PetscInt,count::PetscInt = DMSwarmCreatePointPerCellCount(petsclib::PetscLibType,sw::PetscDM)

Count the number of points within all cells in the cell DM

Not Collective

Input Parameter:

  • sw - the DMSWARM

Output Parameters:

  • ncells - the number of cells in the cell DM (optional argument, pass NULL to ignore)
  • count - array of length ncells containing the number of points per cell

Level: beginner

-seealso: DMSWARM, DMSwarmSetType(), DMSwarmSetCellDM(), DMSwarmType

External Links

source
PETSc.LibPETSc.DMSwarmDestroyGlobalVectorFromFieldMethod
DMSwarmDestroyGlobalVectorFromField(petsclib::PetscLibType,dm::PetscDM, fieldname::String, vec::PetscVec)

Destroys the Vec object which share the array associated with a given field

Collective

Input Parameters:

  • dm - a DMSWARM
  • fieldname - the textual name given to a registered field

Output Parameter:

  • vec - the vector

Level: beginner

-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmCreateGlobalVectorFromField()

External Links

source
PETSc.LibPETSc.DMSwarmDestroyGlobalVectorFromFieldsMethod
DMSwarmDestroyGlobalVectorFromFields(petsclib::PetscLibType,dm::PetscDM, Nf::PetscInt, fieldnames::String, vec::PetscVec)

Destroys the Vec object which share the array associated with a given field set

Collective

Input Parameters:

  • dm - a DMSWARM
  • Nf - the number of fields
  • fieldnames - the textual names given to the registered fields

Output Parameter:

  • vec - the vector

Level: beginner

-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmCreateGlobalVectorFromField()

External Links

source
PETSc.LibPETSc.DMSwarmDestroyLocalVectorFromFieldMethod
DMSwarmDestroyLocalVectorFromField(petsclib::PetscLibType,dm::PetscDM, fieldname::String, vec::PetscVec)

Destroys the Vec object which share the array associated with a given field

Collective

Input Parameters:

  • dm - a DMSWARM
  • fieldname - the textual name given to a registered field

Output Parameter:

  • vec - the vector

Level: beginner

-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmCreateLocalVectorFromField()

External Links

source
PETSc.LibPETSc.DMSwarmDestroyLocalVectorFromFieldsMethod
DMSwarmDestroyLocalVectorFromFields(petsclib::PetscLibType,dm::PetscDM, Nf::PetscInt, fieldnames::String, vec::PetscVec)

Destroys the Vec object which share the array associated with a given field set

Collective

Input Parameters:

  • dm - a DMSWARM
  • Nf - the number of fields
  • fieldnames - the textual names given to the registered fields

Output Parameter:

  • vec - the vector

Level: beginner

-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmCreateLocalVectorFromFields()

External Links

source
PETSc.LibPETSc.DMSwarmDuplicateMethod
nsw::PetscDM = DMSwarmDuplicate(petsclib::PetscLibType,sw::PetscDM)

Creates a new DMSWARM with the same fields and cell DMs but no particles

Collective

Input Parameter:

  • sw - the DMSWARM

Output Parameter:

  • nsw - the new DMSWARM

Level: beginner

-seealso: DM, DMSWARM, DMSwarmCreate(), DMClone()

External Links

source
PETSc.LibPETSc.DMSwarmFinalizeFieldRegisterMethod
DMSwarmFinalizeFieldRegister(petsclib::PetscLibType,dm::PetscDM)

Finalizes the registration of fields to a DMSWARM

Collective

Input Parameter:

  • dm - a DMSWARM

Level: beginner

-seealso: DM, DMSWARM, DMSwarmInitializeFieldRegister(), DMSwarmRegisterPetscDatatypeField(), DMSwarmRegisterUserStructField(), DMSwarmRegisterUserDatatypeField()

External Links

source
PETSc.LibPETSc.DMSwarmGetCellDMMethod
DMSwarmGetCellDM(petsclib::PetscLibType,sw::PetscDM, dm::PetscDM)

Fetches the active cell DM

Collective

Input Parameter:

  • sw - a DMSWARM

Output Parameter:

  • dm - the active DM for the DMSWARM

Level: beginner

-seealso: DM, DMSWARM, DMSwarmSetCellDM()

External Links

source
PETSc.LibPETSc.DMSwarmGetCellDMActiveMethod
DMSwarmGetCellDMActive(petsclib::PetscLibType,sw::PetscDM, celldm::DMSwarmCellDM)

Returns the active cell DM for a DMSWARM

Collective

Input Parameter:

  • sw - a DMSWARM

Output Parameter:

  • celldm - the active DMSwarmCellDM

Level: beginner

-seealso: DM, DMSWARM, DMSwarmCellDM, DMSwarmSetType(), DMSwarmAddCellDM(), DMSwarmSetCellDM(), DMSwarmMigrate()

External Links

source
PETSc.LibPETSc.DMSwarmGetCellDMByNameMethod
DMSwarmGetCellDMByName(petsclib::PetscLibType,sw::PetscDM, name::String, celldm::DMSwarmCellDM)

Get a DMSwarmCellDM from its name

Not collective

Input Parameters:

  • sw - a DMSWARM
  • name - the name

Output Parameter:

  • celldm - the DMSwarmCellDM

Level: beginner

-seealso: DM, DMSWARM, DMSwarmSetCellDM(), DMSwarmGetCellDMNames()

External Links

source
PETSc.LibPETSc.DMSwarmGetCellDMNamesMethod
Ndm::PetscInt = DMSwarmGetCellDMNames(petsclib::PetscLibType,sw::PetscDM, celldms::String)

Get the list of cell DM names

Not collective

Input Parameter:

  • sw - a DMSWARM

Output Parameters:

  • Ndm - the number of DMSwarmCellDM in the DMSWARM
  • celldms - the name of each DMSwarmCellDM

Level: beginner

-seealso: DM, DMSWARM, DMSwarmSetCellDM(), DMSwarmGetCellDMByName()

External Links

source
PETSc.LibPETSc.DMSwarmGetCellSwarmMethod
DMSwarmGetCellSwarm(petsclib::PetscLibType,sw::PetscDM, cellID::PetscInt, cellswarm::PetscDM)

Extracts a single cell from the DMSWARM object, returns it as a single cell DMSWARM. The cell DM is filtered for fields of that cell, and the filtered DM is used as the cell DM of the new swarm object.

Noncollective

Input Parameters:

  • sw - the DMSWARM
  • cellID - the integer id of the cell to be extracted and filtered
  • cellswarm - The DMSWARM to receive the cell

Level: beginner

-seealso: DM, DMSWARM, DMSwarmRestoreCellSwarm()

External Links

source
PETSc.LibPETSc.DMSwarmGetCoordinateFunctionMethod
DMSwarmGetCoordinateFunction(petsclib::PetscLibType,sw::PetscDM, coordFunc::PetscSimplePoCintFn)

Get the function setting initial particle positions, if it exists

Not Collective

Input Parameter:

  • sw - the DMSWARM

Output Parameter:

  • coordFunc - the function setting initial particle positions, or NULL, see PetscSimplePointFn for the calling sequence

Level: intermediate

-seealso: DMSWARM, DMSwarmSetCoordinateFunction(), DMSwarmGetVelocityFunction(), DMSwarmInitializeCoordinates(), PetscSimplePointFn

External Links

source
PETSc.LibPETSc.DMSwarmGetFieldMethod
blocksize::PetscInt = DMSwarmGetField(petsclib::PetscLibType,dm::PetscDM, fieldname::String, type::PetscDataType, data::Cvoid)

Get access to the underlying array storing all entries associated with a registered field

Not Collective, No Fortran Support

Input Parameters:

  • dm - a DMSWARM
  • fieldname - the textual name to identify this field

Output Parameters:

  • blocksize - the number of each data type
  • type - the data type
  • data - pointer to raw array

Level: beginner

-seealso: DM, DMSWARM, DMSwarmRestoreField()

External Links

source
PETSc.LibPETSc.DMSwarmGetLocalSizeMethod
nloc::PetscInt = DMSwarmGetLocalSize(petsclib::PetscLibType,dm::PetscDM)

Retrieves the local length of fields registered

Not Collective

Input Parameter:

  • dm - a DMSWARM

Output Parameter:

  • nlocal - the length of each registered field

Level: beginner

-seealso: DM, DMSWARM, DMSwarmGetSize(), DMSwarmSetLocalSizes()

External Links

source
PETSc.LibPETSc.DMSwarmGetMigrateTypeMethod
mtype::DMSwarmMigrateType = DMSwarmGetMigrateType(petsclib::PetscLibType,dm::PetscDM)

Get the style of point migration

Logically Collective

Input Parameter:

  • dm - the DMSWARM

Output Parameter:

  • mtype - The migration type, see DMSwarmMigrateType

Level: intermediate

-seealso: DM, DMSWARM, DMSwarmMigrateType, DMSwarmMigrate()

External Links

source
PETSc.LibPETSc.DMSwarmGetNumSpeciesMethod
Ns::PetscInt = DMSwarmGetNumSpecies(petsclib::PetscLibType,sw::PetscDM)

Get the number of particle species

Not Collective

Input Parameter:

  • sw - the DMSWARM

Output Parameters:

  • Ns - the number of species

Level: intermediate

-seealso: DMSWARM, DMSwarmSetNumSpecies(), DMSwarmSetType(), DMSwarmType

External Links

source
PETSc.LibPETSc.DMSwarmGetSizeMethod
n::PetscInt = DMSwarmGetSize(petsclib::PetscLibType,dm::PetscDM)

Retrieves the total length of fields registered

Collective

Input Parameter:

  • dm - a DMSWARM

Output Parameter:

  • n - the total length of each registered field

Level: beginner

-seealso: DM, DMSWARM, DMSwarmGetLocalSize(), DMSwarmSetLocalSizes()

External Links

source
PETSc.LibPETSc.DMSwarmGetTypeMethod
stype::DMSwarmType = DMSwarmGetType(petsclib::PetscLibType,sw::PetscDM)

Get particular flavor of DMSWARM

Collective

Input Parameter:

  • sw - the DMSWARM

Output Parameter:

  • stype - the DMSWARM type (e.g. DMSWARM_PIC)

Level: advanced

-seealso: DM, DMSWARM, DMSwarmSetMigrateType(), DMSwarmSetCollectType(), DMSwarmType, DMSWARM_PIC, DMSWARM_BASIC

External Links

source
PETSc.LibPETSc.DMSwarmGetVelocityFunctionMethod
DMSwarmGetVelocityFunction(petsclib::PetscLibType,sw::PetscDM, velFunc::PetscSimplePoCintFn)

Get the function setting initial particle velocities, if it exists

Not Collective

Input Parameter:

  • sw - the DMSWARM

Output Parameter:

  • velFunc - the function setting initial particle velocities, or NULL, see PetscSimplePointFn for the calling sequence

Level: intermediate

-seealso: DMSWARM, DMSwarmSetVelocityFunction(), DMSwarmGetCoordinateFunction(), DMSwarmInitializeVelocities(), PetscSimplePointFn

External Links

source
PETSc.LibPETSc.DMSwarmInitializeFieldRegisterMethod
DMSwarmInitializeFieldRegister(petsclib::PetscLibType,dm::PetscDM)

Initiates the registration of fields to a DMSWARM

Collective

Input Parameter:

  • dm - a DMSWARM

Level: beginner

-seealso: DM, DMSWARM, DMSwarmFinalizeFieldRegister(), DMSwarmRegisterPetscDatatypeField(), DMSwarmRegisterUserStructField(), DMSwarmRegisterUserDatatypeField()

External Links

source
PETSc.LibPETSc.DMSwarmInitializeVelocitiesMethod
DMSwarmInitializeVelocities(petsclib::PetscLibType,sw::PetscDM, sampler::PetscProbFn, v0::Vector{PetscReal})

Set the initial velocities of particles using a distribution.

Collective

Input Parameters:

  • sw - The DMSWARM object
  • sampler - A function which uniformly samples the velocity PDF
  • v0 - The velocity scale for nondimensionalization for each species

Level: advanced

-seealso: DMSWARM, DMSwarmComputeLocalSize(), DMSwarmInitializeCoordinates(), DMSwarmInitializeVelocitiesFromOptions()

External Links

source
PETSc.LibPETSc.DMSwarmInitializeVelocitiesFromOptionsMethod
DMSwarmInitializeVelocitiesFromOptions(petsclib::PetscLibType,sw::PetscDM, v0::Vector{PetscReal})

Set the initial velocities of particles using a distribution determined from options.

Collective

Input Parameters:

  • sw - The DMSWARM object
  • v0 - The velocity scale for nondimensionalization for each species

Level: advanced

-seealso: DMSWARM, DMSwarmComputeLocalSize(), DMSwarmInitializeCoordinates(), DMSwarmInitializeVelocities()

External Links

source
PETSc.LibPETSc.DMSwarmInsertPointsUsingCellDMMethod
DMSwarmInsertPointsUsingCellDM(petsclib::PetscLibType,dm::PetscDM, layout_type::DMSwarmPICLayoutType, fill_param::PetscInt)

Insert point coordinates within each cell

Not Collective

Input Parameters:

  • dm - the DMSWARM
  • layout_type - method used to fill each cell with the cell DM
  • fill_param - parameter controlling how many points per cell are added (the meaning of this parameter is dependent on the layout type)

Level: beginner

-seealso: DMSWARM, DMSwarmPICLayoutType, DMSwarmSetType(), DMSwarmSetCellDM(), DMSwarmType

External Links

source
PETSc.LibPETSc.DMSwarmMigrateMethod
DMSwarmMigrate(petsclib::PetscLibType,dm::PetscDM, remove_sent_points::PetscBool)

Relocates points defined in the DMSWARM to other MPI

Collective

Input Parameters:

  • dm - the DMSWARM
  • remove_sent_points - flag indicating if sent points should be removed from the current MPI-rank

Level: advanced

-seealso: DM, DMSWARM, DMSwarmSetMigrateType()

External Links

source
PETSc.LibPETSc.DMSwarmProjectFieldsMethod
DMSwarmProjectFields(petsclib::PetscLibType,sw::PetscDM, dm::PetscDM, nfields::PetscInt, fieldnames::String, fields::Vector{PetscVec}, mode::ScatterMode)

Project a set of swarm fields onto another DM

Collective

Input Parameters:

  • sw - the DMSWARM
  • dm - the DM, or NULL to use the cell DM
  • nfields - the number of swarm fields to project
  • fieldnames - the textual names of the swarm fields to project
  • fields - an array of Vec's of length nfields
  • mode - if SCATTER_FORWARD then map particles to the continuum, and if SCATTER_REVERSE map the continuum to particles

Level: beginner

See also:

DMSWARM, DMSwarmSetType(), DMSwarmSetCellDM(), DMSwarmType

External Links

source
PETSc.LibPETSc.DMSwarmRegisterPetscDatatypeFieldMethod
DMSwarmRegisterPetscDatatypeField(petsclib::PetscLibType,dm::PetscDM, fieldname::String, blocksize::PetscInt, type::PetscDataType)

Register a field to a DMSWARM with a native PETSc data type

Collective

Input Parameters:

  • dm - a DMSWARM
  • fieldname - the textual name to identify this field
  • blocksize - the number of each data type
  • type - a valid PETSc data type (PETSC_CHAR, PETSC_SHORT, PETSC_INT, PETSC_FLOAT, PETSC_REAL, PETSC_LONG)

Level: beginner

-seealso: DM, DMSWARM, DMSwarmRegisterUserStructField(), DMSwarmRegisterUserDatatypeField()

External Links

source
PETSc.LibPETSc.DMSwarmRegisterUserDatatypeFieldMethod
DMSwarmRegisterUserDatatypeField(petsclib::PetscLibType,dm::PetscDM, fieldname::String, size::Csize_t, blocksize::PetscInt)

Register a user defined data type to a DMSWARM

Collective

Input Parameters:

  • dm - a DMSWARM
  • fieldname - the textual name to identify this field
  • size - the size in bytes of the user data type
  • blocksize - the number of each data type

Level: beginner

-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmRegisterUserStructField()

External Links

source
PETSc.LibPETSc.DMSwarmRegisterUserStructFieldMethod
DMSwarmRegisterUserStructField(petsclib::PetscLibType,dm::PetscDM, fieldname::String, size::Csize_t)

Register a user defined struct to a DMSWARM

Collective

Input Parameters:

  • dm - a DMSWARM
  • fieldname - the textual name to identify this field
  • size - the size in bytes of the user struct of each data type

Level: beginner

-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmRegisterUserDatatypeField()

External Links

source
PETSc.LibPETSc.DMSwarmRemapMethod
DMSwarmRemap(petsclib::PetscLibType,sw::PetscDM)

Project the swarm fields onto a new set of particles

Collective

Input Parameter:

  • sw - The DMSWARM object

Level: beginner

See also:

DMSWARM, DMSwarmMigrate(), DMSwarmCrate()

External Links

source
PETSc.LibPETSc.DMSwarmRestoreCellSwarmMethod
DMSwarmRestoreCellSwarm(petsclib::PetscLibType,sw::PetscDM, cellID::PetscInt, cellswarm::PetscDM)

Restores a DMSWARM object obtained with DMSwarmGetCellSwarm(). All fields are copied back into the parent swarm.

Noncollective

Input Parameters:

  • sw - the parent DMSWARM
  • cellID - the integer id of the cell to be copied back into the parent swarm
  • cellswarm - the cell swarm object

Level: beginner

-seealso: DM, DMSWARM, DMSwarmGetCellSwarm()

External Links

source
PETSc.LibPETSc.DMSwarmRestoreFieldMethod
blocksize::PetscInt = DMSwarmRestoreField(petsclib::PetscLibType,dm::PetscDM, fieldname::String, type::PetscDataType, data::Cvoid)

Restore access to the underlying array storing all entries associated with a registered field

Not Collective

Input Parameters:

  • dm - a DMSWARM
  • fieldname - the textual name to identify this field

Output Parameters:

  • blocksize - the number of each data type
  • type - the data type
  • data - pointer to raw array

Level: beginner

-seealso: DM, DMSWARM, DMSwarmGetField()

External Links

source
PETSc.LibPETSc.DMSwarmSetCellDMMethod
DMSwarmSetCellDM(petsclib::PetscLibType,sw::PetscDM, dm::PetscDM)

Attaches a DM to a DMSWARM

Collective

Input Parameters:

  • sw - a DMSWARM
  • dm - the DM to attach to the DMSWARM

Level: beginner

-seealso: DM, DMSWARM, DMSwarmSetType(), DMSwarmGetCellDM(), DMSwarmMigrate()

External Links

source
PETSc.LibPETSc.DMSwarmSetCellDMActiveMethod
DMSwarmSetCellDMActive(petsclib::PetscLibType,sw::PetscDM, name::String)

Activates a cell DM for a DMSWARM

Collective

Input Parameters:

  • sw - a DMSWARM
  • name - name of the cell DM to active for the DMSWARM

Level: beginner

-seealso: DM, DMSWARM, DMSwarmCellDM, DMSwarmSetType(), DMSwarmAddCellDM(), DMSwarmSetCellDM(), DMSwarmMigrate()

External Links

source
PETSc.LibPETSc.DMSwarmSetCoordinateFunctionMethod
DMSwarmSetCoordinateFunction(petsclib::PetscLibType,sw::PetscDM, coordFunc::PetscSimplePoCintFn)

Set the function setting initial particle positions

Not Collective

Input Parameters:

  • sw - the DMSWARM
  • coordFunc - the function setting initial particle positions, see PetscSimplePointFn for the calling sequence

Level: intermediate

-seealso: DMSWARM, DMSwarmGetCoordinateFunction(), DMSwarmSetVelocityFunction(), DMSwarmInitializeCoordinates(), PetscSimplePointFn

External Links

source
PETSc.LibPETSc.DMSwarmSetLocalSizesMethod
DMSwarmSetLocalSizes(petsclib::PetscLibType,sw::PetscDM, nloc::PetscInt, buffer::PetscInt)

Sets the length of all registered fields on the DMSWARM

Not Collective

Input Parameters:

  • sw - a DMSWARM
  • nlocal - the length of each registered field
  • buffer - the length of the buffer used to efficient dynamic re-sizing

Level: beginner

-seealso: DM, DMSWARM, DMSwarmGetLocalSize()

External Links

source
PETSc.LibPETSc.DMSwarmSetMigrateTypeMethod
DMSwarmSetMigrateType(petsclib::PetscLibType,dm::PetscDM, mtype::DMSwarmMigrateType)

Set the style of point migration

Logically Collective

Input Parameters:

  • dm - the DMSWARM
  • mtype - The migration type, see DMSwarmMigrateType

Level: intermediate

-seealso: DM, DMSWARM, DMSwarmMigrateType, DMSwarmGetMigrateType(), DMSwarmMigrate()

External Links

source
PETSc.LibPETSc.DMSwarmSetNumSpeciesMethod
DMSwarmSetNumSpecies(petsclib::PetscLibType,sw::PetscDM, Ns::PetscInt)

Set the number of particle species

Not Collective

Input Parameters:

  • sw - the DMSWARM
  • Ns - the number of species

Level: intermediate

-seealso: DMSWARM, DMSwarmGetNumSpecies(), DMSwarmSetType(), DMSwarmType

External Links

source
PETSc.LibPETSc.DMSwarmSetPointCoordinatesMethod
DMSwarmSetPointCoordinates(petsclib::PetscLibType,sw::PetscDM, npoints::PetscInt, coor::Vector{PetscReal}, redundant::PetscBool, mode::InsertMode)

Set point coordinates in a DMSWARM from a user defined list

Collective

Input Parameters:

  • sw - the DMSWARM
  • npoints - the number of points to insert
  • coor - the coordinate values
  • redundant - if set to PETSC_TRUE, it is assumed that npoints and coor are only valid on rank 0 and should be broadcast to other ranks
  • mode - indicates whether to append points to the swarm (ADD_VALUES), or over-ride existing points (INSERT_VALUES)

Level: beginner

-seealso: DMSWARM, DMSwarmSetType(), DMSwarmSetCellDM(), DMSwarmType, DMSwarmSetPointsUniformCoordinates()

External Links

source
PETSc.LibPETSc.DMSwarmSetPointCoordinatesCellwiseMethod
DMSwarmSetPointCoordinatesCellwise(petsclib::PetscLibType,dm::PetscDM, npoints::PetscInt, xi::Vector{PetscReal})

Insert point coordinates (defined over the reference cell) within each cell

Not Collective

Input Parameters:

  • dm - the DMSWARM
  • npoints - the number of points to insert in each cell
  • xi - the coordinates (defined in the local coordinate system for each cell) to insert

Level: beginner

-seealso: DMSWARM, DMSwarmSetCellDM(), DMSwarmInsertPointsUsingCellDM()

External Links

source
PETSc.LibPETSc.DMSwarmSetPointsUniformCoordinatesMethod
DMSwarmSetPointsUniformCoordinates(petsclib::PetscLibType,sw::PetscDM, min::Vector{PetscReal}, max::Vector{PetscReal}, npoints::Vector{PetscInt}, mode::InsertMode)

Set point coordinates in a DMSWARM on a regular (ijk) grid

Collective

Input Parameters:

  • sw - the DMSWARM
  • min - minimum coordinate values in the x, y, z directions (array of length dim)
  • max - maximum coordinate values in the x, y, z directions (array of length dim)
  • npoints - number of points in each spatial direction (array of length dim)
  • mode - indicates whether to append points to the swarm (ADD_VALUES), or over-ride existing points (INSERT_VALUES)

Level: beginner

-seealso: DM, DMSWARM, DMSwarmSetType(), DMSwarmSetCellDM(), DMSwarmType

External Links

source
PETSc.LibPETSc.DMSwarmSetTypeMethod
DMSwarmSetType(petsclib::PetscLibType,sw::PetscDM, stype::DMSwarmType)

Set particular flavor of DMSWARM

Collective

Input Parameters:

  • sw - the DMSWARM
  • stype - the DMSWARM type (e.g. DMSWARM_PIC)

Level: advanced

-seealso: DM, DMSWARM, DMSwarmSetMigrateType(), DMSwarmSetCollectType(), DMSwarmType, DMSWARM_PIC, DMSWARM_BASIC

External Links

source
PETSc.LibPETSc.DMSwarmSetVelocityFunctionMethod
DMSwarmSetVelocityFunction(petsclib::PetscLibType,sw::PetscDM, velFunc::PetscSimplePoCintFn)

Set the function setting initial particle velocities

Not Collective

Input Parameters:

  • sw - the DMSWARM
  • velFunc - the function setting initial particle velocities, see PetscSimplePointFn for the calling sequence

Level: intermediate

-seealso: DMSWARM, DMSwarmGetVelocityFunction(), DMSwarmSetCoordinateFunction(), DMSwarmInitializeVelocities(), PetscSimplePointFn

External Links

source
PETSc.LibPETSc.DMSwarmVectorDefineFieldMethod
DMSwarmVectorDefineField(petsclib::PetscLibType,dm::PetscDM, fieldname::String)

Sets the field from which to define a Vec object when DMCreateLocalVector(), or DMCreateGlobalVector() is called

Collective

Input Parameters:

  • dm - a DMSWARM
  • fieldname - the textual name given to each registered field

Level: beginner

-seealso: DM, DMSWARM, DMSwarmVectorDefineFields(), DMSwarmVectorGetField(), DMSwarmRegisterPetscDatatypeField(), DMCreateGlobalVector(), DMCreateLocalVector()

External Links

source
PETSc.LibPETSc.DMSwarmVectorDefineFieldsMethod
DMSwarmVectorDefineFields(petsclib::PetscLibType,sw::PetscDM, Nf::PetscInt, fieldnames::String)

Sets the fields from which to define a Vec object when DMCreateLocalVector(), or DMCreateGlobalVector() is called

Collective, No Fortran support

Input Parameters:

  • sw - a DMSWARM
  • Nf - the number of fields
  • fieldnames - the textual name given to each registered field

Level: beginner

-seealso: DM, DMSWARM, DMSwarmVectorDefineField(), DMSwarmVectorGetField(), DMSwarmRegisterPetscDatatypeField(), DMCreateGlobalVector(), DMCreateLocalVector()

External Links

source
PETSc.LibPETSc.DMSwarmVectorGetFieldMethod
Nf::PetscInt = DMSwarmVectorGetField(petsclib::PetscLibType,sw::PetscDM, fieldnames::String)

Gets the fields from which to define a Vec object when DMCreateLocalVector(), or DMCreateGlobalVector() is called

Not collective

Input Parameter:

  • sw - a DMSWARM

Output Parameters:

  • Nf - the number of fields
  • fieldnames - the textual name given to each registered field, or NULL if it has not been set

Level: beginner

-seealso: DM, DMSWARM, DMSwarmVectorDefineField(), DMSwarmRegisterPetscDatatypeField(), DMCreateGlobalVector(), DMCreateLocalVector()

External Links

source
PETSc.LibPETSc.DMSwarmViewFieldsXDMFMethod
DMSwarmViewFieldsXDMF(petsclib::PetscLibType,dm::PetscDM, filename::String, nfields::PetscInt, field_name_list::String)

Write a selection of DMSwarm fields to an XDMF3 file

Collective

Input Parameters:

  • dm - the DMSWARM
  • filename - the file name of the XDMF file (must have the extension .xmf)
  • nfields - the number of fields to write into the XDMF file
  • field_name_list - array of length nfields containing the textual name of fields to write

Level: beginner

-seealso: DM, DMSWARM, DMSwarmViewXDMF()

External Links

source
PETSc.LibPETSc.DMSwarmViewXDMFMethod
DMSwarmViewXDMF(petsclib::PetscLibType,dm::PetscDM, filename::String)

Write DMSWARM fields to an XDMF3 file

Collective

Input Parameters:

  • dm - the DMSWARM
  • filename - the file name of the XDMF file (must have the extension .xmf)

Level: beginner

-seealso: DM, DMSWARM, DMSwarmViewFieldsXDMF()

External Links

source