1c9aa14a7SToby Isaac /* 268d54884SBarry Smith DMFOREST, for parallel, hierarchically refined, distributed mesh problems. 3c9aa14a7SToby Isaac */ 4a4963045SJacob Faibussowitsch #pragma once 5c9aa14a7SToby Isaac 6c9aa14a7SToby Isaac #include <petscdm.h> 7c9aa14a7SToby Isaac 8ce78bad3SBarry Smith /* MANSEC = DM */ 9ac09b921SBarry Smith /* SUBMANSEC = DMForest */ 10ac09b921SBarry Smith 11c9aa14a7SToby Isaac /*J 125cb80ecdSBarry Smith DMForestTopology - String with the name of a PETSc `DMFOREST` base mesh topology. The topology is a string (e.g. 135cb80ecdSBarry Smith "cube", "shell") and can be interpreted by subtypes of `DMFOREST`) to construct the base `DM` of a forest during 145cb80ecdSBarry Smith `DMSetUp()`. 15c9aa14a7SToby Isaac 16c9aa14a7SToby Isaac Level: beginner 17c9aa14a7SToby Isaac 18af27ebaaSBarry Smith .seealso: [](ch_dmbase), `DMForestSetTopology()`, `DMForestGetTopology()`, `DMFOREST` 19c9aa14a7SToby Isaac J*/ 20c9aa14a7SToby Isaac typedef const char *DMForestTopology; 21c9aa14a7SToby Isaac 22bb2ed840SToby Isaac /* Just a name for the shape of the domain */ 23c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestSetTopology(DM, DMForestTopology); 24c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetTopology(DM, DMForestTopology *); 25c9aa14a7SToby Isaac 26c9aa14a7SToby Isaac /* this is the coarsest possible forest: can be any DM which we can 27bb2ed840SToby Isaac * convert to a DMForest (right now: plex) */ 28c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestSetBaseDM(DM, DM); 29c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetBaseDM(DM, DM *); 30*2a8381b2SBarry Smith PETSC_EXTERN PetscErrorCode DMForestSetBaseCoordinateMapping(DM, PetscErrorCode (*)(DM, PetscInt, PetscInt, const PetscReal[], PetscReal[], PetscCtx), PetscCtx); 31*2a8381b2SBarry Smith PETSC_EXTERN PetscErrorCode DMForestGetBaseCoordinateMapping(DM, PetscErrorCode (**)(DM, PetscInt, PetscInt, const PetscReal[], PetscReal[], PetscCtx), PetscCtx); 32c9aa14a7SToby Isaac 33ba936b91SToby Isaac /* this is the forest from which we adapt */ 34ba936b91SToby Isaac PETSC_EXTERN PetscErrorCode DMForestSetAdaptivityForest(DM, DM); 35ba936b91SToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetAdaptivityForest(DM, DM *); 36c9aa14a7SToby Isaac 37a1b0c543SToby Isaac PETSC_EXTERN PetscErrorCode DMForestSetAdaptivityPurpose(DM, DMAdaptFlag); 38a1b0c543SToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetAdaptivityPurpose(DM, DMAdaptFlag *); 3926d9498aSToby Isaac 40c9aa14a7SToby Isaac /* what we consider adjacent, for the purposes of cell grading, overlap, etc. */ 41c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestSetAdjacencyDimension(DM, PetscInt); 42c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetAdjacencyDimension(DM, PetscInt *); 43c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestSetAdjacencyCodimension(DM, PetscInt); 44c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetAdjacencyCodimension(DM, PetscInt *); 45c9aa14a7SToby Isaac 46c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestSetPartitionOverlap(DM, PetscInt); 47c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetPartitionOverlap(DM, PetscInt *); 48c9aa14a7SToby Isaac 49c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestSetMinimumRefinement(DM, PetscInt); 50c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetMinimumRefinement(DM, PetscInt *); 51c9aa14a7SToby Isaac 52c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestSetMaximumRefinement(DM, PetscInt); 53c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetMaximumRefinement(DM, PetscInt *); 54c9aa14a7SToby Isaac 5556ba9f64SToby Isaac PETSC_EXTERN PetscErrorCode DMForestSetInitialRefinement(DM, PetscInt); 5656ba9f64SToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetInitialRefinement(DM, PetscInt *); 5756ba9f64SToby Isaac 583616b93eSToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetCellChart(DM, PetscInt *, PetscInt *); 59c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetCellSF(DM, PetscSF *); 60c9aa14a7SToby Isaac 61c9aa14a7SToby Isaac /* flag each cell with an adaptivity count: should match the cell section */ 62a1b0c543SToby Isaac PETSC_EXTERN PetscErrorCode DMForestSetAdaptivityLabel(DM, DMLabel); 63a1b0c543SToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetAdaptivityLabel(DM, DMLabel *); 64c9aa14a7SToby Isaac 65c9aa14a7SToby Isaac /*J 6687497f52SBarry Smith DMForestAdaptivityStrategy - String with the name of a PETSc `DMFOREST` adaptivity strategy 67c9aa14a7SToby Isaac 68c9aa14a7SToby Isaac Level: intermediate 69c9aa14a7SToby Isaac 70af27ebaaSBarry Smith .seealso: [](ch_dmbase), `DMFOREST`, `DMForestSetAdaptivityStrategy()`, `DMForestGetAdaptivityStrategy()`, `DMForestSetGradeFactor()` 71c9aa14a7SToby Isaac J*/ 72c9aa14a7SToby Isaac typedef const char *DMForestAdaptivityStrategy; 73c9aa14a7SToby Isaac #define DMFORESTADAPTALL "all" 74c9aa14a7SToby Isaac #define DMFORESTADAPTANY "any" 75c9aa14a7SToby Isaac 76c9aa14a7SToby Isaac /* how to combine: -flags from multiple processes, 77c9aa14a7SToby Isaac * -coarsen flags from multiple children 78c9aa14a7SToby Isaac */ 793616b93eSToby Isaac PETSC_EXTERN PetscErrorCode DMForestSetAdaptivityStrategy(DM, DMForestAdaptivityStrategy); 803616b93eSToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetAdaptivityStrategy(DM, DMForestAdaptivityStrategy *); 81c9aa14a7SToby Isaac 82bf9b5d84SToby Isaac PETSC_EXTERN PetscErrorCode DMForestSetComputeAdaptivitySF(DM, PetscBool); 83bf9b5d84SToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetComputeAdaptivitySF(DM, PetscBool *); 84bf9b5d84SToby Isaac 85bf9b5d84SToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetAdaptivitySF(DM, PetscSF *, PetscSF *); 86bf9b5d84SToby Isaac 872a133e43SToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetAdaptivitySuccess(DM, PetscBool *); 882a133e43SToby Isaac 890eb7e1eaSToby Isaac PETSC_EXTERN PetscErrorCode DMForestTransferVec(DM, Vec, DM, Vec, PetscBool, PetscReal); 90ac34a06fSStefano Zampini PETSC_EXTERN PetscErrorCode DMForestTransferVecFromBase(DM, Vec, Vec); 9180b27e07SToby Isaac 92c9aa14a7SToby Isaac /* for a quadtree/octree mesh, this is the x:1 condition: 1 indicates a uniform mesh, 93c9aa14a7SToby Isaac * 2 indicates typical 2:1, 94c9aa14a7SToby Isaac */ 95c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestSetGradeFactor(DM, PetscInt); 96c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetGradeFactor(DM, PetscInt *); 97c9aa14a7SToby Isaac 98c9aa14a7SToby Isaac /* weights for repartitioning */ 99c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestSetCellWeights(DM, PetscReal[], PetscCopyMode); 100c7eeac06SToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetCellWeights(DM, PetscReal *[]); 101c9aa14a7SToby Isaac 102c9aa14a7SToby Isaac /* weight multiplier for refinement level: useful for sub-cycling time steps */ 103c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestSetCellWeightFactor(DM, PetscReal); 104c9aa14a7SToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetCellWeightFactor(DM, PetscReal *); 105c9aa14a7SToby Isaac 106c9aa14a7SToby Isaac /* this process's capacity when redistributing the cells */ 1073616b93eSToby Isaac PETSC_EXTERN PetscErrorCode DMForestSetWeightCapacity(DM, PetscReal); 1083616b93eSToby Isaac PETSC_EXTERN PetscErrorCode DMForestGetWeightCapacity(DM, PetscReal *); 109c9aa14a7SToby Isaac 110a0452a8eSToby Isaac /* miscellaneous */ 11120e8089bSToby Isaac PETSC_EXTERN PetscErrorCode DMForestTemplate(DM, MPI_Comm, DM *); 112a0452a8eSToby Isaac 11327d4645fSToby Isaac /* type management */ 11427d4645fSToby Isaac PETSC_EXTERN PetscErrorCode DMForestRegisterType(DMType); 11527d4645fSToby Isaac PETSC_EXTERN PetscErrorCode DMIsForest(DM, PetscBool *); 11627d4645fSToby Isaac 117a0452a8eSToby Isaac /* p4est */ 118a0452a8eSToby Isaac PETSC_EXTERN PetscErrorCode DMP4estGetPartitionForCoarsening(DM, PetscBool *); 119a0452a8eSToby Isaac PETSC_EXTERN PetscErrorCode DMP4estSetPartitionForCoarsening(DM, PetscBool); 120a0452a8eSToby Isaac PETSC_EXTERN PetscErrorCode DMP8estGetPartitionForCoarsening(DM, PetscBool *); 121a0452a8eSToby Isaac PETSC_EXTERN PetscErrorCode DMP8estSetPartitionForCoarsening(DM, PetscBool); 122