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