1e1589f56SBarry Smith /* 2e1589f56SBarry Smith Objects to manage the interactions between the mesh data structures and the algebraic objects 3e1589f56SBarry Smith */ 4*3c48a1e8SJed Brown #if !defined(__PETSCDM_H) 5*3c48a1e8SJed Brown #define __PETSCDM_H 662cbcd01SMatthew G Knepley #include "petscmat.h" 7e1589f56SBarry Smith #include "petscao.h" 8e1589f56SBarry Smith PETSC_EXTERN_CXX_BEGIN 9e1589f56SBarry Smith 107087cfbeSBarry Smith extern PetscErrorCode DMInitializePackage(const char[]); 11e1589f56SBarry Smith /*S 12e1589f56SBarry Smith DM - Abstract PETSc object that manages an abstract grid object 13e1589f56SBarry Smith 14e1589f56SBarry Smith Level: intermediate 15e1589f56SBarry Smith 16e1589f56SBarry Smith Concepts: grids, grid refinement 17e1589f56SBarry Smith 18325fc9f4SBarry Smith Notes: The DMDACreate() based object and the DMCompositeCreate() based object are examples of DMs 19e1589f56SBarry Smith 20325fc9f4SBarry Smith Though the DM objects require the petscsnes.h include files the DM library is 21e1589f56SBarry Smith NOT dependent on the SNES or KSP library. In fact, the KSP and SNES libraries depend on 22e1589f56SBarry Smith DM. (This is not great design, but not trivial to fix). 23e1589f56SBarry Smith 24e1589f56SBarry Smith .seealso: DMCompositeCreate(), DMDACreate() 25e1589f56SBarry Smith S*/ 26e1589f56SBarry Smith typedef struct _p_DM* DM; 27e1589f56SBarry Smith 287087cfbeSBarry Smith extern PetscClassId DM_CLASSID; 29e1589f56SBarry Smith 30e1589f56SBarry Smith /*E 31e1589f56SBarry Smith DMType - String with the name of a PETSc DM or the creation function 32e1589f56SBarry Smith with an optional dynamic library name, for example 33e1589f56SBarry Smith http://www.mcs.anl.gov/petsc/lib.a:myveccreate() 34e1589f56SBarry Smith 35e1589f56SBarry Smith Level: beginner 36e1589f56SBarry Smith 37e1589f56SBarry Smith .seealso: DMSetType(), DM 38e1589f56SBarry Smith E*/ 39e1589f56SBarry Smith 40e1589f56SBarry Smith #define DMType char* 41e1589f56SBarry Smith #define DMDA "da" 42e1589f56SBarry Smith #define DMADDA "adda" 43e1589f56SBarry Smith #define DMCOMPOSITE "composite" 44e1589f56SBarry Smith #define DMSLICED "sliced" 45b30b9b2eSMatthew G Knepley #define DMMESH "mesh" 46b30b9b2eSMatthew G Knepley #define DMCARTESIAN "cartesian" 47e1589f56SBarry Smith 48e1589f56SBarry Smith extern PetscFList DMList; 49e1589f56SBarry Smith extern PetscBool DMRegisterAllCalled; 507087cfbeSBarry Smith extern PetscErrorCode DMCreate(MPI_Comm,DM*); 517087cfbeSBarry Smith extern PetscErrorCode DMSetType(DM, const DMType); 527087cfbeSBarry Smith extern PetscErrorCode DMGetType(DM, const DMType *); 537087cfbeSBarry Smith extern PetscErrorCode DMRegister(const char[],const char[],const char[],PetscErrorCode (*)(DM)); 547087cfbeSBarry Smith extern PetscErrorCode DMRegisterAll(const char []); 557087cfbeSBarry Smith extern PetscErrorCode DMRegisterDestroy(void); 56e1589f56SBarry Smith 57e1589f56SBarry Smith /*MC 58e1589f56SBarry Smith DMRegisterDynamic - Adds a new DM component implementation 59e1589f56SBarry Smith 60e1589f56SBarry Smith Synopsis: 61e1589f56SBarry Smith PetscErrorCode DMRegisterDynamic(const char *name,const char *path,const char *func_name, PetscErrorCode (*create_func)(DM)) 62e1589f56SBarry Smith 63e1589f56SBarry Smith Not Collective 64e1589f56SBarry Smith 65e1589f56SBarry Smith Input Parameters: 66e1589f56SBarry Smith + name - The name of a new user-defined creation routine 67e1589f56SBarry Smith . path - The path (either absolute or relative) of the library containing this routine 68e1589f56SBarry Smith . func_name - The name of routine to create method context 69e1589f56SBarry Smith - create_func - The creation routine itself 70e1589f56SBarry Smith 71e1589f56SBarry Smith Notes: 72e1589f56SBarry Smith DMRegisterDynamic() may be called multiple times to add several user-defined DMs 73e1589f56SBarry Smith 74e1589f56SBarry Smith If dynamic libraries are used, then the fourth input argument (routine_create) is ignored. 75e1589f56SBarry Smith 76e1589f56SBarry Smith Sample usage: 77e1589f56SBarry Smith .vb 78e1589f56SBarry Smith DMRegisterDynamic("my_da","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyDMCreate", MyDMCreate); 79e1589f56SBarry Smith .ve 80e1589f56SBarry Smith 81e1589f56SBarry Smith Then, your DM type can be chosen with the procedural interface via 82e1589f56SBarry Smith .vb 83e1589f56SBarry Smith DMCreate(MPI_Comm, DM *); 84e1589f56SBarry Smith DMSetType(DM,"my_da_name"); 85e1589f56SBarry Smith .ve 86e1589f56SBarry Smith or at runtime via the option 87e1589f56SBarry Smith .vb 88e1589f56SBarry Smith -da_type my_da_name 89e1589f56SBarry Smith .ve 90e1589f56SBarry Smith 91e1589f56SBarry Smith Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values. 92e1589f56SBarry Smith If your function is not being put into a shared library then use DMRegister() instead 93e1589f56SBarry Smith 94e1589f56SBarry Smith Level: advanced 95e1589f56SBarry Smith 96e1589f56SBarry Smith .keywords: DM, register 97e1589f56SBarry Smith .seealso: DMRegisterAll(), DMRegisterDestroy(), DMRegister() 98e1589f56SBarry Smith M*/ 99e1589f56SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 100e1589f56SBarry Smith #define DMRegisterDynamic(a,b,c,d) DMRegister(a,b,c,0) 101e1589f56SBarry Smith #else 102e1589f56SBarry Smith #define DMRegisterDynamic(a,b,c,d) DMRegister(a,b,c,d) 103e1589f56SBarry Smith #endif 104e1589f56SBarry Smith 1057087cfbeSBarry Smith extern PetscErrorCode DMView(DM,PetscViewer); 1067087cfbeSBarry Smith extern PetscErrorCode DMDestroy(DM); 1077087cfbeSBarry Smith extern PetscErrorCode DMCreateGlobalVector(DM,Vec*); 1087087cfbeSBarry Smith extern PetscErrorCode DMCreateLocalVector(DM,Vec*); 1097087cfbeSBarry Smith extern PetscErrorCode DMGetLocalVector(DM,Vec *); 1107087cfbeSBarry Smith extern PetscErrorCode DMRestoreLocalVector(DM,Vec *); 1117087cfbeSBarry Smith extern PetscErrorCode DMGetGlobalVector(DM,Vec *); 1127087cfbeSBarry Smith extern PetscErrorCode DMRestoreGlobalVector(DM,Vec *); 1137087cfbeSBarry Smith extern PetscErrorCode DMGetLocalToGlobalMapping(DM,ISLocalToGlobalMapping*); 1147087cfbeSBarry Smith extern PetscErrorCode DMGetLocalToGlobalMappingBlock(DM,ISLocalToGlobalMapping*); 1157087cfbeSBarry Smith extern PetscErrorCode DMGetBlockSize(DM,PetscInt*); 1167087cfbeSBarry Smith extern PetscErrorCode DMGetColoring(DM,ISColoringType,const MatType,ISColoring*); 1177087cfbeSBarry Smith extern PetscErrorCode DMGetMatrix(DM, const MatType,Mat*); 1187087cfbeSBarry Smith extern PetscErrorCode DMGetInterpolation(DM,DM,Mat*,Vec*); 1197087cfbeSBarry Smith extern PetscErrorCode DMGetInjection(DM,DM,VecScatter*); 1207087cfbeSBarry Smith extern PetscErrorCode DMRefine(DM,MPI_Comm,DM*); 1217087cfbeSBarry Smith extern PetscErrorCode DMCoarsen(DM,MPI_Comm,DM*); 1227087cfbeSBarry Smith extern PetscErrorCode DMRefineHierarchy(DM,PetscInt,DM[]); 1237087cfbeSBarry Smith extern PetscErrorCode DMCoarsenHierarchy(DM,PetscInt,DM[]); 1247087cfbeSBarry Smith extern PetscErrorCode DMSetFromOptions(DM); 1257087cfbeSBarry Smith extern PetscErrorCode DMSetUp(DM); 1267087cfbeSBarry Smith extern PetscErrorCode DMGetInterpolationScale(DM,DM,Mat,Vec*); 1277087cfbeSBarry Smith extern PetscErrorCode DMGetAggregates(DM,DM,Mat*); 1287087cfbeSBarry Smith extern PetscErrorCode DMGlobalToLocalBegin(DM,Vec,InsertMode,Vec); 1297087cfbeSBarry Smith extern PetscErrorCode DMGlobalToLocalEnd(DM,Vec,InsertMode,Vec); 1307087cfbeSBarry Smith extern PetscErrorCode DMLocalToGlobalBegin(DM,Vec,InsertMode,Vec); 1317087cfbeSBarry Smith extern PetscErrorCode DMLocalToGlobalEnd(DM,Vec,InsertMode,Vec); 1327087cfbeSBarry Smith extern PetscErrorCode DMGetElements(DM,PetscInt *,PetscInt *,const PetscInt*[]); 1337087cfbeSBarry Smith extern PetscErrorCode DMRestoreElements(DM,PetscInt *,PetscInt *,const PetscInt*[]); 134e1589f56SBarry Smith 1357087cfbeSBarry Smith extern PetscErrorCode DMSetContext(DM,void*); 1367087cfbeSBarry Smith extern PetscErrorCode DMGetContext(DM,void**); 1377087cfbeSBarry Smith extern PetscErrorCode DMSetInitialGuess(DM,PetscErrorCode (*)(DM,Vec)); 1387087cfbeSBarry Smith extern PetscErrorCode DMSetFunction(DM,PetscErrorCode (*)(DM,Vec,Vec)); 1397087cfbeSBarry Smith extern PetscErrorCode DMSetJacobian(DM,PetscErrorCode (*)(DM,Vec,Mat,Mat,MatStructure *)); 1407087cfbeSBarry Smith extern PetscErrorCode DMHasInitialGuess(DM,PetscBool *); 1417087cfbeSBarry Smith extern PetscErrorCode DMHasFunction(DM,PetscBool *); 1427087cfbeSBarry Smith extern PetscErrorCode DMHasJacobian(DM,PetscBool *); 1437087cfbeSBarry Smith extern PetscErrorCode DMComputeInitialGuess(DM,Vec); 1447087cfbeSBarry Smith extern PetscErrorCode DMComputeFunction(DM,Vec,Vec); 1457087cfbeSBarry Smith extern PetscErrorCode DMComputeJacobian(DM,Vec,Mat,Mat,MatStructure *); 1467087cfbeSBarry Smith extern PetscErrorCode DMComputeJacobianDefault(DM,Vec,Mat,Mat,MatStructure *); 1477087cfbeSBarry Smith extern PetscErrorCode DMFinalizePackage(void); 148e1589f56SBarry Smith 149e1589f56SBarry Smith typedef struct NLF_DAAD* NLF; 150e1589f56SBarry Smith 151*3c48a1e8SJed Brown #include "petscbag.h" 152e1589f56SBarry Smith 1537087cfbeSBarry Smith extern PetscErrorCode PetscViewerBinaryMatlabOpen(MPI_Comm, const char [], PetscViewer*); 1547087cfbeSBarry Smith extern PetscErrorCode PetscViewerBinaryMatlabDestroy(PetscViewer); 1557087cfbeSBarry Smith extern PetscErrorCode PetscViewerBinaryMatlabOutputBag(PetscViewer, const char [], PetscBag); 1567087cfbeSBarry Smith extern PetscErrorCode PetscViewerBinaryMatlabOutputVec(PetscViewer, const char [], Vec); 1577087cfbeSBarry Smith extern PetscErrorCode PetscViewerBinaryMatlabOutputVecDA(PetscViewer, const char [], Vec, DM); 158e1589f56SBarry Smith 159e1589f56SBarry Smith PETSC_EXTERN_CXX_END 160e1589f56SBarry Smith #endif 161