| pack.c (1ed6e3ff8437baa411029a28c2b08f047df9ad9a) | pack.c (f13dfd9ea68e0ddeee984e65c377a1819eab8a8a) |
|---|---|
| 1#include <../src/dm/impls/composite/packimpl.h> /*I "petscdmcomposite.h" I*/ 2#include <petsc/private/isimpl.h> 3#include <petsc/private/glvisviewerimpl.h> 4#include <petscds.h> 5 6/*@C 7 DMCompositeSetCoupling - Sets user provided routines that compute the coupling between the 8 separate components `DM` in a `DMCOMPOSITE` to build the correct matrix nonzero structure. --- 207 unchanged lines hidden (view full) --- 216 representation. 217 218 Collective 219 220 Input Parameters: 221+ dm - the `DMCOMPOSITE` 222. pvec - packed vector 223. nwanted - number of vectors wanted | 1#include <../src/dm/impls/composite/packimpl.h> /*I "petscdmcomposite.h" I*/ 2#include <petsc/private/isimpl.h> 3#include <petsc/private/glvisviewerimpl.h> 4#include <petscds.h> 5 6/*@C 7 DMCompositeSetCoupling - Sets user provided routines that compute the coupling between the 8 separate components `DM` in a `DMCOMPOSITE` to build the correct matrix nonzero structure. --- 207 unchanged lines hidden (view full) --- 216 representation. 217 218 Collective 219 220 Input Parameters: 221+ dm - the `DMCOMPOSITE` 222. pvec - packed vector 223. nwanted - number of vectors wanted |
| 224- wanted - sorted array of vectors wanted, or `NULL` to get all vectors | 224- wanted - sorted array of vectors wanted, or `NULL` to get all vectors, length `nwanted` |
| 225 226 Output Parameter: | 225 226 Output Parameter: |
| 227. vecs - array of requested global vectors (must be allocated) | 227. vecs - array of requested global vectors (must be previously allocated and of length `nwanted`) |
| 228 229 Level: advanced 230 231 Note: 232 Use `DMCompositeRestoreAccessArray()` to return the vectors when you no longer need them 233 234.seealso: `DMCOMPOSITE`, `DM`, `DMCompositeGetAccess()`, `DMCompositeGetEntries()`, `DMCompositeScatter()`, `DMCompositeGather()` 235@*/ | 228 229 Level: advanced 230 231 Note: 232 Use `DMCompositeRestoreAccessArray()` to return the vectors when you no longer need them 233 234.seealso: `DMCOMPOSITE`, `DM`, `DMCompositeGetAccess()`, `DMCompositeGetEntries()`, `DMCompositeScatter()`, `DMCompositeGather()` 235@*/ |
| 236PetscErrorCode DMCompositeGetAccessArray(DM dm, Vec pvec, PetscInt nwanted, const PetscInt *wanted, Vec vecs[]) | 236PetscErrorCode DMCompositeGetAccessArray(DM dm, Vec pvec, PetscInt nwanted, const PetscInt *wanted, Vec *vecs) |
| 237{ 238 struct DMCompositeLink *link; 239 PetscInt i, wnum; 240 DM_Composite *com = (DM_Composite *)dm->data; 241 PetscInt readonly; 242 PetscBool flg; 243 244 PetscFunctionBegin; --- 31 unchanged lines hidden (view full) --- 276 packed vectors in their local representation. 277 278 Collective 279 280 Input Parameters: 281+ dm - the `DMCOMPOSITE` 282. pvec - packed vector 283. nwanted - number of vectors wanted | 237{ 238 struct DMCompositeLink *link; 239 PetscInt i, wnum; 240 DM_Composite *com = (DM_Composite *)dm->data; 241 PetscInt readonly; 242 PetscBool flg; 243 244 PetscFunctionBegin; --- 31 unchanged lines hidden (view full) --- 276 packed vectors in their local representation. 277 278 Collective 279 280 Input Parameters: 281+ dm - the `DMCOMPOSITE` 282. pvec - packed vector 283. nwanted - number of vectors wanted |
| 284- wanted - sorted array of vectors wanted, or NULL to get all vectors | 284- wanted - sorted array of vectors wanted, or `NULL` to get all vectors, length `nwanted` |
| 285 286 Output Parameter: | 285 286 Output Parameter: |
| 287. vecs - array of requested local vectors (must be allocated) | 287. vecs - array of requested local vectors (must be allocated and of length `nwanted`) |
| 288 289 Level: advanced 290 291 Note: 292 Use `DMCompositeRestoreLocalAccessArray()` to return the vectors 293 when you no longer need them. 294 295.seealso: `DMCOMPOSITE`, `DM`, `DMCompositeRestoreLocalAccessArray()`, `DMCompositeGetAccess()`, 296 `DMCompositeGetEntries()`, `DMCompositeScatter()`, `DMCompositeGather()` 297@*/ | 288 289 Level: advanced 290 291 Note: 292 Use `DMCompositeRestoreLocalAccessArray()` to return the vectors 293 when you no longer need them. 294 295.seealso: `DMCOMPOSITE`, `DM`, `DMCompositeRestoreLocalAccessArray()`, `DMCompositeGetAccess()`, 296 `DMCompositeGetEntries()`, `DMCompositeScatter()`, `DMCompositeGather()` 297@*/ |
| 298PetscErrorCode DMCompositeGetLocalAccessArray(DM dm, Vec pvec, PetscInt nwanted, const PetscInt *wanted, Vec vecs[]) | 298PetscErrorCode DMCompositeGetLocalAccessArray(DM dm, Vec pvec, PetscInt nwanted, const PetscInt *wanted, Vec *vecs) |
| 299{ 300 struct DMCompositeLink *link; 301 PetscInt i, wnum; 302 DM_Composite *com = (DM_Composite *)dm->data; 303 PetscInt readonly; 304 PetscInt nlocal = 0; 305 PetscBool flg; 306 --- 84 unchanged lines hidden (view full) --- 391 DMCompositeRestoreAccessArray - Returns the vectors obtained with `DMCompositeGetAccessArray()` 392 393 Collective 394 395 Input Parameters: 396+ dm - the `DMCOMPOSITE` object 397. pvec - packed vector 398. nwanted - number of vectors wanted | 299{ 300 struct DMCompositeLink *link; 301 PetscInt i, wnum; 302 DM_Composite *com = (DM_Composite *)dm->data; 303 PetscInt readonly; 304 PetscInt nlocal = 0; 305 PetscBool flg; 306 --- 84 unchanged lines hidden (view full) --- 391 DMCompositeRestoreAccessArray - Returns the vectors obtained with `DMCompositeGetAccessArray()` 392 393 Collective 394 395 Input Parameters: 396+ dm - the `DMCOMPOSITE` object 397. pvec - packed vector 398. nwanted - number of vectors wanted |
| 399. wanted - sorted array of vectors wanted, or NULL to get all vectors 400- vecs - array of global vectors to return | 399. wanted - sorted array of vectors wanted, or `NULL` to restore all vectors 400- vecs - array of global vectors |
| 401 402 Level: advanced 403 404.seealso: `DMCOMPOSITE`, `DM`, `DMCompositeRestoreAccess()`, `DMCompositeRestoreEntries()`, `DMCompositeScatter()`, `DMCompositeGather()` 405@*/ | 401 402 Level: advanced 403 404.seealso: `DMCOMPOSITE`, `DM`, `DMCompositeRestoreAccess()`, `DMCompositeRestoreEntries()`, `DMCompositeScatter()`, `DMCompositeGather()` 405@*/ |
| 406PetscErrorCode DMCompositeRestoreAccessArray(DM dm, Vec pvec, PetscInt nwanted, const PetscInt *wanted, Vec vecs[]) | 406PetscErrorCode DMCompositeRestoreAccessArray(DM dm, Vec pvec, PetscInt nwanted, const PetscInt *wanted, Vec *vecs) |
| 407{ 408 struct DMCompositeLink *link; 409 PetscInt i, wnum; 410 DM_Composite *com = (DM_Composite *)dm->data; 411 PetscInt readonly; 412 PetscBool flg; 413 414 PetscFunctionBegin; --- 19 unchanged lines hidden (view full) --- 434 DMCompositeRestoreLocalAccessArray - Returns the vectors obtained with `DMCompositeGetLocalAccessArray()`. 435 436 Collective 437 438 Input Parameters: 439+ dm - the `DMCOMPOSITE` object 440. pvec - packed vector 441. nwanted - number of vectors wanted | 407{ 408 struct DMCompositeLink *link; 409 PetscInt i, wnum; 410 DM_Composite *com = (DM_Composite *)dm->data; 411 PetscInt readonly; 412 PetscBool flg; 413 414 PetscFunctionBegin; --- 19 unchanged lines hidden (view full) --- 434 DMCompositeRestoreLocalAccessArray - Returns the vectors obtained with `DMCompositeGetLocalAccessArray()`. 435 436 Collective 437 438 Input Parameters: 439+ dm - the `DMCOMPOSITE` object 440. pvec - packed vector 441. nwanted - number of vectors wanted |
| 442. wanted - sorted array of vectors wanted, or NULL to restore all vectors 443- vecs - array of local vectors to return | 442. wanted - sorted array of vectors wanted, or `NULL` to restore all vectors 443- vecs - array of local vectors |
| 444 445 Level: advanced 446 447 Note: | 444 445 Level: advanced 446 447 Note: |
| 448 nwanted and wanted must match the values given to `DMCompositeGetLocalAccessArray()` | 448 `nwanted` and `wanted` must match the values given to `DMCompositeGetLocalAccessArray()` |
| 449 otherwise the call will fail. 450 451.seealso: `DMCOMPOSITE`, `DM`, `DMCompositeGetLocalAccessArray()`, `DMCompositeRestoreAccessArray()`, 452 `DMCompositeRestoreAccess()`, `DMCompositeRestoreEntries()`, 453 `DMCompositeScatter()`, `DMCompositeGather()` 454@*/ 455PetscErrorCode DMCompositeRestoreLocalAccessArray(DM dm, Vec pvec, PetscInt nwanted, const PetscInt *wanted, Vec *vecs) 456{ --- 392 unchanged lines hidden (view full) --- 849 850 Output Parameter: 851. ltogs - the individual mappings for each packed vector. Note that this includes 852 all the ghost points that individual ghosted `DMDA` may have. 853 854 Level: advanced 855 856 Note: | 449 otherwise the call will fail. 450 451.seealso: `DMCOMPOSITE`, `DM`, `DMCompositeGetLocalAccessArray()`, `DMCompositeRestoreAccessArray()`, 452 `DMCompositeRestoreAccess()`, `DMCompositeRestoreEntries()`, 453 `DMCompositeScatter()`, `DMCompositeGather()` 454@*/ 455PetscErrorCode DMCompositeRestoreLocalAccessArray(DM dm, Vec pvec, PetscInt nwanted, const PetscInt *wanted, Vec *vecs) 456{ --- 392 unchanged lines hidden (view full) --- 849 850 Output Parameter: 851. ltogs - the individual mappings for each packed vector. Note that this includes 852 all the ghost points that individual ghosted `DMDA` may have. 853 854 Level: advanced 855 856 Note: |
| 857 Each entry of ltogs should be destroyed with `ISLocalToGlobalMappingDestroy()`, the ltogs array should be freed with `PetscFree()`. | 857 Each entry of `ltogs` should be destroyed with `ISLocalToGlobalMappingDestroy()`, `ltogs` should be freed with `PetscFree()`. |
| 858 859.seealso: `DMCOMPOSITE`, `DM`, `DMDestroy()`, `DMCompositeAddDM()`, `DMCreateGlobalVector()`, 860 `DMCompositeGather()`, `DMCompositeCreate()`, `DMCompositeGetAccess()`, `DMCompositeScatter()`, 861 `DMCompositeGetLocalVectors()`, `DMCompositeRestoreLocalVectors()`, `DMCompositeGetEntries()` 862@*/ | 858 859.seealso: `DMCOMPOSITE`, `DM`, `DMDestroy()`, `DMCompositeAddDM()`, `DMCreateGlobalVector()`, 860 `DMCompositeGather()`, `DMCompositeCreate()`, `DMCompositeGetAccess()`, `DMCompositeScatter()`, 861 `DMCompositeGetLocalVectors()`, `DMCompositeRestoreLocalVectors()`, `DMCompositeGetEntries()` 862@*/ |
| 863PetscErrorCode DMCompositeGetISLocalToGlobalMappings(DM dm, ISLocalToGlobalMapping *ltogs[]) | 863PetscErrorCode DMCompositeGetISLocalToGlobalMappings(DM dm, ISLocalToGlobalMapping **ltogs) |
| 864{ 865 PetscInt i, *idx, n, cnt; 866 struct DMCompositeLink *next; 867 PetscMPIInt rank; 868 DM_Composite *com = (DM_Composite *)dm->data; 869 PetscBool flg; 870 871 PetscFunctionBegin; --- 69 unchanged lines hidden (view full) --- 941 scatter to a composite local vector. The user should not typically need to know which is being done. 942 943 To get the composite global indices at all local points (including ghosts), use `DMCompositeGetISLocalToGlobalMappings()`. 944 945 To get index sets for pieces of the composite global vector, use `DMCompositeGetGlobalISs()`. 946 947 Each returned `IS` should be destroyed with `ISDestroy()`, the array should be freed with `PetscFree()`. 948 | 864{ 865 PetscInt i, *idx, n, cnt; 866 struct DMCompositeLink *next; 867 PetscMPIInt rank; 868 DM_Composite *com = (DM_Composite *)dm->data; 869 PetscBool flg; 870 871 PetscFunctionBegin; --- 69 unchanged lines hidden (view full) --- 941 scatter to a composite local vector. The user should not typically need to know which is being done. 942 943 To get the composite global indices at all local points (including ghosts), use `DMCompositeGetISLocalToGlobalMappings()`. 944 945 To get index sets for pieces of the composite global vector, use `DMCompositeGetGlobalISs()`. 946 947 Each returned `IS` should be destroyed with `ISDestroy()`, the array should be freed with `PetscFree()`. 948 |
| 949.seealso: `DMCOMPOSITE`, `DM`, `DMCompositeGetGlobalISs()`, `DMCompositeGetISLocalToGlobalMappings()`, `MatGetLocalSubMatrix()`, `MatCreateLocalRef()` | 949 Fortran Note: 950 Pass in an array long enough to hold all the `IS`, see `DMCompositeGetNumberDM()` 951 952.seealso: `DMCOMPOSITE`, `DM`, `DMCompositeGetGlobalISs()`, `DMCompositeGetISLocalToGlobalMappings()`, `MatGetLocalSubMatrix()`, 953 `MatCreateLocalRef()`, `DMCompositeGetNumberDM()` |
| 950@*/ | 954@*/ |
| 951PetscErrorCode DMCompositeGetLocalISs(DM dm, IS *is[]) | 955PetscErrorCode DMCompositeGetLocalISs(DM dm, IS **is) |
| 952{ 953 DM_Composite *com = (DM_Composite *)dm->data; 954 struct DMCompositeLink *link; 955 PetscInt cnt, start; 956 PetscBool flg; 957 958 PetscFunctionBegin; 959 PetscValidHeaderSpecific(dm, DM_CLASSID, 1); --- 19 unchanged lines hidden (view full) --- 979. dm - the `DMCOMPOSITE` object 980 981 Output Parameter: 982. is - the array of index sets 983 984 Level: advanced 985 986 Notes: | 956{ 957 DM_Composite *com = (DM_Composite *)dm->data; 958 struct DMCompositeLink *link; 959 PetscInt cnt, start; 960 PetscBool flg; 961 962 PetscFunctionBegin; 963 PetscValidHeaderSpecific(dm, DM_CLASSID, 1); --- 19 unchanged lines hidden (view full) --- 983. dm - the `DMCOMPOSITE` object 984 985 Output Parameter: 986. is - the array of index sets 987 988 Level: advanced 989 990 Notes: |
| 987 The is entries should be destroyed with `ISDestroy()`, the is array should be freed with `PetscFree()` | 991 The `is` entries should be destroyed with `ISDestroy()`, `is` should be freed with `PetscFree()` |
| 988 989 These could be used to extract a subset of vector entries for a "multi-physics" preconditioner 990 991 Use `DMCompositeGetLocalISs()` for index sets in the packed local numbering, and 992 `DMCompositeGetISLocalToGlobalMappings()` for to map local sub-`DM` (including ghost) indices to packed global 993 indices. 994 995 Fortran Notes: --- 236 unchanged lines hidden (view full) --- 1232 dmn = va_arg(Argp, DM *); 1233 if (dmn) *dmn = next->dm; 1234 next = next->next; 1235 } 1236 va_end(Argp); 1237 PetscFunctionReturn(PETSC_SUCCESS); 1238} 1239 | 992 993 These could be used to extract a subset of vector entries for a "multi-physics" preconditioner 994 995 Use `DMCompositeGetLocalISs()` for index sets in the packed local numbering, and 996 `DMCompositeGetISLocalToGlobalMappings()` for to map local sub-`DM` (including ghost) indices to packed global 997 indices. 998 999 Fortran Notes: --- 236 unchanged lines hidden (view full) --- 1236 dmn = va_arg(Argp, DM *); 1237 if (dmn) *dmn = next->dm; 1238 next = next->next; 1239 } 1240 va_end(Argp); 1241 PetscFunctionReturn(PETSC_SUCCESS); 1242} 1243 |
| 1240/*@ | 1244/*@C |
| 1241 DMCompositeGetEntriesArray - Gets the DM for each entry in a `DMCOMPOSITE` 1242 1243 Not Collective 1244 1245 Input Parameter: 1246. dm - the `DMCOMPOSITE` object 1247 1248 Output Parameter: --- 485 unchanged lines hidden --- | 1245 DMCompositeGetEntriesArray - Gets the DM for each entry in a `DMCOMPOSITE` 1246 1247 Not Collective 1248 1249 Input Parameter: 1250. dm - the `DMCOMPOSITE` object 1251 1252 Output Parameter: --- 485 unchanged lines hidden --- |