1 #include <petsc/private/dmpleximpl.h> /*I "petscdmplex.h" I*/ 2 3 /*@C 4 DMPlexCreateCGNSFromFile - Create a `DMPLEX` mesh from a CGNS file. 5 6 Collective 7 8 Input Parameters: 9 + comm - The MPI communicator 10 . filename - The name of the CGNS file 11 - interpolate - Create faces and edges in the mesh 12 13 Output Parameter: 14 . dm - The `DM` object representing the mesh 15 16 Level: beginner 17 18 Note: 19 https://cgns.github.io 20 21 .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexCreate()`, `DMPlexCreateCGNS()`, `DMPlexCreateExodus()` 22 @*/ 23 PetscErrorCode DMPlexCreateCGNSFromFile(MPI_Comm comm, const char filename[], PetscBool interpolate, DM *dm) 24 { 25 PetscFunctionBegin; 26 PetscAssertPointer(filename, 2); 27 #if defined(PETSC_HAVE_CGNS) 28 PetscCall(DMPlexCreateCGNSFromFile_Internal(comm, filename, interpolate, dm)); 29 #else 30 SETERRQ(comm, PETSC_ERR_SUP, "Loading meshes requires CGNS support. Reconfigure using --with-cgns-dir"); 31 #endif 32 PetscFunctionReturn(PETSC_SUCCESS); 33 } 34 35 /*@ 36 DMPlexCreateCGNS - Create a `DMPLEX` mesh from a CGNS file ID. 37 38 Collective 39 40 Input Parameters: 41 + comm - The MPI communicator 42 . cgid - The CG id associated with a file and obtained using cg_open 43 - interpolate - Create faces and edges in the mesh 44 45 Output Parameter: 46 . dm - The `DM` object representing the mesh 47 48 Level: beginner 49 50 Note: 51 https://cgns.github.io 52 53 .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexCreate()`, `DMPlexCreateExodus()` 54 @*/ 55 PetscErrorCode DMPlexCreateCGNS(MPI_Comm comm, PetscInt cgid, PetscBool interpolate, DM *dm) 56 { 57 PetscFunctionBegin; 58 #if defined(PETSC_HAVE_CGNS) 59 { 60 PetscBool use_parallel_viewer = PETSC_FALSE; 61 62 PetscCall(PetscOptionsGetBool(NULL, NULL, "-dm_plex_cgns_parallel", &use_parallel_viewer, NULL)); 63 if (use_parallel_viewer) PetscCall(DMPlexCreateCGNS_Internal_Parallel(comm, cgid, interpolate, dm)); 64 else PetscCall(DMPlexCreateCGNS_Internal_Serial(comm, cgid, interpolate, dm)); 65 } 66 #else 67 SETERRQ(comm, PETSC_ERR_SUP, "Loading meshes requires CGNS support. Reconfigure using --download-cgns"); 68 #endif 69 PetscFunctionReturn(PETSC_SUCCESS); 70 } 71