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.DMSwarmAddCellDM — Method
DMSwarmAddCellDM(petsclib::PetscLibType,sw::PetscDM, celldm::DMSwarmCellDM)Adds a cell DM to the DMSWARM
Collective
Input Parameters:
sw- aDMSWARMcelldm- theDMSwarmCellDM
Level: beginner
-seealso: DM, DMSWARM, DMSwarmSetType(), DMSwarmPushCellDM(), DMSwarmSetCellDM(), DMSwarmMigrate()
External Links
- PETSc Manual:
DMSwarm/DMSwarmAddCellDM
PETSc.LibPETSc.DMSwarmAddNPoints — Method
DMSwarmAddNPoints(petsclib::PetscLibType,dm::PetscDM, npoints::PetscInt)Add space for a number of new points in the DMSWARM
Not Collective
Input Parameters:
dm- aDMSWARMnpoints- the number of new points to add
Level: beginner
-seealso: DM, DMSWARM, DMSwarmAddPoint()
External Links
- PETSc Manual:
DMSwarm/DMSwarmAddNPoints
PETSc.LibPETSc.DMSwarmAddPoint — Method
DMSwarmAddPoint(petsclib::PetscLibType,dm::PetscDM)Add space for one new point in the DMSWARM
Not Collective
Input Parameter:
dm- aDMSWARM
Level: beginner
-seealso: DM, DMSWARM, DMSwarmAddNPoints()
External Links
- PETSc Manual:
DMSwarm/DMSwarmAddPoint
PETSc.LibPETSc.DMSwarmCollectViewCreate — Method
DMSwarmCollectViewCreate(petsclib::PetscLibType,dm::PetscDM)Applies a collection method and gathers points in neighbour ranks into the DMSWARM
Collective
Input Parameter:
dm- theDMSWARM
Level: advanced
-seealso: DM, DMSWARM, DMSwarmCollectViewDestroy(), DMSwarmSetCollectType()
External Links
- PETSc Manual:
DMSwarm/DMSwarmCollectViewCreate
PETSc.LibPETSc.DMSwarmCollectViewDestroy — Method
DMSwarmCollectViewDestroy(petsclib::PetscLibType,dm::PetscDM)Resets the DMSWARM to the size prior to calling DMSwarmCollectViewCreate()
Collective
Input Parameters:
dm- theDMSWARM
-seealso: DM, DMSWARM, DMSwarmCollectViewCreate(), DMSwarmSetCollectType()
External Links
- PETSc Manual:
DMSwarm/DMSwarmCollectViewDestroy
PETSc.LibPETSc.DMSwarmComputeLocalSize — Method
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- TheDMSWARMN- The target number of particlesdensity- The density field for the particle layout, normalized to unity
Level: advanced
-seealso: DMSWARM, DMSwarmComputeLocalSizeFromOptions()
External Links
- PETSc Manual:
DMSwarm/DMSwarmComputeLocalSize
PETSc.LibPETSc.DMSwarmComputeLocalSizeFromOptions — Method
DMSwarmComputeLocalSizeFromOptions(petsclib::PetscLibType,sw::PetscDM)Compute the local number and distribution of particles based upon a density function determined by options
Not Collective
Input Parameter:
sw- TheDMSWARM
Level: advanced
-seealso: DMSWARM, DMSwarmComputeLocalSize()
External Links
- PETSc Manual:
DMSwarm/DMSwarmComputeLocalSizeFromOptions
PETSc.LibPETSc.DMSwarmComputeMoments — Method
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- theDMSWARMcoordinate- the coordinate field nameweight- the weight field name
Output Parameter:
moments- the field moments
Level: intermediate
-seealso: DM, DMSWARM, DMPlexComputeMoments()
External Links
- PETSc Manual:
DMSwarm/DMSwarmComputeMoments
PETSc.LibPETSc.DMSwarmCopyPoint — Method
DMSwarmCopyPoint(petsclib::PetscLibType,dm::PetscDM, pi::PetscInt, pj::PetscInt)Copy point pj to point pi in the DMSWARM
Not Collective
Input Parameters:
dm- aDMSWARMpi- the index of the point to copypj- the point index where the copy should be located
Level: beginner
-seealso: DM, DMSWARM, DMSwarmRemovePoint()
External Links
- PETSc Manual:
DMSwarm/DMSwarmCopyPoint
PETSc.LibPETSc.DMSwarmCreateGlobalVectorFromField — Method
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- aDMSWARMfieldname- the textual name given to a registered field
Output Parameter:
vec- the vector
Level: beginner
-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmDestroyGlobalVectorFromField()
External Links
- PETSc Manual:
DMSwarm/DMSwarmCreateGlobalVectorFromField
PETSc.LibPETSc.DMSwarmCreateGlobalVectorFromFields — Method
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- aDMSWARMNf- the number of fieldsfieldnames- the textual names given to the registered fields
Output Parameter:
vec- the vector
Level: beginner
-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmDestroyGlobalVectorFromFields()
External Links
- PETSc Manual:
DMSwarm/DMSwarmCreateGlobalVectorFromFields
PETSc.LibPETSc.DMSwarmCreateLocalVectorFromField — Method
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- aDMSWARMfieldname- the textual name given to a registered field
Output Parameter:
vec- the vector
Level: beginner
-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmDestroyLocalVectorFromField()
External Links
- PETSc Manual:
DMSwarm/DMSwarmCreateLocalVectorFromField
PETSc.LibPETSc.DMSwarmCreateLocalVectorFromFields — Method
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- aDMSWARMNf- the number of fieldsfieldnames- the textual names given to the registered fields
Output Parameter:
vec- the vector
Level: beginner
-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmDestroyLocalVectorFromField()
External Links
- PETSc Manual:
DMSwarm/DMSwarmCreateLocalVectorFromFields
PETSc.LibPETSc.DMSwarmCreateMassMatrixSquare — Method
mass::PetscMat = DMSwarmCreateMassMatrixSquare(petsclib::PetscLibType,dmCoarse::PetscDM, dmFine::PetscDM)Creates the block
Collective
Input Parameters:
dmCoarse- aDMSWARMdmFine- aDMPLEX
Output Parameter:
mass- the square of the particle mass matrix
Level: advanced
-seealso: DM, DMSWARM, DMCreateMassMatrix()
External Links
- PETSc Manual:
DMSwarm/DMSwarmCreateMassMatrixSquare
PETSc.LibPETSc.DMSwarmCreatePointPerCellCount — Method
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- theDMSWARM
Output Parameters:
ncells- the number of cells in the cellDM(optional argument, passNULLto ignore)count- array of length ncells containing the number of points per cell
Level: beginner
-seealso: DMSWARM, DMSwarmSetType(), DMSwarmSetCellDM(), DMSwarmType
External Links
- PETSc Manual:
DMSwarm/DMSwarmCreatePointPerCellCount
PETSc.LibPETSc.DMSwarmDestroyGlobalVectorFromField — Method
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- aDMSWARMfieldname- the textual name given to a registered field
Output Parameter:
vec- the vector
Level: beginner
-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmCreateGlobalVectorFromField()
External Links
- PETSc Manual:
DMSwarm/DMSwarmDestroyGlobalVectorFromField
PETSc.LibPETSc.DMSwarmDestroyGlobalVectorFromFields — Method
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- aDMSWARMNf- the number of fieldsfieldnames- the textual names given to the registered fields
Output Parameter:
vec- the vector
Level: beginner
-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmCreateGlobalVectorFromField()
External Links
- PETSc Manual:
DMSwarm/DMSwarmDestroyGlobalVectorFromFields
PETSc.LibPETSc.DMSwarmDestroyLocalVectorFromField — Method
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- aDMSWARMfieldname- the textual name given to a registered field
Output Parameter:
vec- the vector
Level: beginner
-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmCreateLocalVectorFromField()
External Links
- PETSc Manual:
DMSwarm/DMSwarmDestroyLocalVectorFromField
PETSc.LibPETSc.DMSwarmDestroyLocalVectorFromFields — Method
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- aDMSWARMNf- the number of fieldsfieldnames- the textual names given to the registered fields
Output Parameter:
vec- the vector
Level: beginner
-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmCreateLocalVectorFromFields()
External Links
- PETSc Manual:
DMSwarm/DMSwarmDestroyLocalVectorFromFields
PETSc.LibPETSc.DMSwarmDuplicate — Method
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- theDMSWARM
Output Parameter:
nsw- the newDMSWARM
Level: beginner
-seealso: DM, DMSWARM, DMSwarmCreate(), DMClone()
External Links
- PETSc Manual:
DMSwarm/DMSwarmDuplicate
PETSc.LibPETSc.DMSwarmFinalizeFieldRegister — Method
DMSwarmFinalizeFieldRegister(petsclib::PetscLibType,dm::PetscDM)Finalizes the registration of fields to a DMSWARM
Collective
Input Parameter:
dm- aDMSWARM
Level: beginner
-seealso: DM, DMSWARM, DMSwarmInitializeFieldRegister(), DMSwarmRegisterPetscDatatypeField(), DMSwarmRegisterUserStructField(), DMSwarmRegisterUserDatatypeField()
External Links
- PETSc Manual:
DMSwarm/DMSwarmFinalizeFieldRegister
PETSc.LibPETSc.DMSwarmGetCellDM — Method
DMSwarmGetCellDM(petsclib::PetscLibType,sw::PetscDM, dm::PetscDM)Fetches the active cell DM
Collective
Input Parameter:
sw- aDMSWARM
Output Parameter:
dm- the activeDMfor theDMSWARM
Level: beginner
-seealso: DM, DMSWARM, DMSwarmSetCellDM()
External Links
- PETSc Manual:
DMSwarm/DMSwarmGetCellDM
PETSc.LibPETSc.DMSwarmGetCellDMActive — Method
DMSwarmGetCellDMActive(petsclib::PetscLibType,sw::PetscDM, celldm::DMSwarmCellDM)Returns the active cell DM for a DMSWARM
Collective
Input Parameter:
sw- aDMSWARM
Output Parameter:
celldm- the activeDMSwarmCellDM
Level: beginner
-seealso: DM, DMSWARM, DMSwarmCellDM, DMSwarmSetType(), DMSwarmAddCellDM(), DMSwarmSetCellDM(), DMSwarmMigrate()
External Links
- PETSc Manual:
DMSwarm/DMSwarmGetCellDMActive
PETSc.LibPETSc.DMSwarmGetCellDMByName — Method
DMSwarmGetCellDMByName(petsclib::PetscLibType,sw::PetscDM, name::String, celldm::DMSwarmCellDM)Get a DMSwarmCellDM from its name
Not collective
Input Parameters:
sw- aDMSWARMname- the name
Output Parameter:
celldm- theDMSwarmCellDM
Level: beginner
-seealso: DM, DMSWARM, DMSwarmSetCellDM(), DMSwarmGetCellDMNames()
External Links
- PETSc Manual:
DMSwarm/DMSwarmGetCellDMByName
PETSc.LibPETSc.DMSwarmGetCellDMNames — Method
Ndm::PetscInt = DMSwarmGetCellDMNames(petsclib::PetscLibType,sw::PetscDM, celldms::String)Get the list of cell DM names
Not collective
Input Parameter:
sw- aDMSWARM
Output Parameters:
Ndm- the number ofDMSwarmCellDMin theDMSWARMcelldms- the name of eachDMSwarmCellDM
Level: beginner
-seealso: DM, DMSWARM, DMSwarmSetCellDM(), DMSwarmGetCellDMByName()
External Links
- PETSc Manual:
DMSwarm/DMSwarmGetCellDMNames
PETSc.LibPETSc.DMSwarmGetCellSwarm — Method
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- theDMSWARMcellID- the integer id of the cell to be extracted and filteredcellswarm- TheDMSWARMto receive the cell
Level: beginner
-seealso: DM, DMSWARM, DMSwarmRestoreCellSwarm()
External Links
- PETSc Manual:
DMSwarm/DMSwarmGetCellSwarm
PETSc.LibPETSc.DMSwarmGetCoordinateFunction — Method
DMSwarmGetCoordinateFunction(petsclib::PetscLibType,sw::PetscDM, coordFunc::PetscSimplePoCintFn)Get the function setting initial particle positions, if it exists
Not Collective
Input Parameter:
sw- theDMSWARM
Output Parameter:
coordFunc- the function setting initial particle positions, orNULL, seePetscSimplePointFnfor the calling sequence
Level: intermediate
-seealso: DMSWARM, DMSwarmSetCoordinateFunction(), DMSwarmGetVelocityFunction(), DMSwarmInitializeCoordinates(), PetscSimplePointFn
External Links
- PETSc Manual:
DMSwarm/DMSwarmGetCoordinateFunction
PETSc.LibPETSc.DMSwarmGetField — Method
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- aDMSWARMfieldname- the textual name to identify this field
Output Parameters:
blocksize- the number of each data typetype- the data typedata- pointer to raw array
Level: beginner
-seealso: DM, DMSWARM, DMSwarmRestoreField()
External Links
- PETSc Manual:
DMSwarm/DMSwarmGetField
PETSc.LibPETSc.DMSwarmGetFieldInfo — Method
blocksize::PetscInt = DMSwarmGetFieldInfo(petsclib::PetscLibType,dm::PetscDM, fieldname::String, type::PetscDataType)External Links
- PETSc Manual:
DMSwarm/DMSwarmGetFieldInfo
PETSc.LibPETSc.DMSwarmGetLocalSize — Method
nloc::PetscInt = DMSwarmGetLocalSize(petsclib::PetscLibType,dm::PetscDM)Retrieves the local length of fields registered
Not Collective
Input Parameter:
dm- aDMSWARM
Output Parameter:
nlocal- the length of each registered field
Level: beginner
-seealso: DM, DMSWARM, DMSwarmGetSize(), DMSwarmSetLocalSizes()
External Links
- PETSc Manual:
DMSwarm/DMSwarmGetLocalSize
PETSc.LibPETSc.DMSwarmGetMigrateType — Method
mtype::DMSwarmMigrateType = DMSwarmGetMigrateType(petsclib::PetscLibType,dm::PetscDM)Get the style of point migration
Logically Collective
Input Parameter:
dm- theDMSWARM
Output Parameter:
mtype- The migration type, seeDMSwarmMigrateType
Level: intermediate
-seealso: DM, DMSWARM, DMSwarmMigrateType, DMSwarmMigrate()
External Links
- PETSc Manual:
DMSwarm/DMSwarmGetMigrateType
PETSc.LibPETSc.DMSwarmGetNumSpecies — Method
Ns::PetscInt = DMSwarmGetNumSpecies(petsclib::PetscLibType,sw::PetscDM)Get the number of particle species
Not Collective
Input Parameter:
sw- theDMSWARM
Output Parameters:
Ns- the number of species
Level: intermediate
-seealso: DMSWARM, DMSwarmSetNumSpecies(), DMSwarmSetType(), DMSwarmType
External Links
- PETSc Manual:
DMSwarm/DMSwarmGetNumSpecies
PETSc.LibPETSc.DMSwarmGetSize — Method
n::PetscInt = DMSwarmGetSize(petsclib::PetscLibType,dm::PetscDM)Retrieves the total length of fields registered
Collective
Input Parameter:
dm- aDMSWARM
Output Parameter:
n- the total length of each registered field
Level: beginner
-seealso: DM, DMSWARM, DMSwarmGetLocalSize(), DMSwarmSetLocalSizes()
External Links
- PETSc Manual:
DMSwarm/DMSwarmGetSize
PETSc.LibPETSc.DMSwarmGetType — Method
stype::DMSwarmType = DMSwarmGetType(petsclib::PetscLibType,sw::PetscDM)Get particular flavor of DMSWARM
Collective
Input Parameter:
sw- theDMSWARM
Output Parameter:
stype- theDMSWARMtype (e.g.DMSWARM_PIC)
Level: advanced
-seealso: DM, DMSWARM, DMSwarmSetMigrateType(), DMSwarmSetCollectType(), DMSwarmType, DMSWARM_PIC, DMSWARM_BASIC
External Links
- PETSc Manual:
DMSwarm/DMSwarmGetType
PETSc.LibPETSc.DMSwarmGetVelocityFunction — Method
DMSwarmGetVelocityFunction(petsclib::PetscLibType,sw::PetscDM, velFunc::PetscSimplePoCintFn)Get the function setting initial particle velocities, if it exists
Not Collective
Input Parameter:
sw- theDMSWARM
Output Parameter:
velFunc- the function setting initial particle velocities, orNULL, seePetscSimplePointFnfor the calling sequence
Level: intermediate
-seealso: DMSWARM, DMSwarmSetVelocityFunction(), DMSwarmGetCoordinateFunction(), DMSwarmInitializeVelocities(), PetscSimplePointFn
External Links
- PETSc Manual:
DMSwarm/DMSwarmGetVelocityFunction
PETSc.LibPETSc.DMSwarmInitializeCoordinates — Method
DMSwarmInitializeCoordinates(petsclib::PetscLibType,sw::PetscDM)Determine the initial coordinates of particles for a PIC method
Not Collective
Input Parameter:
sw- TheDMSWARM
Level: advanced
-seealso: DMSWARM, DMSwarmComputeLocalSize(), DMSwarmInitializeVelocities()
External Links
- PETSc Manual:
DMSwarm/DMSwarmInitializeCoordinates
PETSc.LibPETSc.DMSwarmInitializeFieldRegister — Method
DMSwarmInitializeFieldRegister(petsclib::PetscLibType,dm::PetscDM)Initiates the registration of fields to a DMSWARM
Collective
Input Parameter:
dm- aDMSWARM
Level: beginner
-seealso: DM, DMSWARM, DMSwarmFinalizeFieldRegister(), DMSwarmRegisterPetscDatatypeField(), DMSwarmRegisterUserStructField(), DMSwarmRegisterUserDatatypeField()
External Links
- PETSc Manual:
DMSwarm/DMSwarmInitializeFieldRegister
PETSc.LibPETSc.DMSwarmInitializeVelocities — Method
DMSwarmInitializeVelocities(petsclib::PetscLibType,sw::PetscDM, sampler::PetscProbFn, v0::Vector{PetscReal})Set the initial velocities of particles using a distribution.
Collective
Input Parameters:
sw- TheDMSWARMobjectsampler- A function which uniformly samples the velocity PDFv0- The velocity scale for nondimensionalization for each species
Level: advanced
-seealso: DMSWARM, DMSwarmComputeLocalSize(), DMSwarmInitializeCoordinates(), DMSwarmInitializeVelocitiesFromOptions()
External Links
- PETSc Manual:
DMSwarm/DMSwarmInitializeVelocities
PETSc.LibPETSc.DMSwarmInitializeVelocitiesFromOptions — Method
DMSwarmInitializeVelocitiesFromOptions(petsclib::PetscLibType,sw::PetscDM, v0::Vector{PetscReal})Set the initial velocities of particles using a distribution determined from options.
Collective
Input Parameters:
sw- TheDMSWARMobjectv0- The velocity scale for nondimensionalization for each species
Level: advanced
-seealso: DMSWARM, DMSwarmComputeLocalSize(), DMSwarmInitializeCoordinates(), DMSwarmInitializeVelocities()
External Links
- PETSc Manual:
DMSwarm/DMSwarmInitializeVelocitiesFromOptions
PETSc.LibPETSc.DMSwarmInsertPointsUsingCellDM — Method
DMSwarmInsertPointsUsingCellDM(petsclib::PetscLibType,dm::PetscDM, layout_type::DMSwarmPICLayoutType, fill_param::PetscInt)Insert point coordinates within each cell
Not Collective
Input Parameters:
dm- theDMSWARMlayout_type- method used to fill each cell with the cellDMfill_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
- PETSc Manual:
DMSwarm/DMSwarmInsertPointsUsingCellDM
PETSc.LibPETSc.DMSwarmMigrate — Method
DMSwarmMigrate(petsclib::PetscLibType,dm::PetscDM, remove_sent_points::PetscBool)Relocates points defined in the DMSWARM to other MPI
Collective
Input Parameters:
dm- theDMSWARMremove_sent_points- flag indicating if sent points should be removed from the current MPI-rank
Level: advanced
-seealso: DM, DMSWARM, DMSwarmSetMigrateType()
External Links
- PETSc Manual:
DMSwarm/DMSwarmMigrate
PETSc.LibPETSc.DMSwarmProjectFields — Method
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- theDMSWARMdm- theDM, orNULLto use the cellDMnfields- the number of swarm fields to projectfieldnames- the textual names of the swarm fields to projectfields- an array ofVec's of length nfieldsmode- ifSCATTER_FORWARDthen map particles to the continuum, and ifSCATTER_REVERSEmap the continuum to particles
Level: beginner
See also:
DMSWARM, DMSwarmSetType(), DMSwarmSetCellDM(), DMSwarmType
External Links
- PETSc Manual:
DMSwarm/DMSwarmProjectFields
PETSc.LibPETSc.DMSwarmProjectGradientFields — Method
DMSwarmProjectGradientFields(petsclib::PetscLibType,sw::PetscDM, dm::PetscDM, nfields::PetscInt, fieldnames::String, fields::Vector{PetscVec}, mode::ScatterMode)External Links
- PETSc Manual:
DMSwarm/DMSwarmProjectGradientFields
PETSc.LibPETSc.DMSwarmRegisterPetscDatatypeField — Method
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- aDMSWARMfieldname- the textual name to identify this fieldblocksize- the number of each data typetype- 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
- PETSc Manual:
DMSwarm/DMSwarmRegisterPetscDatatypeField
PETSc.LibPETSc.DMSwarmRegisterUserDatatypeField — Method
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- aDMSWARMfieldname- the textual name to identify this fieldsize- the size in bytes of the user data typeblocksize- the number of each data type
Level: beginner
-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmRegisterUserStructField()
External Links
- PETSc Manual:
DMSwarm/DMSwarmRegisterUserDatatypeField
PETSc.LibPETSc.DMSwarmRegisterUserStructField — Method
DMSwarmRegisterUserStructField(petsclib::PetscLibType,dm::PetscDM, fieldname::String, size::Csize_t)Register a user defined struct to a DMSWARM
Collective
Input Parameters:
dm- aDMSWARMfieldname- the textual name to identify this fieldsize- the size in bytes of the user struct of each data type
Level: beginner
-seealso: DM, DMSWARM, DMSwarmRegisterPetscDatatypeField(), DMSwarmRegisterUserDatatypeField()
External Links
- PETSc Manual:
DMSwarm/DMSwarmRegisterUserStructField
PETSc.LibPETSc.DMSwarmRemap — Method
DMSwarmRemap(petsclib::PetscLibType,sw::PetscDM)Project the swarm fields onto a new set of particles
Collective
Input Parameter:
sw- TheDMSWARMobject
Level: beginner
See also:
DMSWARM, DMSwarmMigrate(), DMSwarmCrate()
External Links
- PETSc Manual:
DMSwarm/DMSwarmRemap
PETSc.LibPETSc.DMSwarmRemovePoint — Method
DMSwarmRemovePoint(petsclib::PetscLibType,dm::PetscDM)Remove the last point from the DMSWARM
Not Collective
Input Parameter:
dm- aDMSWARM
Level: beginner
-seealso: DM, DMSWARM, DMSwarmRemovePointAtIndex()
External Links
- PETSc Manual:
DMSwarm/DMSwarmRemovePoint
PETSc.LibPETSc.DMSwarmRemovePointAtIndex — Method
DMSwarmRemovePointAtIndex(petsclib::PetscLibType,dm::PetscDM, idx::PetscInt)Removes a specific point from the DMSWARM
Not Collective
Input Parameters:
dm- aDMSWARMidx- index of point to remove
Level: beginner
-seealso: DM, DMSWARM, DMSwarmRemovePoint()
External Links
- PETSc Manual:
DMSwarm/DMSwarmRemovePointAtIndex
PETSc.LibPETSc.DMSwarmReplace — Method
DMSwarmReplace(petsclib::PetscLibType,dm::PetscDM, ndm::PetscDM)External Links
- PETSc Manual:
DMSwarm/DMSwarmReplace
PETSc.LibPETSc.DMSwarmRestoreCellSwarm — Method
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 parentDMSWARMcellID- the integer id of the cell to be copied back into the parent swarmcellswarm- the cell swarm object
Level: beginner
-seealso: DM, DMSWARM, DMSwarmGetCellSwarm()
External Links
- PETSc Manual:
DMSwarm/DMSwarmRestoreCellSwarm
PETSc.LibPETSc.DMSwarmRestoreField — Method
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- aDMSWARMfieldname- the textual name to identify this field
Output Parameters:
blocksize- the number of each data typetype- the data typedata- pointer to raw array
Level: beginner
-seealso: DM, DMSWARM, DMSwarmGetField()
External Links
- PETSc Manual:
DMSwarm/DMSwarmRestoreField
PETSc.LibPETSc.DMSwarmSetCellDM — Method
DMSwarmSetCellDM(petsclib::PetscLibType,sw::PetscDM, dm::PetscDM)Attaches a DM to a DMSWARM
Collective
Input Parameters:
sw- aDMSWARMdm- theDMto attach to theDMSWARM
Level: beginner
-seealso: DM, DMSWARM, DMSwarmSetType(), DMSwarmGetCellDM(), DMSwarmMigrate()
External Links
- PETSc Manual:
DMSwarm/DMSwarmSetCellDM
PETSc.LibPETSc.DMSwarmSetCellDMActive — Method
DMSwarmSetCellDMActive(petsclib::PetscLibType,sw::PetscDM, name::String)Activates a cell DM for a DMSWARM
Collective
Input Parameters:
sw- aDMSWARMname- name of the cellDMto active for theDMSWARM
Level: beginner
-seealso: DM, DMSWARM, DMSwarmCellDM, DMSwarmSetType(), DMSwarmAddCellDM(), DMSwarmSetCellDM(), DMSwarmMigrate()
External Links
- PETSc Manual:
DMSwarm/DMSwarmSetCellDMActive
PETSc.LibPETSc.DMSwarmSetCoordinateFunction — Method
DMSwarmSetCoordinateFunction(petsclib::PetscLibType,sw::PetscDM, coordFunc::PetscSimplePoCintFn)Set the function setting initial particle positions
Not Collective
Input Parameters:
sw- theDMSWARMcoordFunc- the function setting initial particle positions, seePetscSimplePointFnfor the calling sequence
Level: intermediate
-seealso: DMSWARM, DMSwarmGetCoordinateFunction(), DMSwarmSetVelocityFunction(), DMSwarmInitializeCoordinates(), PetscSimplePointFn
External Links
- PETSc Manual:
DMSwarm/DMSwarmSetCoordinateFunction
PETSc.LibPETSc.DMSwarmSetLocalSizes — Method
DMSwarmSetLocalSizes(petsclib::PetscLibType,sw::PetscDM, nloc::PetscInt, buffer::PetscInt)Sets the length of all registered fields on the DMSWARM
Not Collective
Input Parameters:
sw- aDMSWARMnlocal- the length of each registered fieldbuffer- the length of the buffer used to efficient dynamic re-sizing
Level: beginner
-seealso: DM, DMSWARM, DMSwarmGetLocalSize()
External Links
- PETSc Manual:
DMSwarm/DMSwarmSetLocalSizes
PETSc.LibPETSc.DMSwarmSetMigrateType — Method
DMSwarmSetMigrateType(petsclib::PetscLibType,dm::PetscDM, mtype::DMSwarmMigrateType)Set the style of point migration
Logically Collective
Input Parameters:
dm- theDMSWARMmtype- The migration type, seeDMSwarmMigrateType
Level: intermediate
-seealso: DM, DMSWARM, DMSwarmMigrateType, DMSwarmGetMigrateType(), DMSwarmMigrate()
External Links
- PETSc Manual:
DMSwarm/DMSwarmSetMigrateType
PETSc.LibPETSc.DMSwarmSetNumSpecies — Method
DMSwarmSetNumSpecies(petsclib::PetscLibType,sw::PetscDM, Ns::PetscInt)Set the number of particle species
Not Collective
Input Parameters:
sw- theDMSWARMNs- the number of species
Level: intermediate
-seealso: DMSWARM, DMSwarmGetNumSpecies(), DMSwarmSetType(), DMSwarmType
External Links
- PETSc Manual:
DMSwarm/DMSwarmSetNumSpecies
PETSc.LibPETSc.DMSwarmSetPointCoordinates — Method
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- theDMSWARMnpoints- the number of points to insertcoor- the coordinate valuesredundant- if set toPETSC_TRUE, it is assumed thatnpointsandcoorare only valid on rank 0 and should be broadcast to other ranksmode- 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
- PETSc Manual:
DMSwarm/DMSwarmSetPointCoordinates
PETSc.LibPETSc.DMSwarmSetPointCoordinatesCellwise — Method
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- theDMSWARMnpoints- the number of points to insert in each cellxi- the coordinates (defined in the local coordinate system for each cell) to insert
Level: beginner
-seealso: DMSWARM, DMSwarmSetCellDM(), DMSwarmInsertPointsUsingCellDM()
External Links
- PETSc Manual:
DMSwarm/DMSwarmSetPointCoordinatesCellwise
PETSc.LibPETSc.DMSwarmSetPointCoordinatesRandom — Method
DMSwarmSetPointCoordinatesRandom(petsclib::PetscLibType,dm::PetscDM, Npc::PetscInt)Sets initial coordinates for particles in each cell
Collective
Input Parameters:
dm- theDMSWARMNpc- The number of particles per cell in the cellDM
Level: intermediate
-seealso: DM, DMSWARM, DMSwarmSetCellDM()
External Links
- PETSc Manual:
DMSwarm/DMSwarmSetPointCoordinatesRandom
PETSc.LibPETSc.DMSwarmSetPointsUniformCoordinates — Method
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- theDMSWARMmin- 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
- PETSc Manual:
DMSwarm/DMSwarmSetPointsUniformCoordinates
PETSc.LibPETSc.DMSwarmSetType — Method
DMSwarmSetType(petsclib::PetscLibType,sw::PetscDM, stype::DMSwarmType)Set particular flavor of DMSWARM
Collective
Input Parameters:
sw- theDMSWARMstype- theDMSWARMtype (e.g.DMSWARM_PIC)
Level: advanced
-seealso: DM, DMSWARM, DMSwarmSetMigrateType(), DMSwarmSetCollectType(), DMSwarmType, DMSWARM_PIC, DMSWARM_BASIC
External Links
- PETSc Manual:
DMSwarm/DMSwarmSetType
PETSc.LibPETSc.DMSwarmSetVelocityFunction — Method
DMSwarmSetVelocityFunction(petsclib::PetscLibType,sw::PetscDM, velFunc::PetscSimplePoCintFn)Set the function setting initial particle velocities
Not Collective
Input Parameters:
sw- theDMSWARMvelFunc- the function setting initial particle velocities, seePetscSimplePointFnfor the calling sequence
Level: intermediate
-seealso: DMSWARM, DMSwarmGetVelocityFunction(), DMSwarmSetCoordinateFunction(), DMSwarmInitializeVelocities(), PetscSimplePointFn
External Links
- PETSc Manual:
DMSwarm/DMSwarmSetVelocityFunction
PETSc.LibPETSc.DMSwarmVectorDefineField — Method
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- aDMSWARMfieldname- the textual name given to each registered field
Level: beginner
-seealso: DM, DMSWARM, DMSwarmVectorDefineFields(), DMSwarmVectorGetField(), DMSwarmRegisterPetscDatatypeField(), DMCreateGlobalVector(), DMCreateLocalVector()
External Links
- PETSc Manual:
DMSwarm/DMSwarmVectorDefineField
PETSc.LibPETSc.DMSwarmVectorDefineFields — Method
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- aDMSWARMNf- the number of fieldsfieldnames- the textual name given to each registered field
Level: beginner
-seealso: DM, DMSWARM, DMSwarmVectorDefineField(), DMSwarmVectorGetField(), DMSwarmRegisterPetscDatatypeField(), DMCreateGlobalVector(), DMCreateLocalVector()
External Links
- PETSc Manual:
DMSwarm/DMSwarmVectorDefineFields
PETSc.LibPETSc.DMSwarmVectorGetField — Method
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- aDMSWARM
Output Parameters:
Nf- the number of fieldsfieldnames- 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
- PETSc Manual:
DMSwarm/DMSwarmVectorGetField
PETSc.LibPETSc.DMSwarmViewFieldsXDMF — Method
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- theDMSWARMfilename- the file name of the XDMF file (must have the extension .xmf)nfields- the number of fields to write into the XDMF filefield_name_list- array of length nfields containing the textual name of fields to write
Level: beginner
-seealso: DM, DMSWARM, DMSwarmViewXDMF()
External Links
- PETSc Manual:
DMSwarm/DMSwarmViewFieldsXDMF
PETSc.LibPETSc.DMSwarmViewXDMF — Method
DMSwarmViewXDMF(petsclib::PetscLibType,dm::PetscDM, filename::String)Write DMSWARM fields to an XDMF3 file
Collective
Input Parameters:
dm- theDMSWARMfilename- the file name of the XDMF file (must have the extension .xmf)
Level: beginner
-seealso: DM, DMSWARM, DMSwarmViewFieldsXDMF()
External Links
- PETSc Manual:
DMSwarm/DMSwarmViewXDMF