126bd1501SBarry Smith #if !defined(PETSCDMSWARM_H) 226bd1501SBarry Smith #define PETSCDMSWARM_H 33d5c7219SDave May 43d5c7219SDave May #include <petscdm.h> 53d5c7219SDave May 6e7af74c8SDave May /*E 7e7af74c8SDave May DMSwarmType - Defines the type of swarm 8e7af74c8SDave May 9e7af74c8SDave May DMSWARM_BASIC defines N entries of varied data-types which the user may register. 10e7af74c8SDave May 11e7af74c8SDave May DMSWARM_PIC is suitable for particle-in-cell methods. Configured as DMSWARM_PIC, the swarm will be aware of, another DM which serves as the background mesh. Fields specific to particle-in-cell methods are registered by default. These include spatial coordinates, a unique identifier, a cell index and an index for the owning rank. The background mesh will (by default) define the spatial decomposition of the points defined in the swarm. DMSWARM_PIC provides support for particle-in-cell operations such as defining initial point coordinates, communicating particles between sub-domains, projecting particle data fields on to the mesh. 12e7af74c8SDave May 13e7af74c8SDave May Level: beginner 14e7af74c8SDave May 15e7af74c8SDave May .seealso: DMSwarmSetType() 16e7af74c8SDave May E*/ 17480eef7bSDave May typedef enum { 18480eef7bSDave May DMSWARM_BASIC=0, 19480eef7bSDave May DMSWARM_PIC 20480eef7bSDave May } DMSwarmType; 21480eef7bSDave May 22480eef7bSDave May typedef enum { 23480eef7bSDave May DMSWARM_MIGRATE_BASIC=0, 24853ec3c6SDave May DMSWARM_MIGRATE_DMCELLNSCATTER, 25853ec3c6SDave May DMSWARM_MIGRATE_DMCELLEXACT, 26853ec3c6SDave May DMSWARM_MIGRATE_USER 27480eef7bSDave May } DMSwarmMigrateType; 28480eef7bSDave May 29480eef7bSDave May typedef enum { 30480eef7bSDave May DMSWARM_COLLECT_BASIC=0, 31480eef7bSDave May DMSWARM_COLLECT_DMDABOUNDINGBOX, 32853ec3c6SDave May DMSWARM_COLLECT_GENERAL, 33853ec3c6SDave May DMSWARM_COLLECT_USER 34480eef7bSDave May } DMSwarmCollectType; 35480eef7bSDave May 36e7af74c8SDave May /*E 370e2ec84fSDave May DMSwarmPICLayoutType - Defines the method used to define particle coordinates within each cell. The layouts are constructured using the reference cell geometry 380e2ec84fSDave May 390e2ec84fSDave May DMSWARMPIC_LAYOUT_REGULAR defines points on a regular ijk mesh. 400e2ec84fSDave May When using DMSWARMPIC_LAYOUT_REGULAR, the fill_param defines the number of points in each spatial direction. 410e2ec84fSDave May 420e2ec84fSDave May DMSWARMPIC_LAYOUT_GAUSS defines points using an npoint Gauss-Legendre tensor product quadrature rule. 430e2ec84fSDave May When using DMSWARMPIC_LAYOUT_GAUSS, the fill_param defines the number of quadrature points in each spatial direction. 440e2ec84fSDave May 450e2ec84fSDave May DMSWARMPIC_LAYOUT_SUBDIVISION defines points on the centroid of a sub-divided reference cell. 460e2ec84fSDave May When using DMSWARMPIC_LAYOUT_SUBDIVISION, the fill_param defines the number times the reference cell is sub-divided. 470e2ec84fSDave May 480e2ec84fSDave May Level: beginner 490e2ec84fSDave May 500e2ec84fSDave May .seealso DMSwarmInsertPointsUsingCellDM() 51e7af74c8SDave May E*/ 52e2d107dbSDave May typedef enum { 53e2d107dbSDave May DMSWARMPIC_LAYOUT_REGULAR=0, 54e2d107dbSDave May DMSWARMPIC_LAYOUT_GAUSS, 55e0e61dcbSKarl Rupp DMSWARMPIC_LAYOUT_SUBDIVISION 56e2d107dbSDave May } DMSwarmPICLayoutType; 57e2d107dbSDave May 58853ec3c6SDave May PETSC_EXTERN const char* DMSwarmTypeNames[]; 59853ec3c6SDave May PETSC_EXTERN const char* DMSwarmMigrateTypeNames[]; 60853ec3c6SDave May PETSC_EXTERN const char* DMSwarmCollectTypeNames[]; 61853ec3c6SDave May 62853ec3c6SDave May PETSC_EXTERN const char DMSwarmField_pid[]; 63853ec3c6SDave May PETSC_EXTERN const char DMSwarmField_rank[]; 64853ec3c6SDave May PETSC_EXTERN const char DMSwarmPICField_coor[]; 65e2d107dbSDave May PETSC_EXTERN const char DMSwarmPICField_cellid[]; 66853ec3c6SDave May 67934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmCreateGlobalVectorFromField(DM,const char[],Vec*); 68934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmDestroyGlobalVectorFromField(DM,const char[],Vec*); 69fb1bcc12SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmCreateLocalVectorFromField(DM,const char[],Vec*); 70fb1bcc12SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmDestroyLocalVectorFromField(DM,const char[],Vec*); 71853ec3c6SDave May 72934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmInitializeFieldRegister(DM); 73934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmFinalizeFieldRegister(DM); 74934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmSetLocalSizes(DM,PetscInt,PetscInt); 75934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmRegisterPetscDatatypeField(DM,const char[],PetscInt,PetscDataType); 76934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmRegisterUserStructField(DM,const char[],size_t); 77934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmRegisterUserDatatypeField(DM,const char[],size_t,PetscInt); 78934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmGetField(DM,const char[],PetscInt*,PetscDataType*,void**); 79934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmRestoreField(DM,const char[],PetscInt*,PetscDataType*,void**); 80934315b8SMatthew G. Knepley 81934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmVectorDefineField(DM,const char[]); 82934315b8SMatthew G. Knepley 83934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmAddPoint(DM); 84934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmAddNPoints(DM,PetscInt); 85934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmRemovePoint(DM); 86934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmRemovePointAtIndex(DM,PetscInt); 87ba4fc9c6SDave May PETSC_EXTERN PetscErrorCode DMSwarmCopyPoint(DM dm,PetscInt,PetscInt); 88934315b8SMatthew G. Knepley 89934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmGetLocalSize(DM,PetscInt*); 90934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmGetSize(DM,PetscInt*); 91934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmMigrate(DM,PetscBool); 92934315b8SMatthew G. Knepley 93934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmCollectViewCreate(DM); 94934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmCollectViewDestroy(DM); 95934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmSetCellDM(DM,DM); 96934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmGetCellDM(DM,DM*); 97934315b8SMatthew G. Knepley 98934315b8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmSetType(DM,DMSwarmType); 99934315b8SMatthew G. Knepley 1000e2ec84fSDave May PETSC_EXTERN PetscErrorCode DMSwarmSetPointsUniformCoordinates(DM,PetscReal*,PetscReal*,PetscInt*,InsertMode); 10194f7d2dcSDave May PETSC_EXTERN PetscErrorCode DMSwarmSetPointCoordinates(DM,PetscInt,PetscReal*,PetscBool,InsertMode); 1020e2ec84fSDave May PETSC_EXTERN PetscErrorCode DMSwarmInsertPointsUsingCellDM(DM,DMSwarmPICLayoutType,PetscInt); 10392e40656SDave May PETSC_EXTERN PetscErrorCode DMSwarmSetPointCoordinatesCellwise(DM,PetscInt,PetscReal*); 1040e2ec84fSDave May PETSC_EXTERN PetscErrorCode DMSwarmViewFieldsXDMF(DM,const char*,PetscInt,const char**); 10594f7d2dcSDave May PETSC_EXTERN PetscErrorCode DMSwarmViewXDMF(DM,const char*); 1060e2ec84fSDave May 10794f7d2dcSDave May PETSC_EXTERN PetscErrorCode DMSwarmSortGetAccess(DM); 10894f7d2dcSDave May PETSC_EXTERN PetscErrorCode DMSwarmSortRestoreAccess(DM); 10994f7d2dcSDave May PETSC_EXTERN PetscErrorCode DMSwarmSortGetPointsPerCell(DM,PetscInt,PetscInt*,PetscInt**); 11094f7d2dcSDave May PETSC_EXTERN PetscErrorCode DMSwarmSortGetNumberOfPointsPerCell(DM,PetscInt,PetscInt*); 11194f7d2dcSDave May PETSC_EXTERN PetscErrorCode DMSwarmSortGetIsValid(DM,PetscBool*); 11294f7d2dcSDave May PETSC_EXTERN PetscErrorCode DMSwarmSortGetSizes(DM,PetscInt*,PetscInt*); 11394f7d2dcSDave May 11494f7d2dcSDave May PETSC_EXTERN PetscErrorCode DMSwarmProjectFields(DM,PetscInt,const char**,Vec**,PetscBool); 115*4cc7f7b2SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSwarmCreateMassMatrixSquare(DM,DM,Mat*); 116dc5f5ce9SDave May 1173d5c7219SDave May #endif 118