1 #include <petsc/private/dmimpl.h> /*I "petscdm.h" I*/ 2 3 #ifdef PETSC_HAVE_LIBCEED 4 #include <petscdmceed.h> 5 6 /*@C 7 DMGetCeed - Get the LibCEED context associated with this DM 8 9 Not collective 10 11 Input Parameter: 12 . DM - The DM 13 14 Output Parameter: 15 . ceed - The LibCEED context 16 17 Level: intermediate 18 19 .seealso: `DMCreate()` 20 @*/ 21 PetscErrorCode DMGetCeed(DM dm, Ceed *ceed) 22 { 23 PetscFunctionBegin; 24 PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 25 PetscValidPointer(ceed, 2); 26 if (!dm->ceed) { 27 char ceedresource[PETSC_MAX_PATH_LEN]; /* libCEED resource specifier */ 28 const char *prefix; 29 30 PetscCall(PetscStrncpy(ceedresource, "/cpu/self", sizeof(ceedresource))); 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 } 38 39 #endif 40