xref: /petsc/src/dm/impls/plex/plexcgns.c (revision 5f34f2dc1c2621700176370c8c2a53775adcdbf1)
1e1b39ce3SMatthew G. Knepley #define PETSCDM_DLL
2af0996ceSBarry Smith #include <petsc/private/dmpleximpl.h>    /*I   "petscdmplex.h"   I*/
3e1b39ce3SMatthew G. Knepley 
444cd5272SMichael Lange /*@C
544cd5272SMichael Lange   DMPlexCreateCGNS - Create a DMPlex mesh from a CGNS file.
644cd5272SMichael Lange 
7d083f849SBarry Smith   Collective
844cd5272SMichael Lange 
944cd5272SMichael Lange   Input Parameters:
1044cd5272SMichael Lange + comm  - The MPI communicator
1144cd5272SMichael Lange . filename - The name of the CGNS file
1244cd5272SMichael Lange - interpolate - Create faces and edges in the mesh
1344cd5272SMichael Lange 
1444cd5272SMichael Lange   Output Parameter:
1544cd5272SMichael Lange . dm  - The DM object representing the mesh
1644cd5272SMichael Lange 
17*5f34f2dcSJed Brown   Note: https://cgns.github.io
1844cd5272SMichael Lange 
1944cd5272SMichael Lange   Level: beginner
2044cd5272SMichael Lange 
21db781477SPatrick Sanan .seealso: `DMPlexCreate()`, `DMPlexCreateCGNS()`, `DMPlexCreateExodus()`
2244cd5272SMichael Lange @*/
2344cd5272SMichael Lange PetscErrorCode DMPlexCreateCGNSFromFile(MPI_Comm comm, const char filename[], PetscBool interpolate, DM *dm)
2444cd5272SMichael Lange {
2544cd5272SMichael Lange   PetscFunctionBegin;
2644cd5272SMichael Lange   PetscValidCharPointer(filename, 2);
2744cd5272SMichael Lange #if defined(PETSC_HAVE_CGNS)
28*5f34f2dcSJed Brown   PetscCall(DMPlexCreateCGNSFromFile_Internal(comm, filename, interpolate, dm));
2944cd5272SMichael Lange #else
3044cd5272SMichael Lange   SETERRQ(comm, PETSC_ERR_SUP, "Loading meshes requires CGNS support. Reconfigure using --with-cgns-dir");
3144cd5272SMichael Lange #endif
32*5f34f2dcSJed Brown   PetscFunctionReturn(0);
3344cd5272SMichael Lange }
3444cd5272SMichael Lange 
35e1b39ce3SMatthew G. Knepley /*@
3644cd5272SMichael Lange   DMPlexCreateCGNS - Create a DMPlex mesh from a CGNS file ID.
37e1b39ce3SMatthew G. Knepley 
38d083f849SBarry Smith   Collective
39e1b39ce3SMatthew G. Knepley 
40e1b39ce3SMatthew G. Knepley   Input Parameters:
41e1b39ce3SMatthew G. Knepley + comm  - The MPI communicator
42e1b39ce3SMatthew G. Knepley . cgid - The CG id associated with a file and obtained using cg_open
43e1b39ce3SMatthew G. Knepley - interpolate - Create faces and edges in the mesh
44e1b39ce3SMatthew G. Knepley 
45e1b39ce3SMatthew G. Knepley   Output Parameter:
46e1b39ce3SMatthew G. Knepley . dm  - The DM object representing the mesh
47e1b39ce3SMatthew G. Knepley 
48*5f34f2dcSJed Brown   Note: https://cgns.github.io
49e1b39ce3SMatthew G. Knepley 
50e1b39ce3SMatthew G. Knepley   Level: beginner
51e1b39ce3SMatthew G. Knepley 
52db781477SPatrick Sanan .seealso: `DMPlexCreate()`, `DMPlexCreateExodus()`
53e1b39ce3SMatthew G. Knepley @*/
54e1b39ce3SMatthew G. Knepley PetscErrorCode DMPlexCreateCGNS(MPI_Comm comm, PetscInt cgid, PetscBool interpolate, DM *dm)
55e1b39ce3SMatthew G. Knepley {
56e1b39ce3SMatthew G. Knepley   PetscFunctionBegin;
57e1b39ce3SMatthew G. Knepley #if defined(PETSC_HAVE_CGNS)
58*5f34f2dcSJed Brown   PetscCall(DMPlexCreateCGNS_Internal(comm, cgid, interpolate, dm));
59e1b39ce3SMatthew G. Knepley #else
60*5f34f2dcSJed Brown   SETERRQ(comm, PETSC_ERR_SUP, "Loading meshes requires CGNS support. Reconfigure using --download-cgns");
61e1b39ce3SMatthew G. Knepley #endif
62*5f34f2dcSJed Brown   PetscFunctionReturn(0);
63e1b39ce3SMatthew G. Knepley }
64