1: #include <petsc/private/dmimpl.h> 3: #ifdef PETSC_HAVE_LIBCEED 4: #include <petscdmceed.h> 6: /*@C 7: DMGetCeed - Get the LibCEED context associated with this DM 9: Not collective 11: Input Parameter: 12: . DM - The DM 14: Output Parameter: 15: . ceed - The LibCEED context 17: Level: intermediate 19: .seealso: `DMCreate()` 20: @*/ 21: PetscErrorCode DMGetCeed(DM dm, Ceed *ceed) 22: { 23: PetscFunctionBegin; 26: if (!dm->ceed) { 27: char ceedresource[PETSC_MAX_PATH_LEN]; /* libCEED resource specifier */ 28: const char *prefix; 30: PetscCall(PetscStrcpy(ceedresource, "/cpu/self")); 31: PetscCall(PetscObjectGetOptionsPrefix((PetscObject)dm, &prefix)); 32: PetscCall(PetscOptionsGetString(NULL, prefix, "-dm_ceed", ceedresource, sizeof(ceedresource), NULL)); 33: PetscCallCEED(CeedInit(ceedresource, &dm->ceed)); 34: } 35: *ceed = dm->ceed; 36: PetscFunctionReturn(PETSC_SUCCESS); 37: } 39: #endif